﻿:root {
      --bg: #e8ebe4;
      --surface: #f7f8f5;
      --ink: #1a2218;
      --muted: #5c6b56;
      --line: #c5cdc0;
      --accent: #c45c26;
      --ok: #2f6b3a;
      --ok-soft: #d5e8d8;
      --warn: #9a6b12;
      --warn-soft: #f5ebc8;
      --bad: #8b2e2e;
      --bad-soft: #f0d6d6;
      --transit: #1f5f8b;
      --transit-soft: #d3e6f2;
      --done: #6a7a64;
      --done-soft: #dde3d9;
      --slot-h: 78px;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: "IBM Plex Sans", system-ui, sans-serif;
      background:
        radial-gradient(ellipse 80% 50% at 10% 0%, #dfe6d8 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 100%, #ddd4c8 0%, transparent 50%),
        var(--bg);
      color: var(--ink);
      min-height: 100vh;
    }

    button, input, select, textarea { font: inherit; }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
      padding: 1rem 1.25rem;
      border-bottom: 1px solid var(--line);
      background: color-mix(in srgb, var(--surface) 88%, transparent);
      backdrop-filter: blur(8px);
      position: sticky;
      top: 0;
      z-index: 20;
    }

    .brand {
      font-family: "DM Sans", sans-serif;
      font-weight: 700;
      font-size: 1.15rem;
      letter-spacing: -0.02em;
    }

    .brand span { color: var(--accent); }

    .seg {
      display: flex;
      gap: 0.35rem;
      background: var(--surface);
      border: 1px solid var(--line);
      padding: 0.25rem;
      border-radius: 10px;
    }

    .seg button {
      border: 0;
      background: transparent;
      font-weight: 500;
      font-size: 0.875rem;
      padding: 0.45rem 0.9rem;
      border-radius: 7px;
      cursor: pointer;
      color: var(--muted);
    }

    .seg button.active {
      background: var(--ink);
      color: #f4f6f2;
    }

    .wrap {
      max-width: 1120px;
      margin: 0 auto;
      padding: 1.25rem;
    }

    .view { display: none; }
    .view.active { display: block; }

    .toolbar {
      display: flex;
      align-items: flex-end;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
      margin-bottom: 1rem;
    }

    .toolbar h1 {
      font-family: "DM Sans", sans-serif;
      font-size: 1.55rem;
      font-weight: 700;
      letter-spacing: -0.03em;
    }

    .toolbar p {
      color: var(--muted);
      font-size: 0.9rem;
      margin-top: 0.2rem;
    }

    .toolbar-actions {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    .icon-btn, .btn {
      border: 1px solid var(--line);
      background: var(--surface);
      height: 36px;
      border-radius: 8px;
      cursor: pointer;
      color: var(--ink);
      padding: 0 0.85rem;
      font-weight: 500;
      font-size: 0.875rem;
    }

    .icon-btn { width: 36px; padding: 0; font-size: 1.1rem; }

    .btn-primary {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }

    .btn-danger {
      background: var(--bad-soft);
      border-color: transparent;
      color: var(--bad);
    }

    .btn-ghost {
      background: transparent;
    }

    .week-grid {
      display: grid;
      grid-template-columns: 72px repeat(5, 1fr);
      gap: 1px;
      background: var(--line);
      border: 1px solid var(--line);
      border-radius: 12px;
      overflow: hidden;
    }

    .cell {
      background: var(--surface);
      min-height: var(--slot-h);
      padding: 0.4rem;
    }

    .cell.head {
      min-height: auto;
      padding: 0.65rem 0.5rem;
      background: #eef1ea;
      text-align: center;
    }

    .cell.head .dow {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--muted);
    }

    .cell.head .dom {
      font-family: "DM Sans", sans-serif;
      font-weight: 700;
      font-size: 1.1rem;
    }

    .cell.head.today .dom { color: var(--accent); }

    .cell.time {
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.75rem;
      color: var(--muted);
      background: #eef1ea;
      font-weight: 500;
    }

    .cell.slot {
      cursor: pointer;
      transition: background 0.12s;
    }

    .cell.slot:hover { background: #eef2ea; }

    .delivery {
      border-radius: 8px;
      padding: 0.4rem 0.5rem;
      font-size: 0.75rem;
      line-height: 1.25;
      border-left: 3px solid;
      margin-bottom: 0.3rem;
      cursor: pointer;
      text-align: left;
      width: 100%;
      font-family: inherit;
      display: block;
    }

    .delivery:last-child { margin-bottom: 0; }

    .delivery .who {
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .delivery .order {
      font-weight: 600;
      font-size: 0.7rem;
      opacity: 0.9;
      margin-bottom: 0.1rem;
    }

    .delivery .addr {
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .st-assigned { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
    .st-confirmed { background: var(--ok-soft); border-color: var(--ok); color: var(--ink); }
    .st-rejected { background: var(--bad-soft); border-color: var(--bad); color: var(--ink); }
    .st-in_transit { background: var(--transit-soft); border-color: var(--transit); color: var(--ink); }
    .st-done { background: var(--done-soft); border-color: var(--done); color: var(--ink); opacity: 0.85; }
    .st-cancelled { background: #e8e8e8; border-color: #888; color: var(--ink); opacity: 0.7; text-decoration: line-through; }

    .legend {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem 1.25rem;
      margin-top: 1rem;
      font-size: 0.8rem;
      color: var(--muted);
    }

    .legend i {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 2px;
      margin-right: 0.35rem;
      vertical-align: middle;
    }

    /* Month */
    .month-grid {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 1px;
      background: var(--line);
      border: 1px solid var(--line);
      border-radius: 12px;
      overflow: hidden;
    }

    .month-head {
      background: #eef1ea;
      padding: 0.55rem;
      text-align: center;
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--muted);
      font-weight: 600;
    }

    .month-day {
      background: var(--surface);
      min-height: 110px;
      padding: 0.45rem;
      cursor: pointer;
      vertical-align: top;
    }

    .month-day:hover { background: #eef2ea; }
    .month-day.outside { background: #e4e8e0; color: var(--muted); }
    .month-day.today .day-num { color: var(--accent); font-weight: 700; }
    .month-day.weekend { background: #f0ebe4; }
    .month-day.weekend.outside { background: #e4dfd8; }

    .day-num {
      font-family: "DM Sans", sans-serif;
      font-size: 0.9rem;
      font-weight: 600;
      margin-bottom: 0.35rem;
    }

    .month-pills {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

    .pill {
      font-size: 0.68rem;
      padding: 0.2rem 0.35rem;
      border-radius: 5px;
      border-left: 3px solid;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      text-align: left;
      width: 100%;
      cursor: pointer;
      font-family: inherit;
    }

    .more {
      font-size: 0.7rem;
      color: var(--muted);
      padding-left: 0.2rem;
    }

    /* Driver */
    .phone-frame {
      max-width: 390px;
      margin: 0 auto;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 28px;
      box-shadow: 0 20px 50px rgba(26, 34, 24, 0.12);
      overflow: hidden;
      min-height: 640px;
      display: flex;
      flex-direction: column;
    }

    .phone-status {
      padding: 0.85rem 1.25rem 0.4rem;
      font-size: 0.75rem;
      font-weight: 600;
      display: flex;
      justify-content: space-between;
      color: var(--muted);
    }

    .phone-body { padding: 0.5rem 1.1rem 1.25rem; flex: 1; }

    .phone-body h2 {
      font-family: "DM Sans", sans-serif;
      font-size: 1.55rem;
      letter-spacing: -0.03em;
    }

    .phone-body .sub {
      color: var(--muted);
      font-size: 0.9rem;
      margin: 0.15rem 0 1rem;
    }

    .day-switch {
      display: flex;
      flex-wrap: wrap;
      gap: 0.35rem;
      margin-bottom: 0.85rem;
    }

    .day-switch.seg button {
      padding: 0.4rem 0.65rem;
      font-size: 0.8rem;
    }

    .driver-nav {
      display: none;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      margin-bottom: 0.85rem;
    }

    .driver-nav.visible { display: flex; }

    .phone-frame.wide {
      max-width: 720px;
      border-radius: 20px;
    }

    .card {
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 14px;
      padding: 1rem;
      margin-bottom: 0.75rem;
    }

    .day-group {
      margin-bottom: 1.1rem;
    }

    .day-group h3 {
      font-family: "DM Sans", sans-serif;
      font-size: 0.95rem;
      margin-bottom: 0.5rem;
      color: var(--muted);
      font-weight: 600;
    }

    .driver-week-grid,
    .driver-month-grid {
      margin-top: 0.25rem;
    }

    .driver-month-grid .month-day {
      min-height: 72px;
    }

    .driver-week-grid .week-grid {
      grid-template-columns: 56px repeat(5, 1fr);
    }

    .card .meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.55rem;
      font-size: 0.8rem;
    }

    .badge {
      font-size: 0.68rem;
      font-weight: 600;
      padding: 0.2rem 0.5rem;
      border-radius: 6px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      white-space: nowrap;
    }

    .badge.wait { background: var(--warn-soft); color: var(--warn); }
    .badge.ok { background: var(--ok-soft); color: var(--ok); }
    .badge.bad { background: var(--bad-soft); color: var(--bad); }
    .badge.transit { background: var(--transit-soft); color: var(--transit); }
    .badge.done { background: var(--done-soft); color: var(--done); }

    .card h3 {
      font-family: "DM Sans", sans-serif;
      font-size: 1.05rem;
      margin-bottom: 0.25rem;
    }

    .card .order-no {
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--accent);
      margin-bottom: 0.2rem;
    }

    .card .addr { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
    .card .note {
      font-size: 0.85rem;
      background: #f0f2ed;
      padding: 0.55rem 0.65rem;
      border-radius: 8px;
      margin-bottom: 0.85rem;
    }

    .actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.5rem;
    }

    .actions button,
    .actions a {
      border: 0;
      font-weight: 600;
      font-size: 0.9rem;
      padding: 0.7rem;
      border-radius: 10px;
      cursor: pointer;
      text-align: center;
      text-decoration: none;
      display: block;
    }

    .actions .btn-ok {
      background: var(--ok);
      color: #fff;
    }

    .actions .btn-no {
      background: #f0d6d6;
      color: #8b2e2e;
    }

    .actions .btn-call {
      grid-column: 1 / -1;
      background: #f3e0d4;
      color: #9a3f12;
      border: 1px solid #e2b896;
    }

    .actions .btn-open {
      grid-column: 1 / -1;
      background: #eef1ea;
      color: var(--ink);
      border: 1px solid var(--line);
    }

    .actions .btn-wide { grid-column: 1 / -1; }

    .actions .btn-transit {
      background: var(--transit);
      color: #fff;
    }

    .actions .btn-done {
      background: var(--ok);
      color: #fff;
    }

    .empty {
      text-align: center;
      color: var(--muted);
      padding: 2rem 1rem;
      font-size: 0.95rem;
    }

    /* Modal */
    .overlay {
      position: fixed;
      inset: 0;
      background: rgba(26, 34, 24, 0.45);
      display: none;
      align-items: flex-end;
      justify-content: center;
      z-index: 50;
      padding: 1rem;
    }

    .overlay.open { display: flex; }

    @media (min-width: 640px) {
      .overlay { align-items: center; }
    }

    .modal {
      background: var(--surface);
      border-radius: 16px;
      width: min(440px, 100%);
      max-height: min(90vh, 720px);
      overflow: auto;
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
    }

    .modal header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 1rem 1.15rem;
      border-bottom: 1px solid var(--line);
      position: sticky;
      top: 0;
      background: var(--surface);
      z-index: 1;
    }

    .modal header h2 {
      font-family: "DM Sans", sans-serif;
      font-size: 1.15rem;
    }

    .modal .body { padding: 1.15rem; }

    .field { margin-bottom: 0.9rem; }

    .field label {
      display: block;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 0.3rem;
    }

    .field input,
    .field select,
    .field textarea {
      width: 100%;
      border: 1px solid var(--line);
      background: #fff;
      border-radius: 8px;
      padding: 0.6rem 0.7rem;
      color: var(--ink);
    }

    .field textarea { min-height: 80px; resize: vertical; }

    .field-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.75rem;
    }

    .modal footer {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      justify-content: flex-end;
      padding: 0 1.15rem 1.15rem;
    }

    .status-chip {
      display: inline-block;
      font-size: 0.75rem;
      font-weight: 600;
      padding: 0.25rem 0.55rem;
      border-radius: 6px;
      margin-bottom: 0.75rem;
    }

    .reject-box {
      display: none;
      margin-top: 0.5rem;
    }

    .reject-box.open { display: block; }

    @media (max-width: 800px) {
      .week-grid { grid-template-columns: 48px repeat(5, 1fr); }
      .delivery .addr { display: none; }
      .month-day { min-height: 84px; }
      .pill .slot-label { display: none; }
    }

/* login + chrome */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.login-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 16px 40px rgba(26, 34, 24, 0.1);
}
.login-card .brand { margin-bottom: 0.75rem; font-size: 1.35rem; }
.login-hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.login-card .field { display: block; margin-bottom: 0.9rem; }
.login-card .field span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.login-card .field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
}
.login-submit { width: 100%; height: 42px; }
.login-error { color: var(--bad); font-size: 0.85rem; margin-bottom: 0.75rem; }
.topbar-right { display: flex; gap: 0.5rem; align-items: center; }
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f4f6f2;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  z-index: 80;
  max-width: 90vw;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  margin-right: 0.35rem;
}
