/* =====================================================================
   Superior Window Coverings — Dealer Portal & Admin
   Sunlit theme, matched to the main site.
   ===================================================================== */
:root {
  --cream: #faf6ec; --cream-deep: #f4edda; --sand: #ecdfbe;
  --navy: #0b2244; --navy-soft: #1e3a5f; --navy-hover: #133057;
  --ink: #0b2244; --ink-soft: #3a4a66; --ink-mute: #6a7a8f;
  --gold: #eed68e; --gold-deep: #c9a24d; --bronze: #dab375; --bronze-deep: #a8823d;
  --line: rgba(11,34,68,.12); --line-strong: rgba(11,34,68,.25);
  --white: #fffdf6;
  --green: #2e7d4f; --green-bg: #e3f0e7;
  --blue: #24548f;  --blue-bg: #e2ecf7;
  --amber: #9a6b1a; --amber-bg: #f7edd6;
  --red: #a33a2e;   --red-bg: #f7e2de;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--cream); color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

.display { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; letter-spacing: -0.02em; line-height: 1.05; }
.script { font-family: 'Instrument Serif', serif; font-style: italic; color: var(--bronze-deep); font-weight: 400; }
.mono-label { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--bronze-deep); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px; font-size: 14px; font-weight: 600;
  border: 2px solid transparent; transition: all .22s cubic-bezier(.22,1,.36,1); white-space: nowrap;
}
.btn-dark { background: var(--navy); color: var(--cream); }
.btn-dark:hover { background: var(--navy-hover); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(11,34,68,.25); }
.btn-bronze { background: var(--bronze-deep); color: var(--cream); }
.btn-bronze:hover { background: var(--navy); }
.btn-ghost { color: var(--ink); border-color: var(--line-strong); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: var(--red-bg); background: transparent; }
.btn-danger:hover { background: var(--red-bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ============ Login ============ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px;
  background: linear-gradient(160deg, var(--cream) 55%, var(--cream-deep)); }
.login-card { width: 100%; max-width: 420px; background: var(--white); border: 1px solid var(--line);
  border-radius: 20px; padding: 40px 36px; box-shadow: 0 24px 60px rgba(11,34,68,.10); }
.login-card .logo { display: block; height: 58px; padding: 15px 24px; box-sizing: border-box;
  background: var(--ink); border-radius: 12px; margin: 0 auto 26px; }
.login-card h1 { font-size: 30px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--ink-mute); font-size: 14px; margin-bottom: 26px; }
.demo-note { margin-top: 18px; padding: 12px 14px; background: var(--sand); border-radius: 12px;
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }

/* ============ Forms ============ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-mute); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line-strong); border-radius: 10px;
  background: var(--white); transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--bronze-deep); }
.field .hint { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }
.form-error { color: var(--red); background: var(--red-bg); border-radius: 10px; padding: 10px 14px;
  font-size: 13.5px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.check input { width: 16px; height: 16px; accent-color: var(--bronze-deep); }

/* ============ App shell ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--navy); color: var(--cream);
  display: flex; flex-direction: column; padding: 26px 18px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo-box { padding: 0 8px 26px; border-bottom: 1px solid rgba(250,246,236,.15); margin-bottom: 20px; }
.sidebar .logo-box img { height: 26px; filter: brightness(0) invert(1) sepia(.18); }
.sidebar .who { font-size: 12.5px; color: rgba(250,246,236,.65); margin-top: 10px; line-height: 1.4; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { padding: 11px 14px; border-radius: 10px; font-size: 14.5px; font-weight: 500;
  color: rgba(250,246,236,.78); display: flex; align-items: center; gap: 10px; transition: all .15s; }
.sidebar nav a:hover { background: rgba(250,246,236,.08); color: var(--cream); }
.sidebar nav a.active { background: var(--bronze-deep); color: var(--cream); }
.sidebar .spacer { flex: 1; }
.sidebar .mode-tag { font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); padding: 8px 14px; }
.sidebar .signout { margin: 0 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(250,246,236,.3);
  background: transparent; color: var(--cream); font-size: 13.5px; }
.sidebar .signout:hover { background: rgba(250,246,236,.1); }

.main { flex: 1; padding: 40px 48px 80px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-size: 40px; }
.page-head .sub { color: var(--ink-mute); font-size: 15px; margin-top: 4px; }

/* ============ Cards / stats ============ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 30px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.stat .num { font-size: 32px; font-family: 'Instrument Serif', serif; }
.stat .lbl { font-size: 12.5px; color: var(--ink-mute); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; margin-bottom: 22px; }
.card h2 { font-size: 24px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* ============ Tables ============ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tblwrap { overflow-x: auto; }
.tbl td { word-break: break-word; }
.tbl td.right { word-break: normal; white-space: nowrap; }   /* money/date cells never split mid-number */
.tbl th { text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--line-strong); }
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--cream); }
.tbl .right { text-align: right; }
.tbl .clickable { cursor: pointer; }
.empty { text-align: center; color: var(--ink-mute); padding: 36px 20px; font-size: 15px; }

