/* LotThread dashboard - application UI.
   Shares the marketing palette so the app and the landing page read as one product. */

:root {
  --bg: #F7F8F5;
  --panel: #ffffff;
  --ink: #111814;
  --muted: #55605A;
  --faint: #8b958f;
  --border: #DDE3DF;
  --border-soft: #E7EBE7;
  --green: #50C878;
  --mint: #77E6A1;
  --deep: #123C2B;
  --deep-2: #0f1a14;
  --amber: #E5A83B;
  --amber-ink: #835507;      /* WCAG-AA text on white/amber tint */
  --red: #CE5B45;
  --red-ink: #a8402c;
  --green-ink: #166b41;      /* WCAG-AA text on white/green tint */
  --slate: #5A7183;
  --slate-ink: #48596a;      /* WCAG-AA text on white/slate tint */
  --font: 'Geist', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 14px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::selection { background: #77E6A1; color: #111814; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--deep-2);
  color: rgba(234, 243, 237, .72);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; }
.sidebar__brand span { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sidebar__org { display: flex; align-items: center; gap: 8px; margin: 0 6px 10px; padding: 8px 11px;
  border-radius: 9px; background: rgba(255,255,255,.05); color: rgba(234,243,237,.85);
  font-size: 12.5px; font-weight: 600; border: 1px solid rgba(255,255,255,.08); }
.sidebar__org:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar__org-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); flex-shrink: 0; }
.sidebar__section {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(234, 243, 237, .38); padding: 14px 11px 6px;
}
.sidebar__nav {
  display:flex; flex:1 1 auto; flex-direction:column; min-height:0;
  overflow-y:auto; overflow-x:hidden; padding-right:3px;
  scrollbar-width:thin; scrollbar-color:rgba(119,230,161,.3) transparent;
  overscroll-behavior:contain;
}
.sidebar__nav::-webkit-scrollbar { width:5px; }
.sidebar__nav::-webkit-scrollbar-thumb { background:rgba(119,230,161,.3); border-radius:10px; }
.sidebar__group--settings { margin-top:10px; padding-top:7px; border-top:1px solid rgba(255,255,255,.09); }
.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; color: rgba(234, 243, 237, .72);
  transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.navlink .dot { width: 6px; height: 6px; border-radius: 2px; background: rgba(234, 243, 237, .3); flex-shrink: 0; }
.navlink.is-active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 600; }
.navlink.is-active .dot { background: var(--mint); }
.navlink.is-cta { background: var(--green); color: #0a2016; font-weight: 700; margin-top: 4px; }
.navlink.is-cta .dot { background: #0a2016; }
.navlink.is-cta:hover { background: #5fd487; color: #0a2016; }
.navlink__badge {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  background: rgba(229, 168, 59, .22); color: #F0C070; border-radius: 100px; padding: 1px 8px;
}
.sidebar__foot {
  flex:0 0 auto; margin-top:8px; padding:11px 11px 4px;
  border-top:1px solid rgba(255,255,255,.08);
  font-size:11.5px; color:rgba(234,243,237,.4);
}

/* ---------- Main / topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: rgba(247, 248, 245, .85);
  backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.search {
  flex: 1; max-width: 560px; position: relative;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 11px; padding: 10px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search:focus-within { border-color: var(--deep); box-shadow: 0 8px 22px -14px rgba(18, 60, 43, .5); }
.search input { border: none; outline: none; background: transparent; flex: 1; font-family: var(--font); font-size: 14px; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; }
.search__results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 22px 44px -22px rgba(17, 24, 20, .4); overflow: hidden; z-index: 40; display: none;
}
.search__results.is-open { display: block; }
.search__result { display: flex; align-items: center; gap: 11px; padding: 11px 15px; cursor: pointer; border-top: 1px solid var(--border-soft); }
.search__result:first-child { border-top: none; }
.search__result:hover, .search__result.is-hi { background: rgba(119, 230, 161, .1); }
.search__result .code { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--deep); }
.search__result .kind { margin-left: auto; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.search__empty { padding: 14px 15px; font-size: 13px; color: var(--muted); }
.topbar__user { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--deep); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }

.content { padding: 30px clamp(22px,3vw,40px) 48px; max-width: 1440px; width: 100%; margin: 0 auto; }
.breadcrumb { display:flex; align-items:center; gap:7px; margin:-9px 0 15px; color:var(--muted); font:500 10.5px var(--mono); letter-spacing:.03em; }
.breadcrumb a:hover { color:var(--deep); text-decoration:underline; text-underline-offset:3px; }
.breadcrumb span[aria-current="page"] { color:var(--deep); font-weight:600; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--green-ink); font-weight: 600; }
.page-head h1 { margin: 8px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; max-width: 60ch; }
.breadcrumb { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a:hover { color: var(--green-ink); }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px -26px rgba(15,51,36,.45); }
.card__pad { padding: 20px; }
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* stat tiles */
.stat { position:relative; overflow:hidden; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 18px; box-shadow:0 8px 24px -24px rgba(15,51,36,.5); }
.stat::after { content:""; position:absolute; inset:auto -20px -34px auto; width:76px; height:76px; border-radius:50%; background:var(--green); opacity:.07; }
.stat__label { font-size: 12.5px; color: var(--muted); }
.stat__value { font-family: var(--mono); font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat--amber .stat__value { color: var(--amber-ink); }
.stat--red .stat__value { color: var(--red-ink); }
.stat--green .stat__value { color: var(--green-ink); }

/* readiness hero tile (dark) */
.readiness { background: var(--deep); color: #EAF3ED; border-radius: var(--radius); padding: 22px; }
.readiness__label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: rgba(234, 243, 237, .72); }
.readiness__value { font-size: 48px; font-weight: 700; letter-spacing: -.03em; color: #fff; line-height: 1; margin-top: 8px; }
.readiness__value sup { font-size: 22px; color: var(--mint); font-weight: 700; }
.bar { height: 7px; border-radius: 5px; background: rgba(255, 255, 255, .14); overflow: hidden; margin-top: 14px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--mint)); border-radius: 5px; }
.readiness__notes { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: rgba(234, 243, 237, .72); }

/* light progress bar */
.bar-light { height: 8px; border-radius: 6px; background: #EDF0EC; overflow: hidden; }
.bar-light > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--mint)); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  border-radius: 100px; padding: 3px 10px; white-space: nowrap;
}
.badge .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--green-ink); background: rgba(80, 200, 120, .14); }
.badge--amber { color: var(--amber-ink); background: rgba(229, 168, 59, .16); }
.badge--red { color: var(--red-ink); background: rgba(206, 91, 69, .14); }
.badge--deep { color: var(--deep); background: rgba(119, 230, 161, .2); }
.badge--slate { color: var(--slate-ink); background: rgba(90, 113, 131, .12); }

