/* ============================================================
   Dealership Content Calendar — styles
   ============================================================ */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --ink: #1b1f24;
  --ink-2: #5b6470;
  --ink-3: #8a929d;
  --line: #e6e3dd;
  --line-2: #d9d5cd;
  --primary: #15324f;       /* deep dealership navy */
  --primary-ink: #ffffff;
  --accent: #d97706;        /* amber */
  --danger: #c0392b;
  --ok: #15803d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20,28,40,.06), 0 1px 3px rgba(20,28,40,.05);
  --shadow: 0 6px 24px rgba(20,28,40,.10);
  --shadow-lg: 0 18px 50px rgba(20,28,40,.22);
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
::placeholder { color: var(--ink-3); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); font-weight: 500; font-size: 13px;
  transition: background .14s, border-color .14s, transform .04s, box-shadow .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: #1d4368; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { background: #b9650a; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(20,28,40,.05); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(192,57,43,.08); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: rgba(20,28,40,.06); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── App shell ─────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex: none;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  background: var(--primary); color: #fff; display: grid; place-items: center;
}
.brand .mark svg { width: 21px; height: 21px; }
.brand { max-width: 230px; }
.brand h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

.monthnav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.monthnav .label { font-size: 15px; font-weight: 600; min-width: 168px; text-align: center; letter-spacing: -.2px; }

.spacer { flex: 1; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.divider { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }

/* ── Legend / filter bar ───────────────────────────────── */
.legendbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 9px 20px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); flex: none;
}
.legend-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.legend-group .gl { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); font-weight: 600; margin-right: 2px; }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  transition: all .12s;
}
.chip-toggle .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip-toggle.off { opacity: .42; }
.chip-toggle:hover { border-color: var(--ink-3); }

/* ── Filter dropdown ───────────────────────────────────── */
.filter-dd { position: relative; }
.dd-trigger { gap: 8px; }
.dd-count { background: var(--line); color: var(--ink-2); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 600; }
.dd-caret svg { width: 14px; height: 14px; }
.dd-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 35; min-width: 250px; max-height: 64vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.dd-panel.show { display: block; }
.dd-actions { display: flex; gap: 4px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dd-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.dd-row:hover { background: var(--surface-2); }
.dd-row input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; flex: none; }