/* ============ Status pills ============ */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-order-placed { background: var(--blue-bg); color: var(--blue); }
.pill.s-in-production { background: var(--amber-bg); color: var(--amber); }
.pill.s-shipped { background: var(--blue-bg); color: var(--blue); }
.pill.s-delivered { background: var(--green-bg); color: var(--green); }
.pill.s-on-hold { background: var(--red-bg); color: var(--red); }
.pill.s-remake { background: var(--red-bg); color: var(--red); }
.pill.s-draft { background: var(--sand); color: var(--bronze-deep); }

/* ============ Timeline ============ */
.timeline { display: flex; align-items: flex-start; margin: 18px 0 6px; }
.tl-step { flex: 1; text-align: center; position: relative; font-size: 12px; color: var(--ink-mute); }
.tl-step .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--cream-deep);
  border: 2px solid var(--line-strong); margin: 0 auto 8px; position: relative; z-index: 2; }
.tl-step::before { content: ''; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 1; }
.tl-step:first-child::before { display: none; }
.tl-step.done .dot { background: var(--bronze-deep); border-color: var(--bronze-deep); }
.tl-step.done::before { background: var(--bronze-deep); }
.tl-step.done { color: var(--ink); font-weight: 600; }
.tl-warn { margin-top: 10px; font-size: 13.5px; color: var(--red); background: var(--red-bg);
  border-radius: 10px; padding: 8px 14px; display: inline-block; }

/* ============ Quote builder ============ */
.builder-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .builder-grid { grid-template-columns: 1fr; } }
.item-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; margin-bottom: 14px; }
.item-card .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.item-card .opts { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.item-head .t { font-weight: 700; font-size: 15px; }
.item-price { font-size: 14px; color: var(--ink-soft); margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.item-price b { color: var(--ink); }
.item-errors { margin-top: 10px; font-size: 13px; color: var(--red); }
.item-errors div::before { content: '⚠ '; }
.summary { background: var(--navy); color: var(--cream); border-radius: 18px; padding: 24px 26px; position: sticky; top: 24px; }
.summary h3 { font-family: 'Instrument Serif', serif; font-size: 24px; font-weight: 400; margin-bottom: 14px; }
.summary .line { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 0; color: rgba(250,246,236,.85); }
.summary .line.total { border-top: 1px solid rgba(250,246,236,.25); margin-top: 10px; padding-top: 14px;
  font-size: 19px; font-weight: 700; color: var(--cream); }
.summary .note { font-size: 12px; color: rgba(250,246,236,.6); margin-top: 12px; line-height: 1.5; }
.summary .btn { width: 100%; margin-top: 14px; }
.summary .btn-gold { background: var(--gold); color: var(--navy); }
.summary .btn-gold:hover { background: var(--gold-deep); color: var(--cream); }

/* ============ Modal ============ */
.modal-bg { position: fixed; inset: 0; background: rgba(11,34,68,.45); display: none;
  align-items: flex-start; justify-content: center; padding: 60px 20px; z-index: 200; overflow-y: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--white); border-radius: 20px; padding: 32px 34px; width: 100%; max-width: 640px;
  box-shadow: 0 30px 80px rgba(11,34,68,.3); }
.modal h2 { font-size: 26px; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .modal .grid2 { grid-template-columns: 1fr; } }

/* ============ Toast ============ */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--navy); color: var(--cream);
  padding: 14px 22px; border-radius: 12px; font-size: 14.5px; box-shadow: 0 16px 40px rgba(11,34,68,.35);
  opacity: 0; transform: translateY(12px); transition: all .3s; z-index: 300; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* ============ Detail rows ============ */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; font-size: 14.5px; }
