/* ============================================================
   STARWORLD SmartDelivery — Design System
   ============================================================ */

:root {
  /* STARWORLD CI theme — #980f11 red / #f8bc0c amber / logo yellow */
  --bg: #1c0507;
  --bg2: #2a090c;
  --card: #340c10;
  --card2: #401114;
  --ink: #f7eff0;
  --ink2: #e0c5c8;
  --muted: #a67d82;
  --brand: #f8bc0c;
  --brand2: #ffd75e;
  --brand-soft: rgba(248,188,12,.13);
  --brand-red: #980f11;
  --brand-red2: #b51417;
  --ok: #2bd576;
  --ok-soft: rgba(43,213,118,.12);
  --warn: #f59e0b;
  --danger: #ff5d6c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar (STARWORLD red, CI #980f11) ---------- */
.topbar {
  background: linear-gradient(135deg, #980f11, #7d0c0e);
  border-bottom: 3px solid #f8bc0c;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 18px rgba(0,0,0,.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
  color: #f8bc0c;
  text-decoration: none;
}

.topnav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topnav a {
  padding: 8px 16px;
  border-radius: 99px;
  color: #ffe9c2;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: all .15s;
}
.topnav a:hover { background: rgba(248,188,12,.2); color: #ffd75e; }
.topnav a.active { background: #f8bc0c; color: #5c090b; box-shadow: 0 4px 12px rgba(0,0,0,.35); }

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 26px 0 6px;
}
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 24px 60px; }
.wrap-narrow { max-width: 620px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,.06);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-lg); }

/* ---------- Form ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink2);
  margin: 14px 0 6px;
  letter-spacing: .01em;
}
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #2c333d;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  color: var(--ink);
  background: var(--card2);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(248,188,12,.18);
  background: #4a171c;
}

button.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #5c090b;
  border: 0;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 18px;
  box-shadow: 0 6px 18px rgba(248,188,12,.3);
  transition: transform .12s, box-shadow .12s;
}
button.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(248,188,12,.4); }
button.primary:active { transform: translateY(0); }
button.primary:disabled { background: #6b5636; color: #a89a80; box-shadow: none; cursor: default; }

/* ---------- Badges / zones ---------- */
.zone {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 99px;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .02em;
}

/* ---------- Suggested date chips ---------- */
.sug {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 5px 5px 0 0;
  padding: 8px 16px;
  border: 2px solid var(--ok);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--ok);
  background: var(--ok-soft);
  transition: all .15s;
}
.sug:hover { background: var(--ok); color: #fff; transform: translateY(-2px); }
.sug small { font-weight: 500; opacity: .8; }

.hint { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.5; }

/* ---------- Messages ---------- */
#msg { margin-top: 12px; font-weight: 700; font-size: 14px; }
#msg.ok { color: var(--ok); }
#msg.err { color: var(--danger); }

/* ---------- Calendar grid ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
}

.day {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 118px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
}
.day:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.day.empty { opacity: .45; }
.day.today {
  border: 2px solid var(--brand);
  background: linear-gradient(160deg, var(--card) 55%, rgba(255,196,0,.1));
}
.day .dnum { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.day.today .dnum { color: var(--brand); }
.day .dw { color: var(--muted); font-size: 12px; font-weight: 600; margin: 1px 0 8px; text-transform: uppercase; letter-spacing: .05em; }
.day .badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  margin: 2px 2px 0 0;
  color: #fff;
}

/* ---------- Buttons (small, inline) ---------- */
.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .13s;
}
.btn.call { background: var(--brand-soft); color: var(--brand); }
.btn.call:hover { background: var(--brand); color: #111418; }
.btn.wa { background: var(--ok-soft); color: var(--ok); }
.btn.wa:hover { background: var(--ok); color: #06130c; }
.btn.nav-btn { background: rgba(124,58,237,.15); color: #b79bff; }
.btn.nav-btn:hover { background: #7c3aed; color: #fff; }
.btn.done-btn { background: var(--ok); color: #06130c; margin-left: auto; }
.btn.done-btn:hover { background: #3ae28a; }
.btn.undo-btn { background: #4b5563; color: #f3f4f6; margin-left: auto; }
.btn.undo-btn:hover { background: #6b7280; }

/* 司机端 Today/Tomorrow 切换 tab */
#day-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
  padding: 8px 18px; border-radius: 10px; border: 1px solid rgba(248,188,12,.35);
  background: transparent; color: #cbd5e1; font-weight: 700; cursor: pointer;
}
.tab-btn.active { background: var(--accent, #f8bc0c); color: #1a0505; border-color: transparent; }

/* 司机端 slot 分组 */
.slot-group {
  border: 1px solid rgba(255,255,255,.08); border-radius: 12px;
  margin-bottom: 16px; overflow: hidden;
}
.slot-head {
  padding: 10px 14px; font-weight: 800; letter-spacing: .02em;
  background: rgba(248,188,12,.10); color: var(--accent, #f8bc0c);
  display: flex; align-items: center; gap: 8px;
}
.slot-count {
  margin-left: auto; font-size: 12px; font-weight: 700;
  background: rgba(248,188,12,.18); color: var(--accent, #f8bc0c);
  padding: 2px 10px; border-radius: 999px;
}
.slot-group .order { margin: 0 14px 12px; }

/* Check 页：日期行 */
.date-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; margin-top: 8px; flex-wrap: wrap;
}

/* ---------- Order cards (driver) ---------- */
.order {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.06);
  transition: all .15s;
}
.order.done { opacity: .5; }
.order:not(.done):hover { box-shadow: var(--shadow-lg); }
.order .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.order .inv { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.order .name { font-size: 17px; font-weight: 800; margin: 8px 0 3px; letter-spacing: -.01em; }
.order .addr { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.order .btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* ---------- Map page ---------- */
#map { height: calc(100vh - 64px); border-radius: 0; background: var(--bg); }
.leaflet-popup-content { font-family: var(--font); }
.leaflet-container { background: #1a0a0d; }
.leaflet-control-attribution { background: rgba(26,10,13,.7) !important; color: #b89aa0 !important; }
.leaflet-control-attribution a { color: #d8c3c8 !important; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding: 14px 14px 40px; }
  .page-title { font-size: 22px; margin-top: 18px; }

  /* 手机端 header：品牌一行 + 导航平铺一行，整齐不挤 */
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .brand { width: 100%; font-size: 16px; }
  .topnav {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .topnav a {
    padding: 9px 4px;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    justify-content: center;
  }
}

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card, .day, .order { animation: fadeUp .25s ease both; }
