/* ThreeMonkey Member Portal — white (default) + dark theme. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e6eb;
  --primary: #2563eb;
  --primary-700: #1d4ed8;
  --primary-contrast: #ffffff;
  --ok: #0a7f3f;
  --ok-bg: #e6f6ec;
  --err: #b42318;
  --err-bg: #fdeceb;
  --warn: #92400e;
  --warn-bg: #fff7e6;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 12px;
}

html[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f242d;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --border: #2a2f3a;
  --primary: #3b82f6;
  --primary-700: #2563eb;
  --primary-contrast: #ffffff;
  --ok: #34d399;
  --ok-bg: #0e2a1e;
  --err: #f87171;
  --err-bg: #2a1414;
  --warn: #fcd34d;
  --warn-bg: #2a2410;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK",
    "Microsoft JhengHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

/* Nav */
.nav { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.nav__inner { max-width: 1000px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 18px; }
.nav__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--text); }
/* Inline brand wordmark (SVG, fill=currentColor) — inherits the nav text colour so it
   stays legible in BOTH themes. Sized by height; width follows the 244x147 viewBox. */
.nav__logo { height: 26px; width: auto; display: block; flex: none; }
.nav__menu { display: flex; flex: 1; align-items: center; gap: 18px; }
.nav__links { display: flex; gap: 6px; flex-wrap: wrap; }
.nav__links a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 14px; }
.nav__links a:hover { background: var(--surface-2); color: var(--text); }
.nav__links a.nav__link--active, .nav__links a.nav__link--active:hover { background: #2563eb; color: #fff; }
.nav__controls { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav__controls--bare { margin-left: auto; }
/* Higher specificity than .btn-ghost so the burger is truly hidden on desktop. */
.nav .nav__burger { display: none; font-size: 18px; line-height: 1; padding: 7px 11px; }

/* Mobile (<600px): one compact row (logo + ☰); links + controls collapse into ☰. */
@media (max-width: 600px) {
  .nav__brand-text { display: none; }
  .nav .nav__burger { display: inline-flex; margin-left: auto; }
  .nav__inner { flex-wrap: wrap; gap: 8px; }
  .nav__menu { display: none; flex-basis: 100%; order: 5; flex-direction: column; align-items: stretch; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
  .nav--open .nav__menu { display: flex; }
  .nav__links { flex-direction: column; gap: 2px; }
  .nav__links a { padding: 11px 10px; font-size: 15px; }
  .nav__menu .nav__controls { margin-left: 0; padding-top: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
}

/* Layout */
.main { max-width: 1000px; margin: 0 auto; padding: 26px 20px 60px; }
.foot { max-width: 1000px; margin: 0 auto; padding: 24px 20px; color: var(--muted); font-size: 13px; }

h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { color: var(--muted); margin-top: 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.stat { text-align: center; }
.stat__num { font-size: 30px; font-weight: 700; }
.stat__label { color: var(--muted); font-size: 13px; }

/* Buttons */
.btn-primary, .btn-ghost {
  font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: 10px 16px; font-weight: 600; transition: background .15s, border-color .15s;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); width: 100%; }
.btn-primary:hover { background: var(--primary-700); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); padding: 7px 12px; font-size: 14px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn-primary { width: auto; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.form input, .form textarea, .form select {
  font: inherit; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); width: 100%;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.form .btn-primary { margin-top: 16px; }
.form textarea { min-height: 80px; resize: vertical; }

/* Auth pages */
.auth-page .main { max-width: 420px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; }
.auth-links a { text-decoration: none; }
.resend { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Alerts / banners */
.alert { padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 14px; }
.alert--error { background: var(--err-bg); color: var(--err); }
.alert--ok { background: var(--ok-bg); color: var(--ok); }
.alert--warn { background: var(--warn-bg); color: var(--warn); }
.banner { border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; border: 1px solid var(--border); }
.banner--warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.banner--accent { background: linear-gradient(135deg, var(--primary), var(--primary-700)); color: #fff; border-color: transparent; }
.banner h2 { color: inherit; }
.banner a.btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--err { background: var(--err-bg); color: var(--err); }
.badge--info { background: rgba(37, 99, 235, .12); color: var(--primary); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }

/* Item lists (gear / shipping) */
.item { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.item__title { font-weight: 700; }
.kv { display: flex; gap: 8px; font-size: 14px; padding: 3px 0; }
.kv__k { color: var(--muted); min-width: 96px; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }

.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; color: var(--text); }
.checklist input { width: auto; }

/* Shipping order wizard */
.ship-note { color: var(--err); font-size: 13px; margin: 6px 0; }
.ship-bag { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; }
.ship-bag select, .ship-bag input { width: auto; flex: 1; min-width: 64px; }
.ship-bag .bag-id { flex: 2; min-width: 120px; }
.ship-bag .bag-del { flex: 0 0 auto; padding: 7px 11px; }
.dest-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.dest-row .dest-pick, .dest-row .dest-text { flex: 1; }
.dest-row .dest-del { padding: 7px 11px; flex: 0 0 auto; }

.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Timeline (Gantt) */
.tl__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tl__inner { min-width: 760px; }
.tl__axis-row, .tl__row { display: grid; grid-template-columns: 136px 1fr; }
.tl__corner, .tl__label { position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.tl__corner { height: 36px; }
.tl__axis { position: relative; height: 36px; }
.tl__month { position: absolute; top: 0; bottom: 0; padding-left: 6px; font-size: 12px; color: var(--muted); border-left: 1px solid var(--border); display: flex; align-items: center; }
.tl__row { border-top: 1px solid var(--border); }
.tl__label { padding: 8px 12px; font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.tl__lane { position: relative; min-height: 50px; }
.tl__bar { position: absolute; top: 12px; height: 26px; border-radius: 6px; display: flex; align-items: center; padding: 0 8px; font-size: 12px; line-height: 1; color: #fff; white-space: nowrap; overflow: hidden; cursor: pointer; box-shadow: var(--shadow); }
.tl__bar:hover { filter: brightness(1.06); }
.tl__bar--blue { background: #1d4ed8; }
.tl__bar--green { background: #0a7f3f; }
.tl__bar--amber { background: #b45309; }
.tl__bar--purple { background: #7c3aed; }
.tl__bar--red { background: #b42318; }
.tl__bar--neutral { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.tl__today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--err); z-index: 2; pointer-events: none; }
.tl__today-cap { position: absolute; top: 2px; transform: translateX(-50%); font-size: 10px; color: var(--err); white-space: nowrap; z-index: 3; }

.tl__bar-top { display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tl__season { font: inherit; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }

/* Bag service sub-row + milestone */
.tl__row--sub .tl__label--sub { font-weight: 400; font-size: 12px; color: var(--muted); padding-left: 22px; }
.tl__lane--sub { min-height: 34px; }
.tl__ms { position: absolute; top: 10px; width: 12px; height: 12px; background: var(--ok); transform: translateX(-50%) rotate(45deg); cursor: pointer; z-index: 1; }
.tl__ms-label { position: absolute; top: 8px; transform: translateX(12px); font-size: 12px; color: var(--ok); white-space: nowrap; cursor: pointer; }
.tl__ms-label--chip { left: 12px; transform: none; color: var(--muted); }

/* Stacked fallback (phones) */
.tl__stack { display: none; padding: 4px; }
.tl__stack-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 8px; background: var(--surface); }
.tl__stack-head { font-weight: 700; margin-bottom: 4px; }
.tl__stack-line { padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; cursor: pointer; }

@media (max-width: 600px) {
  .tl__scroll { display: none; }
  .tl__stack { display: block; }
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.modal__card { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 420px; padding: 22px; max-height: 85vh; overflow: auto; }
.modal__close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.switch input { width: auto; }

/* Shipping wizard — bag checklist + typed destination rows */
.ship-bag .bag-check { flex: 0 0 auto; }
.ship-bag .bag-check input { width: auto; }
.ship-bag .bag-name { flex: 2; min-width: 110px; }
.dest-row-x { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; }
.dest-head { display: flex; gap: 6px; align-items: center; }
.dest-head .dest-type { flex: 1; }
.dest-head .dest-del { flex: 0 0 auto; padding: 7px 11px; }
.dest-fields { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dest-fields select, .dest-fields input { flex: 1; width: auto; min-width: 90px; }
