/* ============================================================
   The Trunkline Tracker — JD Fields & Company
   static/style.css   (v2 — white-knockout sidebar logo)
   ============================================================ */

:root {
  --blue-50:  #eef4fb;
  --blue-100: #d7e6f6;
  --blue-200: #aecbec;
  --blue-300: #7ba9dd;
  --blue-500: #2f6fb5;
  --blue-600: #1f5694;
  --blue-700: #1a467a;
  --blue-800: #0e3656;
  --blue-900: #052c47;

  --gold-50:  #f7f2e2;
  --gold-100: #efe6c8;
  --gold-500: #b79746;
  --gold-600: #9a7d34;

  --slate-50:  #f7f9fb;
  --slate-100: #eef1f5;
  --slate-200: #e1e6ec;
  --slate-300: #cbd3dd;
  --slate-400: #9aa6b5;
  --slate-500: #6b7888;
  --slate-600: #4d5868;
  --slate-900: #141a22;

  --green-50: #eaf5ee; --green-500: #2e8b57; --green-600: #246e45;
  --amber-50: #fdf4e3; --amber-500: #c98a14; --amber-600: #a06f0f;
  --red-50:   #fcecec; --red-500:   #c0392b; --red-600:   #9c2e22;

  --surface: #fff;
  --surface-sunken: var(--slate-50);
  --shell: var(--slate-100);
  --text: var(--slate-900);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --ring: 0 0 0 3px rgba(47,111,181,.22);

  --font-display: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Public Sans', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', Consolas, monospace;

  --radius-md: 7px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(5,44,71,.06), 0 1px 3px rgba(5,44,71,.04);
  --ease: cubic-bezier(.2,0,.2,1);

  /* Legacy names still referenced inline by untouched templates */
  --muted: var(--slate-500);
  --amber: var(--amber-600);
  --green: var(--green-600);
  --rose:  var(--red-600);
  --sky:   var(--blue-600);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--shell);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); text-decoration: underline; }

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

.side {
  width: 236px; flex: 0 0 236px;
  background: var(--blue-900); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.09); }
/* the navy/gold logo is unreadable on the navy sidebar, so it is knocked
   out to solid white; the gold rule underneath carries the brand accent */
.side-brand .logo { height: 34px; width: auto; display: block; filter: brightness(0) invert(1); }
.side-rule { margin-top: 14px; width: 26px; height: 2px; background: var(--gold-500); }
.side-title {
  margin-top: 12px; font-family: var(--font-display);
  font-size: 17px; font-weight: 600; letter-spacing: -.015em; line-height: 1.15;
}
.side-sub { margin-top: 3px; font-size: 11.5px; color: rgba(255,255,255,.5); letter-spacing: .02em; }

.side-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  position: relative; display: block; padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.74);
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.side-nav a.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 2px; background: var(--gold-500);
}
.side-label {
  margin: 16px 12px 6px; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4);
}
.side-foot {
  margin-top: auto; padding: 16px;
  border-top: 1px solid rgba(255,255,255,.09);
  font-size: 11.5px; line-height: 1.5; color: rgba(255,255,255,.55);
  text-wrap: pretty;
}
.side-foot .side-label { margin: 0 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: 0 0 60px;
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  letter-spacing: -.015em; color: var(--blue-900);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.topbar-actions .btn { height: 32px; padding: 0 13px; font-size: 12.5px; }

.content { flex: 1; padding: 24px 26px 60px; min-width: 0; overflow-x: auto; }
.content > * { max-width: 1320px; }

.wrap { max-width: 1320px; }

/* ---------- Buttons ---------- */
.btn, button, summary.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; line-height: 1;
  color: #fff; background: var(--blue-600); border: 1px solid var(--blue-600);
  border-radius: var(--radius-md); cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 1px rgba(5,44,71,.05);
  transition: background 140ms var(--ease), border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.btn:hover, button:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; text-decoration: none; }
.btn:focus-visible, button:focus-visible, input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--ring); }

.btn.secondary, button.secondary {
  color: var(--blue-900); background: var(--surface); border-color: var(--border-strong);
}
.btn.secondary:hover, button.secondary:hover { background: var(--surface-sunken); border-color: var(--border-strong); color: var(--blue-900); }