.kv dt { color: var(--ink-mute); font-weight: 600; }
.itemlist { margin-top: 10px; }
.itemlist .it { padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; display: flex; justify-content: space-between; gap: 14px; }
.itemlist .it:last-child { border-bottom: none; }
.itemlist .it .d { color: var(--ink-mute); font-size: 13px; }

/* ============ Pricing editor ============ */
.price-grid input { width: 90px; padding: 7px 10px; border: 1.5px solid var(--line-strong); border-radius: 8px; text-align: right; }
.banner { background: var(--sand); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 18px; }

/* ============ Fabric picker ============ */
.fab-preview { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 10px 12px;
  background: var(--cream); border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.fab-preview img { width: 84px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-strong); }
.fab-preview .fab-none { width: 84px; height: 60px; border-radius: 8px; background: repeating-linear-gradient(45deg, var(--cream-deep), var(--cream-deep) 6px, var(--sand) 6px, var(--sand) 12px); border: 1px solid var(--line); }
.fab-preview .d { font-size: 12.5px; color: var(--ink-mute); }
.fab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
  max-height: 56vh; overflow-y: auto; padding: 2px; }
.fab-cell { cursor: pointer; border: 2px solid transparent; border-radius: 12px; overflow: hidden;
  background: var(--cream); transition: all .15s; }
.fab-cell:hover { border-color: var(--bronze-deep); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(11,34,68,.12); }
.fab-cell img { width: 100%; height: 96px; object-fit: cover; display: block; }
.fab-cell .cap { padding: 7px 9px; font-size: 12px; line-height: 1.35; }
.fab-cell .cap b { display: block; font-size: 12.5px; }
.fab-cell .cap span { color: var(--ink-mute); display: inline-block; margin-right: 6px; }
.it-swatch { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-strong); flex-shrink: 0; }
.it-swatch.none { display: inline-block; background: repeating-linear-gradient(45deg, var(--cream-deep), var(--cream-deep) 5px, var(--sand) 5px, var(--sand) 10px); }

.fab-cell.oos img { opacity: .4; filter: grayscale(.7); }
.fab-cell.oos { cursor: not-allowed; }
.fab-oos { position: absolute; font-size: 10px; font-weight: 700; letter-spacing: .06em; background: var(--red-bg); color: var(--red);
  padding: 3px 8px; border-radius: 6px; margin: 6px; max-width: calc(100% - 12px); }
.fab-cell { position: relative; }

/* ============ Responsive ============ */
/* (superseded by the mobile/tablet layers at the end of this file) */

/* ============================================================
   MOBILE LAYER (≤760px) — phones only; desktop untouched.
   Turns the dealer tables into stacked cards (no side-scroll),
   collapses the sidebar into a top bar, tames the detail pages.
   ============================================================ */
