:root {
  color-scheme: light;
  --ink: #14201f;
  --muted: #667574;
  --line: #dbe4df;
  --paper: #f6f7f2;
  --panel: #ffffff;
  --primary: #0f3d3e;
  --primary-2: #168a7a;
  --accent: #e3a22f;
  --accent-2: #315f8f;
  --danger: #b83232;
  --success: #2f7f4f;
  --shadow: 0 16px 42px rgba(15, 61, 62, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(22, 138, 122, 0.12), rgba(227, 162, 47, 0.09)),
    #f6f7f2;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.helper-text,
.form-message,
.install-hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.form-message {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.password-toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf8;
  color: var(--primary);
  font-weight: 900;
  padding: 0 12px;
}

.app-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 28px) 32px;
}

.topbar,
.toolbar,
.summary-grid,
.calendar-panel,
.day-form,
.work-hero,
.work-checklist,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 8px;
  padding: 18px;
  background: linear-gradient(135deg, #0f3d3e, #166b68 58%, #315f8f);
  color: #fff;
  border: 0;
}

.topbar .eyebrow,
.topbar .install-hint {
  color: rgba(255, 255, 255, 0.78);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  font-weight: 900;
  white-space: nowrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.22rem;
}

.eyebrow {
  color: var(--primary-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.icon-button,
.nav-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 800;
}

.top-actions .icon-button {
  width: auto;
  min-width: 44px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.toolbar {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px;
}

.month-title {
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  text-transform: capitalize;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.view-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 900;
  flex: 1 1 120px;
}

.view-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.work-hero {
  margin-top: 14px;
  border-radius: 8px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, #fff, #f8fbf8);
  border-top: 4px solid var(--primary-2);
}

.work-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.work-checklist {
  margin-top: 14px;
  border-radius: 8px;
  padding: 16px;
  border-top: 4px solid var(--accent);
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
  background: #fff;
  color: var(--primary);
  font-weight: 900;
  white-space: nowrap;
}

.status-pill[data-status="active"] {
  color: #fff;
  background: var(--success);
  border-color: var(--success);
}

.status-pill[data-status="finished"] {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.courier-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 2px 4px;
  scrollbar-width: thin;
}

.courier-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  min-width: 92px;
}

.courier-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.summary-grid {
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.section-gap {
  margin-top: 12px;
}

.metric {
  border-left: 4px solid var(--primary-2);
  background: #fafdff;
  padding: 10px 12px;
  min-height: 74px;
  border-radius: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.calendar-panel,
.table-panel {
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-row {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.78rem;
  text-align: center;
}

.day-cell {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-cell.outside {
  opacity: 0.35;
}

.day-cell.has-entry {
  border-color: var(--primary-2);
  background: #f2fbfb;
}

.day-number {
  font-weight: 900;
}

.day-info {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table-link {
  border: 0;
  background: transparent;
  color: var(--primary-2);
  padding: 0;
  font-weight: 900;
  text-align: left;
}

.settings-block + .settings-block {
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.settings-row-wide {
  grid-template-columns: 34px repeat(4, minmax(0, 1fr));
}

.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.list-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.alert-danger {
  border-color: var(--danger);
  background: #fff7f7;
}

.alert-warning {
  border-color: var(--accent);
  background: #fffaf0;
}

.alert-info {
  border-color: var(--primary-2);
  background: #f2fbfb;
}

.check-row {
  display: flex;
  min-height: 44px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.check-row input {
  width: auto;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.form-col-span {
  grid-column: 1 / -1;
}

.field-title {
  display: block;
  font-weight: 900;
  margin-bottom: 6px;
}

.permissions-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf8;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-permissions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.permission-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.permission-check input {
  width: auto;
}

.small-btn {
  align-self: center;
}

.day-dialog {
  width: min(620px, calc(100% - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.day-dialog::backdrop {
  background: rgba(16, 36, 62, 0.45);
}

.day-form {
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.receipt-line {
  min-height: 20px;
}

.receipt-line a {
  color: var(--primary-2);
  font-weight: 800;
  text-decoration: none;
}

.dialog-actions {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.primary-button,
.ghost-button,
.secondary-button {
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary);
}

.ghost-button {
  background: #fff;
  color: var(--danger);
  border: 1px solid #efc5c5;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  background: #0f2848;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 999;
}

.toast.toast-error {
  background: #8b2d2d;
}

@media (max-width: 1080px) {
  .settings-row-wide {
    grid-template-columns: 34px repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .permission-grid,
  .compact-permissions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
  .work-hero,
  .list-card {
    align-items: stretch;
    flex-direction: column;
  }
  .work-actions {
    justify-content: stretch;
  }
  .work-actions > * {
    width: 100%;
  }
  .top-actions {
    justify-content: space-between;
  }
  .calendar-panel {
    padding: 8px;
  }
  .weekday-row,
  .calendar-grid {
    gap: 4px;
  }
  .day-cell {
    min-height: 78px;
    padding: 6px;
  }
  .day-info {
    font-size: 0.66rem;
  }
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .view-tab {
    flex-basis: 100%;
  }
  .settings-row,
  .settings-row-wide {
    grid-template-columns: 1fr;
  }
  .row-number {
    width: 100%;
    height: 32px;
  }
}

@media (max-width: 460px) {
  .two-col {
    grid-template-columns: 1fr;
  }
  .summary-grid {
    gap: 8px;
  }
  .metric {
    min-height: 68px;
  }
  .day-cell {
    min-height: 64px;
  }
}