.btn.danger, button.danger { background: var(--red-500); border-color: var(--red-500); color: #fff; }
.btn.danger:hover, button.danger:hover { background: var(--red-600); border-color: var(--red-600); }

summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
details > summary { cursor: pointer; }

/* ---------- Panels / cards ---------- */
.panel, .excel-sheet > .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
  overflow-x: auto;
  overflow-y: hidden;
}
.panel > h2, h2 {
  margin: 0 0 14px;
  font-family: var(--font-sans);
  font-size: 15px; font-weight: 600; letter-spacing: 0;
  color: var(--blue-900);
}
.panel > table:first-child, .panel > h2 + table { margin-top: 0; }
.excel-sheet { display: block; }

/* ---------- Stat row ---------- */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 16px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.stat .n {
  font-family: var(--font-mono); font-size: 26px; font-weight: 600;
  color: var(--blue-900); line-height: 1;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.stat .n.amber { color: var(--amber-600); }
.stat .n.green { color: var(--green-600); }
.stat .n.rose  { color: var(--red-600); }
.stat .l {
  margin-top: 9px; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--slate-500);
}

/* ---------- Filters / forms ---------- */
.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.field { margin-bottom: 14px; }
.field > label, label {
  display: block; margin-bottom: 5px;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--slate-500);
}
input[type=text], input[type=number], input[type=date], input[type=email],
input:not([type]), select, textarea {
  width: 100%; height: 36px; padding: 0 11px;
  font-family: var(--font-sans); font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
textarea { height: auto; padding: 9px 11px; line-height: 1.5; }
input:hover, select:hover { border-color: var(--slate-400); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--slate-500) 50%),
                    linear-gradient(135deg, var(--slate-500) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 30px;
}
input[type=file] { border: none; padding: 0; height: auto; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 18px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 12px; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--slate-500);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px; border-bottom: 1px solid var(--border);
  vertical-align: top; color: var(--text);
}
tbody tr:hover > td { background: var(--surface-sunken); }
tbody tr:last-child > td { border-bottom: none; }
td[align=right], th[align=right] { text-align: right; }
.numeric, td.numeric {
  font-family: var(--font-mono); text-align: right;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.gp-pos { color: var(--green-600); font-weight: 600; font-family: var(--font-mono); }
.gp-neg { color: var(--red-600);   font-weight: 600; font-family: var(--font-mono); }
.muted, .sub { color: var(--slate-500); }
table table { font-size: 12.5px; }
table table thead th { background: var(--blue-50); color: var(--blue-700); }

.highlighted-po-row > td { background: var(--gold-50) !important; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px;
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .02em;
  border-radius: 999px; white-space: nowrap;
  color: var(--slate-600); background: var(--slate-100);
  border: none;
}
a.badge:hover { text-decoration: none; filter: brightness(.96); }

.badge.Draft, .badge.Quoted, .badge.Entered, .badge.Pending, .badge.SOEEntered, .badge.New {
  color: var(--amber-600); background: var(--amber-50);
}
.badge.Issued, .badge.Emailed, .badge.Ordered, .badge.Released,
.badge.Coating, .badge.Fabrication, .badge.Production,
.badge.MaterialSecured, .badge.POIssued, .badge.POEmailed, .badge.InProduction,
.badge.ReleasedToCoater, .badge.AtCoater, .badge.AtFabricator {
  color: var(--blue-700); background: var(--blue-50);
}
.badge.LetsGo, .badge.Complete, .badge.Received, .badge.Shipped,
.badge.Invoiced, .badge.Paid, .badge.Closed, .badge.BillComplete,
.badge.ShippedToJob, .badge.TalliedInvoiced {
  color: var(--green-600); background: var(--green-50);
}
.badge.Cancelled, .badge.Expired, .badge.Declined, .badge.Hold, .badge.Late {
  color: var(--red-600); background: var(--red-50);
}

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px; margin: 0 0 14px;
  border: 1px solid var(--border); border-left: 3px solid var(--slate-400);
  border-radius: var(--radius-md); background: var(--surface);
  font-size: 13px; box-shadow: var(--shadow-sm);
}
.flash.success { border-left-color: var(--green-500); background: var(--green-50); color: var(--green-600); }
.flash.error   { border-left-color: var(--red-500);   background: var(--red-50);   color: var(--red-600); }
.flash.warning { border-left-color: var(--amber-500); background: var(--amber-50); color: var(--amber-600); }