/* ── Calendar ──────────────────────────────────────────── */
.cal-wrap { flex: 1; overflow: auto; padding: 16px 20px 28px; }
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; min-height: 100%;
}
.dow {
  background: var(--surface); padding: 9px 12px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .7px; color: var(--ink-3);
}
.cell {
  background: var(--surface); min-height: 124px; padding: 7px 8px 9px;
  display: flex; flex-direction: column; gap: 5px; position: relative;
  transition: background .12s; min-width: 0; overflow: hidden;
}
.cell.out { background: var(--surface-2); }
.cell.today { background: #fff7ec; }
.cell:hover { background: #fbfaf8; }
.cell:hover .cell-add { opacity: 1; }
.cell-head { display: flex; align-items: center; justify-content: space-between; }
.cell-date { font-size: 13px; font-weight: 600; color: var(--ink-2); width: 24px; height: 24px; display: grid; place-items: center; }
.cell.out .cell-date { color: var(--ink-3); }
.cell.today .cell-date { background: var(--accent); color: #fff; border-radius: 50%; }
.cell-add {
  opacity: 0; transition: opacity .12s; border: none; background: transparent;
  color: var(--ink-3); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
}
.cell-add:hover { background: rgba(20,28,40,.08); color: var(--ink); }
.cell-add svg { width: 15px; height: 15px; }
.cell-pieces { display: flex; flex-direction: column; gap: 4px; }

.piece-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 7px; border-radius: 6px; font-size: 12px; line-height: 1.25;
  border: 1px solid var(--cat); border-left-width: 3px;
  background: var(--cat-bg); color: var(--ink);
  text-align: left; width: 100%; overflow: hidden;
}
.piece-chip:hover { filter: brightness(.985); box-shadow: var(--shadow-sm); }
.piece-chip .pc-status { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1.5px solid var(--cat); }
.piece-chip .pc-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.piece-chip .pc-plat { font-size: 10px; color: var(--ink-3); flex: none; }
.cell-more { font-size: 11px; color: var(--ink-3); padding-left: 4px; }

/* status fills */
.st-Draft     .pc-status { background: transparent; }
.st-Approved  .pc-status { background: var(--cat); }
.st-Scheduled .pc-status { background: #fff; box-shadow: inset 0 0 0 2px var(--cat); }
.st-Posted    .pc-status { background: var(--ok); border-color: var(--ok); }

/* ── Drawer ────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgba(20,28,40,.34); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 94vw;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 50;
  transform: translateX(100%); transition: transform .24s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-head .dh-sub { font-size: 12px; color: var(--ink-3); }
.drawer-body { flex: 1; overflow: auto; padding: 16px 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex: none; }

/* day list */
.day-piece {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px;
  margin-bottom: 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
  border-left: 4px solid var(--cat);
}
.day-piece:hover { border-color: var(--ink-3); box-shadow: var(--shadow-sm); }
.day-piece .dp-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--cat-bg); color: var(--cat); border: 1px solid var(--cat); }
.status-pill { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.sp-Draft { background: #eef0f2; color: #5b6470; }
.sp-Approved { background: #e3edf9; color: #1d4f86; }
.sp-Scheduled { background: #efe7fb; color: #6b3fb5; }
.sp-Posted { background: #e3f3e8; color: #15803d; }
.day-piece .dp-text { font-size: 13px; color: var(--ink); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* editor fields */
.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,50,79,.12); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 0; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: 1; border: none; background: var(--surface); padding: 8px 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); border-right: 1px solid var(--line-2); transition: background .12s; }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--primary); color: #fff; }
.seg button:not(.on):hover { background: var(--surface-2); }
.hashin { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 7px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.htag { display: inline-flex; align-items: center; gap: 5px; background: #eef1f4; color: var(--ink-2); font-size: 12px; padding: 3px 6px 3px 9px; border-radius: 999px; }
.htag button { border: none; background: transparent; color: var(--ink-3); cursor: pointer; line-height: 1; padding: 0; font-size: 14px; }
.hashin input { border: none; outline: none; flex: 1; min-width: 90px; padding: 4px; }

/* ── Modal (settings / login) ──────────────────────────── */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(20,28,40,.42); opacity: 0; pointer-events: none; transition: opacity .18s; }
.modal-wrap.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; transform: translateY(8px) scale(.98); transition: transform .18s; }
.modal-wrap.show .modal { transform: none; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.help { font-size: 12px; color: var(--ink-3); margin-top: 5px; line-height: 1.4; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch .track { width: 40px; height: 23px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch.on .track { background: var(--ok); }
.switch.on .track::after { transform: translateX(17px); }
.platrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Login ─────────────────────────────────────────────── */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--primary); z-index: 70; padding: 24px; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 380px; max-width: 100%; padding: 30px 28px; }
.login-card .mark { width: 46px; height: 46px; border-radius: 11px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }
.login-card .mark svg { width: 26px; height: 26px; }
.login-card h2 { margin: 0 0 4px; font-size: 19px; }
.login-card p { margin: 0 0 20px; color: var(--ink-3); font-size: 13px; }
.login-err { color: var(--danger); font-size: 12.5px; margin-top: 9px; min-height: 16px; }

/* ── Misc ──────────────────────────────────────────────── */
.empty { text-align: center; color: var(--ink-3); padding: 30px 16px; font-size: 13px; }
.spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.primary):not(.accent) .spin { border-color: rgba(20,28,40,.25); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 9px; animation: tin .2s ease; }
.toast.err { background: var(--danger); }
.toast svg { width: 16px; height: 16px; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.demo-banner { background: var(--accent); color: #fff; font-size: 12px; text-align: center; padding: 5px; font-weight: 500; }
.copybtn-ok { color: var(--ok) !important; }
.gen-meta { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.field-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-meta label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); font-weight: 600; }

/* ════════════════════════════════════════════════════════════
   Mobile (≤ 640px) — phone-friendly layout
   ════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  body { -webkit-tap-highlight-color: transparent; }

  /* Topbar → 3 stacked rows: brand · month nav · actions */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar .spacer { display: none; }
  .brand { flex: 1 1 100%; max-width: none; }
  .brand .sub { display: none; }
  .brand .mark { width: 32px; height: 32px; }
  .monthnav { flex: 1 1 100%; margin-left: 0; justify-content: center; gap: 2px; }
  .monthnav .label { min-width: 0; flex: 1; font-size: 15px; }
  .toolbar { flex: 1 1 100%; gap: 6px; }
  .toolbar .btn { flex: 1; justify-content: center; padding: 9px 8px; }
  .icon-btn { width: 38px; height: 38px; }

  /* Legend / filter bar */
  .legendbar { padding: 8px 12px; gap: 10px; }
  .dd-panel { min-width: 220px; }

  /* Calendar — compact grid; chips become slim color bars */
  .cal-wrap { padding: 10px 8px 22px; }
  .dow { padding: 7px 2px; font-size: 10px; text-align: center; letter-spacing: .4px; }
  .cell { min-height: 62px; padding: 4px 3px 6px; gap: 3px; }
  .cell-date { font-size: 12px; width: 20px; height: 20px; }
  .cell-add { display: none; }              /* tap the day to add/generate */
  .cell-pieces { gap: 3px; }
  .piece-chip {
    height: 6px; padding: 0; gap: 0; border: none; border-radius: 3px;
    background: var(--cat);
  }
  .piece-chip .pc-status,
  .piece-chip .pc-text,
  .piece-chip .pc-plat { display: none; }
  .st-Posted.piece-chip { background: var(--ok); }
  .cell-more { font-size: 9px; padding-left: 2px; }

  /* Drawer → full screen */
  .drawer { width: 100vw; max-width: 100vw; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 14px; padding-right: 14px; }
  .row2 { grid-template-columns: 1fr; }     /* stack category + platform */

  /* Settings modal → near full width */
  .modal-wrap { padding: 12px; }
  .modal { width: 100%; max-height: 92vh; }
  .modal-head { padding: 16px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; }

  /* Login */
  .login { padding: 16px; }
  .login-card { padding: 26px 22px; }

  /* 16px inputs prevent iOS zoom-on-focus */
  .input, .textarea, .select, .hashin input { font-size: 16px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .monthnav .label { font-size: 14px; }
  .toolbar .btn { font-size: 12px; padding: 9px 4px; }
  .cell { min-height: 56px; }
}

/* ════════════════════════════════════════════════════════════
   Dashboard · lot picker · admin
   ════════════════════════════════════════════════════════════ */
.dash { display: flex; flex-direction: column; min-height: 100vh; }
.dash-body { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 20px 44px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dash-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.brand .mark.admin { background: #1b1f24; }

.lot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lot-card {
  display: flex; align-items: center; gap: 14px; text-align: left; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s, transform .04s;
}
.lot-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.lot-card:active { transform: translateY(1px); }
.lc-icon { width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.lc-icon svg { width: 24px; height: 24px; }
.lc-main { flex: 1; min-width: 0; }
.lc-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.lc-go { color: var(--ink-3); display: inline-flex; flex: none; }
.lc-go svg { width: 20px; height: 20px; }

.empty-card { text-align: center; padding: 48px 24px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface); }
.empty-card .ec-icon { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 12px; background: var(--surface-2); color: var(--ink-3); display: grid; place-items: center; }
.empty-card .ec-icon svg { width: 28px; height: 28px; }
.empty-card h3 { margin: 0 0 6px; font-size: 16px; }
.empty-card p { margin: 0 0 16px; color: var(--ink-3); font-size: 13px; }
.empty-card .btn { display: inline-flex; }

.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.ar-icon { width: 40px; height: 40px; flex: none; border-radius: 9px; background: var(--surface-2); color: var(--primary); display: grid; place-items: center; }
.ar-icon svg { width: 22px; height: 22px; }
.ar-main { flex: 1; min-width: 0; }
.ar-name { font-weight: 600; font-size: 15px; }
.ar-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.ar-voice { font-size: 12px; color: var(--ink-2); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.ar-actions { display: flex; gap: 6px; flex: none; }

.login-alt { display: block; text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--ink-3); text-decoration: none; }
.login-alt:hover { color: var(--ink); text-decoration: underline; }
.login.admin { background: #1b1f24; }

@media (max-width: 640px) {
  .dash-body { padding: 16px 12px 32px; }
  .lot-grid { grid-template-columns: 1fr; }
  .admin-row { flex-wrap: wrap; }
  .ar-actions { width: 100%; }
  .ar-voice { max-width: none; white-space: normal; }
}