@media (max-width: 760px){
  .shell{flex-direction:column}
  .sidebar{width:100%;height:auto;min-height:0;box-sizing:border-box;display:flex;flex-direction:row;align-items:center;flex-wrap:wrap;column-gap:10px;row-gap:0;padding:10px 14px 0;position:static}
  .sidebar .logo-box{padding:0;border:none;margin:0;display:flex;align-items:center;flex:1;min-width:0}
  .sidebar .logo-box img{height:20px}
  .sidebar .who{display:none}
  .sidebar .spacer{display:none}
  .sidebar .mode-tag{display:none}
  .sidebar .signout{margin:0;padding:6px 12px;font-size:12.5px;border-radius:99px;flex-shrink:0}
  .sidebar nav{flex-direction:row;flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;gap:5px;flex:1 1 100%;order:5;margin:9px -14px 0;padding:0 14px 11px;scrollbar-width:none}
  .sidebar nav::-webkit-scrollbar{display:none}
  .sidebar nav a{padding:7px 14px;font-size:13.5px;white-space:nowrap;border-radius:99px;flex-shrink:0;background:rgba(250,246,236,.07)}
  .sidebar nav a.active{background:var(--bronze-deep);color:var(--cream)}
  .main{padding:20px 16px 90px;max-width:100%;box-sizing:border-box}
  .page-head{margin-bottom:18px}
  .page-head h1{font-size:30px}
  .card{padding:18px 16px;border-radius:16px}
  .stat .num{font-size:26px}
  .kv{grid-template-columns:112px 1fr;font-size:14px}
  .tl-step{font-size:10.5px}
  .summary{position:static}
  .modal{padding:22px 18px;max-height:92vh;overflow:auto;border-radius:16px}
  .banner{font-size:13px}

  /* dealer tables → cards with inline labels (portal.html sets body.is-dealer) */
  body.is-dealer .tbl thead{display:none}
  body.is-dealer .tbl,body.is-dealer .tbl tbody,body.is-dealer .tbl tr,body.is-dealer .tbl td{display:block;width:100%;box-sizing:border-box}
  body.is-dealer .tbl tr{border:1px solid var(--line);border-radius:14px;padding:10px 14px;margin-bottom:10px;background:var(--white)}
  body.is-dealer .tbl tr:last-child{margin-bottom:0}
  body.is-dealer .tbl tbody tr:hover{background:var(--white)}
  body.is-dealer .tbl td{border:none;padding:5px 0;display:flex;justify-content:space-between;align-items:baseline;gap:14px;text-align:right}
  body.is-dealer .tbl td[data-th]::before{content:attr(data-th);font-size:10.5px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-mute);font-weight:700;flex-shrink:0;text-align:left}
  body.is-dealer .tbl td:not([data-th]){justify-content:flex-end;gap:8px}
}

/* ============================================================
   TABLET LAYER — iPads. Portrait gets breathing room + card
   tables; landscape (≥1025px) keeps the full desktop layout.
   ============================================================ */
@media (min-width: 761px) and (max-width: 1024px){
  .sidebar{width:200px;padding-top:20px}
  .main{padding:28px 30px 70px}
  .page-head h1{font-size:34px}
  .card{padding:22px 22px}
  .kv{grid-template-columns:140px 1fr}
}
/* iPad portrait (768/834): the 7-column order table can't breathe — card it */
@media (min-width: 761px) and (max-width: 900px){
  body.is-dealer .tbl thead{display:none}
  body.is-dealer .tbl,body.is-dealer .tbl tbody,body.is-dealer .tbl tr,body.is-dealer .tbl td{display:block;width:100%;box-sizing:border-box}
  body.is-dealer .tbl tr{border:1px solid var(--line);border-radius:14px;padding:10px 16px;margin-bottom:10px;background:var(--white)}
  body.is-dealer .tbl tr:last-child{margin-bottom:0}
  body.is-dealer .tbl tbody tr:hover{background:var(--white)}
  body.is-dealer .tbl td{border:none;padding:5px 0;display:flex;justify-content:space-between;align-items:baseline;gap:14px;text-align:right}
  body.is-dealer .tbl td[data-th]::before{content:attr(data-th);font-size:10.5px;letter-spacing:.09em;text-transform:uppercase;color:var(--ink-mute);font-weight:700;flex-shrink:0;text-align:left}
  body.is-dealer .tbl td:not([data-th]){justify-content:flex-end;gap:8px}
}

.pill.s-internal-hold { background: #e8e4f4; color: #4b3d8f; }