/* ---------- Upload drop zones ---------- */
.quick-box {
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--blue-900);
  background: var(--blue-50);
  border: 1px dashed var(--blue-200); border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.quick-box:hover, .quick-box.dragover { border-color: var(--blue-500); background: #e6eff9; }
.quick-box .sub { font-weight: 400; color: var(--slate-500); }
.quick-box.busy { opacity: .6; cursor: wait; }

/* ---------- Footer ---------- */
footer {
  margin-top: 34px; padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--slate-500); line-height: 1.6;
  text-wrap: pretty;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 6px; border: 3px solid var(--shell); }

/* ---------- Panel heads ---------- */
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: -20px -22px 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; }
.pipeline-panel, .attention-panel { padding-bottom: 0; }

/* ---------- Pipeline ---------- */
.pipeline {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px; background: var(--border);
  margin: 0 -22px; border-top: 1px solid var(--border);
}
.stage {
  display: block; padding: 15px 14px 14px;
  background: var(--surface); color: var(--text);
  transition: background 140ms var(--ease);
}
.stage:hover { background: var(--surface-sunken); text-decoration: none; color: var(--text); }
.stage.on { background: var(--blue-50); box-shadow: inset 0 -2px 0 var(--blue-600); }
.stage-name {
  display: flex; align-items: baseline; gap: 6px; min-height: 30px;
  font-size: 11.5px; font-weight: 600; color: var(--slate-600); line-height: 1.25;
}
.stage-no { font-family: var(--font-mono); font-size: 10px; color: var(--slate-400); }
.stage-n {
  margin-top: 8px; font-family: var(--font-mono);
  font-size: 24px; font-weight: 600; line-height: 1; color: var(--blue-900);
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.stage-money {
  margin-top: 7px; font-family: var(--font-mono); font-size: 11.5px; color: var(--slate-500);
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.stage-dots { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 3px; min-height: 7px; }
.stage-dots span { width: 7px; height: 7px; border-radius: 2px; background: var(--blue-300); }

/* ---------- Needs you today ---------- */
.attn {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 14px 22px; margin: 0 -22px;
  border-bottom: 1px solid var(--border); color: var(--text);
  transition: background 140ms var(--ease);
}
.attn:hover { background: var(--surface-sunken); text-decoration: none; color: var(--text); }
.attn:last-child { border-bottom: none; }
.attn-dot { flex: 0 0 auto; margin-top: 6px; width: 8px; height: 8px; border-radius: 50%; }
.attn.red   .attn-dot { background: var(--red-500); }
.attn.amber .attn-dot { background: var(--amber-500); }
.attn-body { flex: 1; min-width: 0; display: block; }
.attn-head { display: block; font-size: 13px; color: var(--slate-600); }
.attn-head b { font-family: var(--font-mono); font-weight: 600; color: var(--blue-900); margin-right: 6px; }
.attn-msg { display: block; margin-top: 3px; font-size: 13px; color: var(--text); text-wrap: pretty; }
.attn-note {
  flex: 0 0 auto; font-size: 11.5px; color: var(--slate-500); white-space: nowrap; text-align: right;
}

/* ---------- Table helpers ---------- */
th.num, td.num {
  text-align: right; font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "lnum" 1; white-space: nowrap;
}
th.num { font-family: var(--font-sans); }
a.pkt { font-family: var(--font-mono); font-weight: 600; }
.po-children { margin-top: 3px; padding-left: 12px; }
.po-children > div { margin-top: 2px; font-size: 11.5px; color: var(--slate-500); white-space: nowrap; }
.po-children a { font-family: var(--font-mono); }
.badge.tiny { height: 18px; padding: 0 7px; font-size: 10px; margin-left: 3px; }
.btn.sm, button.sm { height: 28px; padding: 0 10px; font-size: 11.5px; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin-left: 6px; }
td.empty { padding: 26px 12px; text-align: center; }

.filters .field { margin-bottom: 0; min-width: 190px; }
.filters .btn { align-self: flex-end; }
