/*
  RealMFG+ — the design system.

  One dark theme, tuned rather than themed: every surface is a step on the
  same blue-black ramp, every accent comes from one two-stop gradient, and
  nothing is decorated that is not also information. The rules that matter:

    - Numbers are tabular. A column of money that wobbles is unreadable.
    - Status is colour + word, never colour alone.
    - Focus is visible everywhere. This is keyboard software.
    - Motion is 120–160 ms and only on things the user caused.

  Every figure on these screens came out of Postgres. Nothing here computes.
*/

:root {
  /* Surface ramp, darkest to lightest — Real Botanicals slate.
     The brand's own #687e8c (realbotanicals.com's theme colour) anchors
     the ramp: every surface is that hue darkened, every accent is it
     lifted, and the ink is their cream instead of clinical white. */
  --bg:      #0b1013;
  --bg-deep: #080c0e;
  --panel:   #121a1e;
  --panel2:  #182227;
  --panel3:  #1f2b31;
  --line:    #263540;
  --line2:   #334653;

  /* Ink ramp — cream over slate. */
  --ink:     #f1efe7;
  --dim:     #a3b2ba;
  --dimmer:  #687e8c;   /* the brand hex itself */

  /* Semantics. */
  --ok:   #2fd274;
  --warn: #f5a623;
  --bad:  #f0524f;
  --accent:  #7fa3b8;
  --accent2: #b5c49e;
  --grad: linear-gradient(135deg, #7fa3b8 0%, #b5c49e 100%);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  --shadow-pop: 0 24px 64px -16px rgba(0,0,0,.65);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(127,163,184,.08);
  padding: 1px 5px; border-radius: 4px;
}
pre code, td code { background: none; padding: 0; }
::selection { background: rgba(127,163,184,.35); }

/* Scrollbars that belong to the theme rather than to the OS. */
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--line2); border-radius: 99px;
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-track { background: transparent; }

/* Focus is a feature. Everything interactive shows it, the same way. */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none; box-shadow: var(--focus);
}