.mono { font-family: var(--mono); }
.code-link { font-family: var(--mono); font-weight: 600; color: var(--deep); }
.code-link:hover { color: var(--green-ink); text-decoration: underline; }
.muted { color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: #fff; scrollbar-width:thin; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 11px 16px; background: #F7F8F5; border-bottom: 1px solid var(--border);
}
.navlink__text { min-width:0; flex:1; }
.navlink__chevron { margin-left:auto; color:rgba(234,243,237,.46); font-size:18px; line-height:1; transform:rotate(90deg); }
.navsub { margin:2px 0 4px 17px; padding-left:12px; border-left:1px solid rgba(119,230,161,.22); }
.navsub__link { display:block; padding:6px 10px; border-radius:7px; color:rgba(234,243,237,.58); font-size:12.5px; }
.navsub__link:hover { color:#fff; background:rgba(255,255,255,.05); }
.navsub__link.is-active { color:var(--mint); font-weight:600; }
.tbl thead { position:sticky; top:0; z-index:2; }
.tbl tbody td { padding: 12px 16px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tbody tr:hover { background: rgba(119, 230, 161, .06); }
.tbl tbody tr[data-href] { cursor: pointer; }
.table-scroll { width:100%; overflow-x:auto; overscroll-behavior-inline:contain; scrollbar-width:thin; }
.table-scroll > .tbl { min-width:680px; }
.tbl td.num { font-family: var(--mono); }

/* mini chain (genealogy strip) */
.chain { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 4px 0; }
.chip { font-family: var(--mono); font-size: 11px; font-weight: 600; border-radius: 8px; padding: 7px 10px; white-space: nowrap; }
.chip--mat { color: var(--deep); background: #fff; border: 1px solid var(--border); }
.chip--batch { color: #fff; background: var(--deep); }
.chip--finished { color: var(--green-ink); background: rgba(80, 200, 120, .16); border: 1px solid rgba(80, 200, 120, .4); }
.chip--ship { color: var(--slate-ink); background: rgba(90, 113, 131, .1); border: 1px solid rgba(90, 113, 131, .25); }
.chain .arrow { color: var(--green-ink); flex-shrink: 0; }

/* key-value grid */
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.kv > div { background: #fff; padding: 13px 15px; }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-size: 14px; font-weight: 600; margin-top: 3px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--ink); cursor: pointer; transition: all .15s ease; }
.btn:hover { border-color: var(--deep); }
.btn--primary { background: var(--deep); color: #fff; border-color: var(--deep); }
.btn--primary:hover { background: #0c2c1f; }
.btn--green { background: var(--green); color: #0a2016; border-color: var(--green); }
.btn--green:hover { background: #5fd487; }
.btn:disabled, .btn[aria-disabled="true"] { cursor:not-allowed; opacity:.52; box-shadow:none; }

/* segmented control */
.seg { display: inline-flex; gap: 4px; background: #F2F4F0; border: 1px solid var(--border); border-radius: 11px; padding: 4px; }
.seg a, .seg button { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--muted); background: transparent; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.seg a.is-active, .seg button.is-active { background: #fff; color: var(--deep); box-shadow: 0 1px 3px rgba(17, 24, 20, .12); }

/* empty */
.empty { padding: 44px 24px; text-align: center; color: var(--muted); font-size: 14px; background:linear-gradient(180deg,#fff,#fafcf9); }

/* list rows (queue / activity) */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row-item { display: flex; align-items: center; gap: 11px; font-size: 13px; }
.row-item .n { width: 20px; height: 20px; border-radius: 6px; background: rgba(119, 230, 161, .2); border: 1px solid rgba(80, 200, 120, .35); font-family: var(--mono); font-size: 10.5px; color: var(--deep); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.row-item .ev-dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); flex-shrink: 0; }

/* ---------- Genealogy graph (trace page) ---------- */
.gene { position: relative; border: 1px solid var(--border); border-radius: 18px; overflow-x: auto; overflow-y: hidden; }
.gene__track { position: relative; min-width: 680px; padding: 30px 24px; background: linear-gradient(180deg, #FbFcFa, #F7F8F5); }
.gene__grid-bg { position: absolute; inset: 0; background-image: linear-gradient(rgba(17,24,20,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(17,24,20,.03) 1px, transparent 1px); background-size: 32px 32px; pointer-events: none; }
.gene svg.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gene__cols { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px; align-items: start; }
.gene__col-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; text-align: center; margin-bottom: 14px; }
.gene__node { display: block; width: 100%; text-align: left; cursor: pointer; background: #fff; border: 1.5px solid var(--border); border-radius: 11px; padding: 11px 13px; box-shadow: 0 1px 2px rgba(17,24,20,.05); transition: all .25s ease; margin-bottom: 12px; }
.gene__node .code { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--deep); }
.gene__node .name { font-size: 13px; color: var(--ink); margin-top: 2px; }

/* ---------- Accessibility ---------- */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; background: var(--deep); color: #fff; font-weight: 600; font-size: 13.5px; padding: 10px 16px; border-radius: 0 0 10px 0; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
tr[data-href]:focus-visible { outline-offset: -2px; }

/* flash messages: dismiss + button loading state */
.msg { position: relative; padding-right: 38px; }
.msg__close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: none; color: inherit; font-size: 17px; line-height: 1; cursor: pointer; opacity: .55; padding: 4px 7px; border-radius: 6px; }
.msg__close:hover { opacity: 1; }
.btn.is-loading { opacity: .6; pointer-events: none; position: relative; }
.btn.is-loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: btnspin .7s linear infinite; }
@keyframes btnspin { to { transform: rotate(360deg); } }

/* sortable column headers */
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover, .th-sort.is-sorted { color: var(--deep); }

/* mobile nav toggle (hidden on desktop) */
.nav-toggle { display: none; border: 1px solid var(--border); background: #fff; color: var(--deep); border-radius: 10px; padding: 9px 11px; cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  [data-detail-grid] { grid-template-columns:1fr !important; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  /* Sidebar becomes an off-canvas drawer opened by the topbar toggle. */
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 120;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 24px 0 60px -30px rgba(0,0,0,.55); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open { overflow:hidden; }
  body.nav-open::after { content:""; position:fixed; inset:0; z-index:110; background:rgba(8,22,14,.42); backdrop-filter:blur(2px); }
  .grid-2 { grid-template-columns: 1fr; }
  [data-overview-grid] { grid-template-columns:1fr !important; }
  .topbar { padding:12px 16px; gap:10px; flex-wrap:wrap; }
  .search { order:4; flex-basis:100%; max-width:none; }
  .newmenu { margin-left:0; }
  .topbar > .newmenu:first-of-type { margin-left:auto; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .kv { grid-template-columns: 1fr 1fr; }
  .page-head { align-items:flex-start; }
  .page-head > .btn, .page-head > a.btn { width:100%; justify-content:center; }
  .table-wrap .tbl, .table-scroll .tbl { min-width:660px; }
  .newmenu__panel { position:fixed; left:12px; right:12px; top:72px; min-width:0; max-height:calc(100vh - 90px); overflow-y:auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .sidebar { transition: none; }
  .btn.is-loading::after { animation: none; }
}