/* ------------------------------------------------------------ the mark */
.logo { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.logo svg { display: block; }
.logo-word { font-weight: 800; font-size: 15.5px; letter-spacing: -.015em; line-height: 1.15; }
.logo-word span { color: var(--accent); font-weight: 700; }
.logo-word small {
  display: block; font-size: 8.5px; font-weight: 700; letter-spacing: .3em;
  color: var(--dimmer); text-transform: uppercase; margin-top: 1px;
}

/* ------------------------------------------------------------ shell */
header {
  display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 56px;
  background: linear-gradient(180deg, #14202a 0%, #0e161c 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.hamburger {
  display: none; background: none; border: 0; color: var(--dim);
  font-size: 19px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.crumb {
  color: var(--dim); font-size: 13px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumb span { color: var(--dimmer); }
.crumb span::after { content: " / "; color: var(--dimmer); }
.spacer { flex: 1; }
.kbd-hint {
  color: var(--dimmer); font-size: 11.5px; border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; cursor: pointer; user-select: none;
  background: rgba(255,255,255,.02); white-space: nowrap;
}
.kbd-hint:hover { color: var(--dim); border-color: var(--line2); }
.kbd-hint kbd {
  font-family: inherit; font-size: 10.5px; font-weight: 700;
  border: 1px solid var(--line2); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; margin-right: 4px;
}

.layout { display: flex; align-items: flex-start; }
aside {
  width: 216px; flex: 0 0 216px; position: sticky; top: 56px;
  align-self: flex-start; height: calc(100vh - 56px); overflow-y: auto;
  padding: 14px 10px 44px; border-right: 1px solid var(--line);
  background: var(--bg-deep);
}
.content { flex: 1; min-width: 0; }

nav { display: block; }
.navgroup { margin-bottom: 14px; }
.navgroup h4 {
  margin: 0 0 4px 0; padding: 2px 10px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .14em; color: var(--dimmer); font-weight: 800;
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px;
  border-radius: 6px; transition: color .12s ease;
}
.navgroup h4:hover { color: var(--dim); }
.navgroup h4 .chev {
  display: inline-block; font-size: 9px; transition: transform .14s ease;
  transform: rotate(90deg);
}
.navgroup.folded h4 .chev { transform: rotate(0deg); }
.navgroup h4 small {
  margin-left: auto; font-size: 9px; font-weight: 700; color: var(--dimmer);
  background: var(--panel2); border-radius: 8px; padding: 1px 6px;
}
.navgroup h4 small:empty { display: none; }
.navgroup.folded button { display: none; }

/* Subcategories: a quieter header one step in, same folding grammar. */
.navsub { margin: 2px 0 6px; }
.navsub h5 {
  margin: 4px 0 2px; padding: 2px 10px 2px 16px; font-size: 10.5px;
  color: var(--dim); font-weight: 700; letter-spacing: .02em;
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px;
  border-radius: 6px; text-transform: none;
}
.navsub h5:hover { color: var(--ink); }
.navsub h5 .chev {
  display: inline-block; font-size: 8px; color: var(--dimmer);
  transition: transform .14s ease; transform: rotate(90deg);
}
.navsub.folded h5 .chev { transform: rotate(0deg); }
.navsub h5 small {
  margin-left: auto; font-size: 9px; font-weight: 700; color: var(--dimmer);
  background: var(--panel2); border-radius: 8px; padding: 0 6px;
}
.navsub h5 small:empty { display: none; }
.navsub button { padding-left: 22px; }
nav button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--dim); font-size: 13.5px; font-weight: 600; padding: 6px 10px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
nav button:hover { color: var(--ink); background: #16222a; }
nav button.on {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(127,163,184,.16), rgba(181,196,158,.06));
  box-shadow: inset 2.5px 0 0 var(--accent);
}

/* ---------------------------------------------------- pipeline board */
.pipeboard {
  display: flex; gap: 10px; align-items: flex-start;
  overflow-x: auto; padding-bottom: 14px;
}
.pipecol {
  flex: 0 0 240px; min-width: 240px; background: var(--bg-deep);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: 68vh;
}
.pipecol-head {
  padding: 10px 12px 8px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px;
}
.pipecol-head b { font-size: 13px; }
.pipecol-head .muted { font-size: 11.5px; }
.pipecol-head small { color: var(--dimmer); font-size: 10px; }
.pipecol-body { padding: 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.pipecol-empty {
  color: var(--dimmer); font-size: 11.5px; text-align: center;
  padding: 18px 6px; border: 1px dashed var(--line); border-radius: 8px;
}
.pipecol.won  .pipecol-head b { color: var(--ok); }
.pipecol.lost .pipecol-head b { color: var(--dim); }
.pipecol.dropover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.dealcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; margin-bottom: 8px;
  cursor: grab; transition: border-color .12s ease, transform .12s ease;
}
.dealcard:hover { border-color: var(--line2); }
.dealcard:active { cursor: grabbing; }
.dealcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.dealcard.rot { border-left: 3px solid var(--bad); }
.dealcard.closed { opacity: .55; cursor: default; }
.dealcard .dc-name { font-weight: 700; font-size: 12.8px; line-height: 1.3; }
.dealcard .dc-party { color: var(--dim); font-size: 11.5px; margin: 1px 0 5px; }
.dealcard .dc-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px;
}
.dealcard .dc-owner {
  color: var(--dimmer); font-size: 10.5px; margin-top: 4px;
}
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }

main { padding: 24px 28px 12px; max-width: 1480px; animation: rise .16s ease; }
@keyframes rise { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  main { animation: none; }
  * { transition: none !important; }
}
section { display: none; }
section.on { display: block; }

.pagehead { margin-bottom: 20px; }
.pagehead h1 { margin: 0; font-size: 22px; font-weight: 780; letter-spacing: -.022em; }
.pagehead p {
  margin: 6px 0 0; color: var(--dim); font-size: 13px; max-width: 84ch;
  line-height: 1.6;
}

h2 { font-size: 14.5px; margin: 28px 0 12px; letter-spacing: -.005em; font-weight: 720; }
h2:first-child { margin-top: 0; }
.sub {
  color: var(--dim); font-size: 12.5px; margin: -8px 0 12px; max-width: 84ch;
  line-height: 1.6;
}
.period { color: var(--dim); font-size: 12.5px; }
.period b { color: var(--ink); }

.emptystate { padding: 20px 4px; color: var(--dim); font-size: 13px; line-height: 1.65; }
.emptystate b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }

/* ------------------------------------------------------------ layout */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .g4, .g3, .g2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  { .g4, .g3, .g2 { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 55%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--dim); font-weight: 750;
}
.kpi {
  font-size: 27px; font-weight: 800; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.kpi.sm { font-size: 21px; }
.kpi-note { color: var(--dim); font-size: 12px; margin-top: 5px; line-height: 1.5; }
.up { color: var(--ok); } .down { color: var(--bad); } .flat { color: var(--dim); }

/* ------------------------------------------------------------ tables */
.scroll { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--dimmer); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px;
  border-bottom: 1px solid var(--line2); white-space: nowrap;
}
td { padding: 8.5px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: rgba(127,163,184,.05); }
.num {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.muted { color: var(--dim); }

/* ------------------------------------------------------------ badges */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.t-ok   { background: rgba(47,210,116,.13); color: var(--ok); }
.t-warn { background: rgba(245,166,35,.14); color: var(--warn); }
.t-bad  { background: rgba(240,82,79,.14);  color: #ff8a87; }
.t-info { background: rgba(127,163,184,.14); color: #93b8fb; }
.t-dim  { background: #1c2940; color: var(--dim); }

.bar { height: 7px; background: #1c2830; border-radius: 99px; overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }

.note {
  border-left: 3px solid var(--line2); padding: 3px 0 3px 12px; color: var(--dim);
  font-size: 12.5px; margin-top: 8px; line-height: 1.55;
}
.note.warn { border-color: var(--warn); color: #f8cf8a; }
.note.bad  { border-color: var(--bad);  color: #ffa3a1; }

details {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  margin-top: 8px; background: var(--panel2);
}
summary { cursor: pointer; font-weight: 600; font-size: 12.5px; }
details pre {
  margin: 10px 0 0; padding: 10px; background: var(--bg-deep); border-radius: 7px;
  overflow-x: auto; color: #a8c5f0; font-size: 11.5px; line-height: 1.5;
}

.step {
  display: flex; gap: 11px; align-items: flex-start; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; }
.dot {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px; margin-top: 1px;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.dot.done  { background: rgba(47,210,116,.18); color: var(--ok); }
.dot.todo  { background: #1c2940; color: var(--dim); }
.dot.block { background: var(--grad); color: #fff; }

.prop {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: var(--panel); margin-bottom: 11px; box-shadow: var(--shadow);
}
.prop .who { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.prop .sum { font-size: 15px; font-weight: 650; line-height: 1.35; }
.prop .why { color: var(--dim); font-size: 12.5px; margin-top: 6px; }
.ev { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ev span {
  background: var(--bg-deep); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 7px; font-size: 11px; color: #9fb6d6;
  font-family: ui-monospace, monospace;
}

svg text { fill: var(--dim); font-size: 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

footer { color: var(--dimmer); font-size: 11.5px; padding: 30px 28px 46px; line-height: 1.75; }

/* ------------------------------------------------------------ forms */
.hidden { display: none !important; }
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 50;
  background:
    radial-gradient(900px 480px at 18% -10%, rgba(127,163,184,.14), transparent 60%),
    radial-gradient(720px 420px at 88% 108%, rgba(181,196,158,.11), transparent 60%),
    var(--bg);
}
.gate-card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line2); border-radius: 18px;
  padding: 30px; width: 350px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-pop);
}
.gate-brand { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.gate-brand span { color: var(--accent); }
.gate-sub { color: var(--dim); font-size: 13px; margin-bottom: 4px; }
.gate-err { color: #ffa3a1; font-size: 13px; min-height: 18px; }
.gate-link { font-size: 12.5px; color: var(--dim); text-align: center; margin-top: 4px; }

label {
  display: flex; flex-direction: column; gap: 5px; font-size: 12px;
  color: var(--dim); font-weight: 600;
}
input, select, textarea {
  background: var(--bg-deep); border: 1px solid var(--line2); border-radius: 9px;
  color: var(--ink); padding: 9px 11px; font-size: 14px; font-family: inherit;
  width: 100%; transition: border-color .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #35486a; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127,163,184,.18);
}
textarea { min-height: 70px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--dimmer); }

.btn {
  background: var(--grad); border: 0; border-radius: 10px; color: #fff;
  font-weight: 700; font-size: 14px; padding: 10px 16px; cursor: pointer;
  font-family: inherit; letter-spacing: .01em;
  transition: filter .12s ease, transform .08s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: #1b2740; box-shadow: none; color: var(--ink);
  border: 1px solid var(--line2);
}
.btn.ghost:hover { background: #223252; filter: none; }
.btn.danger { background: linear-gradient(135deg, #f0524f, #d03a63); }
.btn.sm { padding: 5.5px 11px; font-size: 12.5px; border-radius: 8px; }
.linkbtn {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
}
.linkbtn:hover { color: var(--ink); }
.who { color: var(--dim); font-size: 12.5px; white-space: nowrap; }
.who b { color: var(--ink); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 130px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

/* ------------------------------------------------------------ modal */
#modal .gate { background: rgba(3,6,11,.78); backdrop-filter: blur(3px); }
#modal .gate-card { animation: pop .14s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; } }

/* ------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 140%);
  background: var(--panel3); border: 1px solid var(--line2); border-radius: 12px;
  padding: 13px 18px; font-size: 14px; font-weight: 600;
  max-width: min(560px, 90vw); box-shadow: var(--shadow-pop);
  transition: transform .18s ease; z-index: 60; line-height: 1.5;
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok  { border-color: rgba(47,210,116,.5);  color: #b9f4d2; }
.toast.bad { border-color: rgba(240,82,79,.55); color: #ffc9c7; }

/* ------------------------------------------------------------ command palette */
.cmdk {
  position: fixed; inset: 0; z-index: 70; display: grid;
  place-items: start center; padding-top: 14vh;
  background: rgba(3,6,11,.7); backdrop-filter: blur(3px);
}
.cmdk-box {
  width: min(540px, 92vw); background: var(--panel2);
  border: 1px solid var(--line2); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow-pop); animation: pop .12s ease;
}
.cmdk-box input {
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: transparent; padding: 14px 16px; font-size: 15px;
}
.cmdk-box input:focus { box-shadow: none; }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
  font-weight: 600; color: var(--ink);
}
.cmdk-item small { color: var(--dimmer); font-weight: 600; font-size: 11px; }
.cmdk-item.sel { background: linear-gradient(90deg, rgba(127,163,184,.18), rgba(181,196,158,.08)); }
.cmdk-empty { padding: 18px 14px; color: var(--dim); font-size: 13px; }

/* ------------------------------------------------------------ hour grid (floor) */
.hourgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.hourcell {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px;
  background: var(--bg-deep); cursor: pointer; text-align: left; color: var(--ink);
  font-family: inherit; transition: border-color .12s ease;
}
.hourcell:hover { border-color: var(--accent); }
.hourcell .t { font-size: 11px; color: var(--dim); font-weight: 700; }
.hourcell .g { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hourcell .s { font-size: 11px; color: var(--dim); }
.hourcell.blank { border-style: dashed; opacity: .75; }
.hourcell.down { border-color: rgba(245,166,35,.5); }
.hourcell.low { border-color: rgba(240,82,79,.45); }

/* ------------------------------------------------------------ mobile */
@media (max-width: 900px) {
  .hamburger { display: block; }
  aside {
    position: fixed; left: 0; top: 56px; z-index: 25; transform: translateX(-100%);
    transition: transform .16s ease; box-shadow: var(--shadow-pop);
  }
  body.navopen aside { transform: none; }
  main { padding: 16px; }
  .kbd-hint { display: none; }
}

/* ------------------------------------------------------------ print */
@media print {
  aside, header, footer, .actions, .btn { display: none !important; }
  body, .card { background: #fff; color: #111; }
  .card { border-color: #ccc; box-shadow: none; }
}
