/* optic360.css — All Component Classes
   Load after reset.css and tokens.css
*/

/* ══════════════════════════════════════════════
   SHELL LAYOUT
══════════════════════════════════════════════ */

.shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-page);
  font-size: var(--fs-sm);
  color: var(--tp);
}

/* Horizontal layout mode */
.shell.layout-horizontal {
  flex-direction: column;
}

/* ══════════════════════════════════════════════
   SIDEBAR — VERTICAL NAV
══════════════════════════════════════════════ */

.sidebar {
  width: var(--w-sidebar);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: var(--border-width) solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal);
  overflow: hidden;
}

.sidebar.col { width: var(--w-sidebar-col); }

.sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-bottom: var(--border-width) solid var(--border);
  height: var(--h-topbar);
  flex-shrink: 0;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
}

.sb-logo-icon {
  width: var(--av-md);
  height: var(--av-md);
  background: var(--ac);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-logo-icon i { font-size: 12px; color: #fff; }

.sb-logo-text {
  font-size: var(--fs-title);
  font-weight: var(--fw-medium);
  color: var(--tp);
}

.sb-logo-text s { color: var(--ac); text-decoration: none; }

/* Collapse button */
.cbtn {
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ts);
  flex-shrink: 0;
  border: var(--border-width) solid var(--border);
}

.cbtn i {
  font-size: var(--icon-sm);
  transition: transform var(--transition-normal);
}

/* Collapsed state — hide text, center icons */
.sidebar.col .sb-logo-text,
.sidebar.col .sb-sec,
.sidebar.col .mod-txt,
.sidebar.col .mod-arrow,
.sidebar.col .sub-item span,
.sidebar.col .user-info,
.sidebar.col .cbtn { display: none; }

.sidebar.col .sb-top,
.sidebar.col .mod-item,
.sidebar.col .sub-item,
.sidebar.col .user-row { justify-content: center; padding: 0; }

.sidebar.col .sub-tree { display: none; }
.sidebar.col .mod-item { height: 36px; }
.sidebar.col .sub-item { height: 34px; }

/* Nav sections */
.sb-nav {
  flex: 1;
  padding: 8px 6px;
  overflow-y: auto;
}

.sb-sec {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 0 6px;
  margin: 10px 0 3px;
  white-space: nowrap;
}

/* Module items (parent level) */
.mod-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--ts);
  cursor: pointer;
  margin-bottom: 1px;
  height: 30px;
  transition: background var(--transition-fast),
              color var(--transition-fast);
}

.mod-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mod-left i {
  font-size: var(--icon-md);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.mod-arrow { font-size: var(--icon-sm); }

.mod-item.on { color: var(--ac); font-weight: var(--fw-medium); }

.mod-item:hover {
  background: var(--acl);
  color: var(--ac);
}

/* Sub item tree */
.sub-tree {
  padding-left: 10px;
  margin-bottom: 2px;
  border-left: 1.5px solid var(--acl);
  margin-left: 15px;
}

/* Sub items (child level) */
.sub-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--ts);
  cursor: pointer;
  margin-bottom: 1px;
  height: 28px;
  white-space: nowrap;
  transition: background var(--transition-fast),
              color var(--transition-fast);
}

.sub-item i { font-size: 12px; flex-shrink: 0; }

.sub-item:hover,
.sub-item.on { background: var(--acl); color: var(--ac); }

.sub-item.on { font-weight: var(--fw-medium); }

/* User row */
.sb-bot {
  border-top: var(--border-width) solid var(--border);
  padding: 8px 6px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  height: 32px;
}

.user-row:hover { background: var(--acl); }

.user-name { font-size: 12px; font-weight: var(--fw-medium); color: var(--tp); }
.user-role { font-size: 10px; color: var(--ts); }

.sidebar.col .user-row { justify-content: center; padding: 0; }
.sidebar.col .user-info { display: none; }

/* ══════════════════════════════════════════════
   AVATAR
══════════════════════════════════════════════ */

.av {
  border-radius: 50%;
  background: var(--ac);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: var(--fw-medium);
  color: #fff;
  flex-shrink: 0;
  width: var(--av-md);
  height: var(--av-md);
}

.av-sq {
  border-radius: var(--r-sm);
}

/* ══════════════════════════════════════════════
   MAIN CONTENT AREA
══════════════════════════════════════════════ */

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

/* ══════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════ */

.topbar {
  background: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-page);
  height: var(--h-topbar);
  flex-shrink: 0;
}

.tb-left { display: flex; align-items: center; gap: 5px; }

.bc { font-size: var(--fs-sm); color: var(--ts); cursor: pointer; }
.bc:hover { color: var(--ac); }
.bcsep { font-size: var(--fs-sm); color: var(--ts); }
.bccur { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--tp); }

.tb-docid { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--tp); }
.tb-sep { font-size: var(--fs-sm); color: var(--tt); }
.tb-date { font-size: var(--fs-sm); color: var(--ts); }

.tb-right { display: flex; align-items: center; gap: 5px; }

.ibtn {
  width: var(--h-btn-p);
  height: var(--h-btn-p);
  border-radius: var(--r-md);
  border: var(--border-width) solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ts);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ibtn i { font-size: var(--icon-md); }
.ibtn:hover { background: var(--acl); color: var(--ac); }
.ibtn.on { background: var(--acl); color: var(--ac); }

/* ══════════════════════════════════════════════
   BUTTONS — use div not native button
══════════════════════════════════════════════ */

/* Secondary button */
.db {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  height: var(--h-btn);
  border: var(--border-width) solid var(--border);
  border-radius: var(--r-md);
  font-size: 10px;
  color: var(--ts);
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
  line-height: 1;
  transition: background var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast);
}

.db i { font-size: 10px; }
.db:hover { background: var(--acl); color: var(--ac); border-color: var(--ac); }

/* Primary button */
.db-p {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 10px;
  height: var(--h-btn-p);
  background: var(--ac);
  color: #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition: opacity var(--transition-fast);
}

.db-p i { font-size: var(--fs-sm); }
.db-p:hover { opacity: .85; }

/* Success button */
.db-up {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 10px;
  height: var(--h-btn-p);
  background: var(--up);
  color: #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}

.db-up i { font-size: var(--fs-sm); }
.db-up:hover { opacity: .85; }

/* Danger button */
.db-dn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 10px;
  height: var(--h-btn-p);
  background: var(--dn);
  color: #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}

.db-dn:hover { opacity: .85; }

/* Module header button (slightly taller) */
.db-h {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 10px;
  height: var(--h-btn-h);
  background: var(--ac);
  color: #fff;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
}

/* More / kebab button */
.more {
  width: var(--h-btn);
  height: var(--h-btn);
  border-radius: var(--r-md);
  border: var(--border-width) solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ts);
}

.more i { font-size: var(--icon-md); }
.more:hover { background: var(--acl); color: var(--ac); }

/* Row action button */
.ra {
  width: 20px;
  height: 20px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ts);
}

.ra i { font-size: var(--icon-sm); }
.ra:hover { color: var(--ac); background: var(--bg-surface); }

/* ══════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════ */

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  white-space: nowrap;
}

/* Status badges — documents */
.b-draft        { background: var(--th); color: var(--ts); }
.b-open         { background: var(--acl); color: var(--ac); }
.b-confirmed    { background: var(--bll); color: var(--bl); }
.b-partial      { background: var(--aml); color: var(--am); }
.b-delivered    { background: var(--upl); color: var(--up); }
.b-invoiced     { background: var(--upl); color: var(--up); }
.b-posted       { background: var(--bll); color: var(--bl); }
.b-paid         { background: var(--upl); color: var(--up); }
.b-overdue      { background: var(--dnl); color: var(--dn); }
.b-cancelled    { background: var(--dnl); color: var(--dn); }
.b-shipped      { background: var(--upl); color: var(--up); }
.b-picking      { background: var(--aml); color: var(--am); }
.b-won          { background: var(--upl); color: var(--up); }
.b-lost         { background: var(--dnl); color: var(--dn); }
.b-active       { background: var(--upl); color: var(--up); }
.b-inactive     { background: var(--dnl); color: var(--dn); }

/* GL category badges */
.b-asset        { background: var(--acl); color: var(--ac); }
.b-liability    { background: var(--aml); color: var(--am); }
.b-equity       { background: var(--bll); color: var(--bl); }
.b-revenue      { background: var(--upl); color: var(--up); }
.b-expense      { background: var(--dnl); color: var(--dn); }

/* CRM stage badges */
.b-lead         { background: var(--th); color: var(--ts); }
.b-qualified    { background: var(--bll); color: var(--bl); }
.b-proposal     { background: var(--aml); color: var(--am); }
.b-negotiation  { background: var(--acl); color: var(--ac); }

/* Activity type badges */
.b-call         { background: var(--bll); color: var(--bl); }
.b-email        { background: var(--acl); color: var(--ac); }
.b-meeting      { background: var(--upl); color: var(--up); }
.b-task         { background: var(--aml); color: var(--am); }
.b-note         { background: var(--th); color: var(--ts); }

/* Contact role badges */
.b-primary      { background: var(--acl); color: var(--ac); }
.b-finance      { background: var(--upl); color: var(--up); }
.b-ops          { background: var(--bll); color: var(--bl); }

/* ══════════════════════════════════════════════
   MODULE HEADER
══════════════════════════════════════════════ */

.mod-header {
  background: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border);
  padding: 10px var(--space-page);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.mh-left { display: flex; align-items: center; gap: 9px; }

.mh-icon {
  width: 28px;
  height: 28px;
  background: var(--acl);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mh-icon i { font-size: var(--icon-lg); color: var(--ac); }

.mh-title { font-size: var(--fs-h1); font-weight: var(--fw-medium); color: var(--tp); }
.mh-sub { font-size: 10px; color: var(--ts); margin-top: 2px; }

.mh-right { display: flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════════════
   STATUS TABS
══════════════════════════════════════════════ */

.status-tabs {
  display: flex;
  padding: 0 var(--space-page);
  border-bottom: var(--border-width) solid var(--border);
  background: var(--bg-surface);
  height: var(--h-statustab);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.status-tabs::-webkit-scrollbar { display: none; }

.stab {
  font-size: var(--fs-sm);
  padding: 0 12px;
  display: flex;
  align-items: center;
  color: var(--ts);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  gap: 5px;
  transition: color var(--transition-fast);
}

.stab:hover { color: var(--tp); }

.stab.on {
  color: var(--ac);
  border-bottom-color: var(--ac);
  font-weight: var(--fw-medium);
}

.stab-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--th);
  color: var(--ts);
  font-weight: var(--fw-medium);
}

.stab.on .stab-count { background: var(--acl); color: var(--ac); }

/* ══════════════════════════════════════════════
   TOOLBAR
══════════════════════════════════════════════ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 var(--space-page);
  height: var(--h-toolbar);
  border-bottom: var(--border-width) solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 5px;
  border: var(--border-width) solid var(--border);
  border-radius: var(--r-md);
  padding: 0 8px;
  height: var(--h-input);
  width: var(--w-search);
  background: var(--bg-page);
}

.search-box:focus-within { border-color: var(--ac); }

.search-box i { font-size: var(--icon-sm); color: var(--ts); flex-shrink: 0; }

.search-input {
  font-size: var(--fs-sm);
  color: var(--tp);
  flex: 1;
  background: transparent;
}

.search-input::placeholder { color: var(--ts); }

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  height: var(--h-input);
  border: var(--border-width) solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--ts);
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tb-btn i { font-size: var(--icon-sm); }
.tb-btn:hover { background: var(--acl); color: var(--ac); border-color: var(--ac); }
.tb-btn.active { background: var(--acl); color: var(--ac); border-color: var(--ac); }

.rc { font-size: var(--fs-sm); color: var(--ts); margin-left: auto; }

/* ══════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════ */

.pag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-page);
  height: var(--h-pagination);
  background: var(--bg-surface);
  border-bottom: var(--border-width) solid var(--border);
  flex-shrink: 0;
}

.pag-bot { border-bottom: none; border-top: var(--border-width) solid var(--border); }

.pag-left { display: flex; align-items: center; gap: 6px; }
.pag-lbl { font-size: var(--fs-sm); color: var(--ts); }
.pag-info { font-size: var(--fs-sm); color: var(--ts); }
.pag-nums { display: flex; gap: 3px; }

.pgb {
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  cursor: pointer;
  border: var(--border-width) solid var(--border);
  color: var(--ts);
  background: transparent;
}

.pgb.on { background: var(--ac); color: #fff; border-color: var(--ac); }
.pgb:hover:not(.on):not(.dots) { background: var(--acl); color: var(--ac); }
.pgb.dots { border: none; cursor: default; }
.pgb i { font-size: var(--icon-sm); }

/* ══════════════════════════════════════════════
   TABLE
══════════════════════════════════════════════ */

.list-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.list-table thead tr { background: var(--th); }

.list-table thead th {
  padding: 0 12px;
  height: var(--h-thead);
  text-align: left;
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: var(--border-width) solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.list-table thead th.r { text-align: right; }
.list-table thead th.sorted { color: var(--ac); }

.sort-icon { font-size: 10px; margin-left: 3px; opacity: .5; }
.sorted .sort-icon { opacity: 1; }

.list-table tbody tr {
  border-bottom: var(--border-width) solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.list-table tbody tr:hover { background: var(--acl); }
.list-table tbody tr:last-child { border-bottom: none; }

.list-table tbody td {
  padding: 0 12px;
  height: var(--h-row);
  font-size: var(--fs-sm);
  color: var(--tp);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.list-table tbody td.sec { color: var(--ts); }
.list-table tbody td.r { text-align: right; }

/* Row actions — hidden until hover */
.row-actions { display: flex; gap: 3px; opacity: 0; }
.list-table tbody tr:hover .row-actions { opacity: 1; }

/* Cell types */
.cell-name { font-size: 12px; font-weight: var(--fw-medium); color: var(--tp); line-height: 1; }
.cell-sub { font-size: 10px; color: var(--ts); margin-top: 2px; }
.cell-link { color: var(--ac); cursor: pointer; }

/* Checkbox */
.row-cb { width: 13px; height: 13px; accent-color: var(--ac); cursor: pointer; }

/* ══════════════════════════════════════════════
   DOCUMENT TABS
══════════════════════════════════════════════ */

.tabs {
  display: flex;
  padding: 0 var(--space-page);
  border-bottom: var(--border-width) solid var(--border);
  background: var(--bg-surface);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  font-size: var(--fs-sm);
  padding: 9px 10px;
  color: var(--ts);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.tab:hover { color: var(--tp); }

.tab.on {
  color: var(--ac);
  border-bottom-color: var(--ac);
  font-weight: var(--fw-medium);
}

.tc {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--acl);
  color: var(--ac);
  margin-left: 4px;
}

/* ══════════════════════════════════════════════
   DOCUMENT HEADER
══════════════════════════════════════════════ */

.doc-header {
  padding: 10px var(--space-page) 11px;
  border-bottom: var(--border-width) solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.doc-title { font-size: var(--fs-title); font-weight: var(--fw-medium); color: var(--tp); }
.doc-value { font-size: var(--fs-value); font-weight: var(--fw-medium); color: var(--tp); }
.doc-value-label { font-size: 9px; color: var(--ts); text-transform: uppercase; letter-spacing: .05em; }

.meta-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; flex: 1; }

.mi { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--ts); white-space: nowrap; }
.mi i { font-size: 10px; }
.mi.link { color: var(--ac); cursor: pointer; }
.mi.up { color: var(--up); }
.mi.dn { color: var(--dn); }
.mi.am { color: var(--am); }

.md { font-size: 9px; color: var(--tt); }

.btn-row { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ══════════════════════════════════════════════
   CREDIT BANNER
══════════════════════════════════════════════ */

.credit-banner {
  padding: 6px var(--space-page);
  border-bottom: var(--border-width) solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-sm);
}

.credit-banner.green { background: var(--upl); color: var(--up); }
.credit-banner.amber { background: var(--aml); color: var(--am); }
.credit-banner.red   { background: var(--dnl); color: var(--dn); }

.credit-bar-wrap { width: 120px; height: 4px; background: rgba(0,0,0,.1); border-radius: 2px; overflow: hidden; }
.credit-bar { height: 100%; border-radius: 2px; background: currentColor; }

/* ══════════════════════════════════════════════
   DOCUMENT TRAIL
══════════════════════════════════════════════ */

.doc-trail {
  border-bottom: var(--border-width) solid var(--border);
  padding: 6px var(--space-page);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.doc-trail::-webkit-scrollbar { display: none; }

.trl {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 8px;
  flex-shrink: 0;
}

.tn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  border: var(--border-width) solid var(--border);
  background: var(--bg-page);
  color: var(--ts);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.tn i { font-size: var(--icon-sm); }
.tn.cur { background: var(--acl); border-color: var(--ac); color: var(--ac); font-weight: var(--fw-medium); }
.tn.done { background: var(--upl); border-color: var(--up); color: var(--up); }
.tn.pend { opacity: .4; cursor: default; }

.ta { font-size: var(--icon-sm); color: var(--ts); flex-shrink: 0; }

/* ══════════════════════════════════════════════
   DETAIL BODY
══════════════════════════════════════════════ */

/* CRITICAL: Natural height — NEVER use flex:1 or min-height */
.detail-content {
  padding: var(--space-section) var(--space-page);
}

/* Two-column detail layout */
.detail-body {
  display: grid;
  grid-template-columns: 1fr var(--w-detail-side);
  background: var(--bg-surface);
}

.detail-main {
  padding: var(--space-section) var(--space-page);
  border-right: var(--border-width) solid var(--border);
}

.detail-side { padding: 12px 14px; }

/* ══════════════════════════════════════════════
   FIELD GRID (Details tabs)
══════════════════════════════════════════════ */

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-field); }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-field); }
.field { display: flex; flex-direction: column; gap: 3px; }
.field.full { grid-column: 1 / -1; }

/* LOCKED — field value rules */
.fl {
  font-size: 10px;
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: var(--fw-medium);
  line-height: 1;
}

/* Plain value — always black */
.fv {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--tp);
  line-height: 1.2;
}

/* Link value — always purple */
.fv.link { color: var(--ac); cursor: pointer; }
.fv.link:hover { text-decoration: underline; }

/* Due date — colour by status ONLY */
.fv.due-ok   { color: var(--up); }
.fv.due-warn { color: var(--am); }
.fv.due-dn   { color: var(--dn); }

/* All other dates → var(--tp) black — never colour coded */

/* Section within detail */
.section { margin-bottom: 14px; }

.sec-title {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: var(--border-width) solid var(--border);
}

/* ══════════════════════════════════════════════
   FOOTER (Document detail screens)
══════════════════════════════════════════════ */

.doc-footer {
  border-top: var(--border-width) solid var(--border);
  background: var(--bg-page);
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex-shrink: 0;
}

.fc {
  padding: 10px var(--space-page);
}

.fc:first-child { border-right: var(--border-width) solid var(--border); }

.ft {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
}

/* CRITICAL — footer rows: fixed label width, never stretch */
.footer-row {
  display: grid;
  grid-template-columns: var(--w-footer-lbl) 1fr;
  padding: 3px 0;
  border-bottom: var(--border-width) solid var(--border);
  font-size: var(--fs-sm);
}

.footer-row:last-child { border-bottom: none; }
.footer-lbl { color: var(--ts); }
.footer-val { font-weight: var(--fw-medium); color: var(--tp); }

/* Footer action links */
.al {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: var(--fs-sm);
  color: var(--ts);
  cursor: pointer;
  border-bottom: var(--border-width) solid var(--border);
  transition: color var(--transition-fast);
}

.al:last-child { border-bottom: none; }
.al:hover { color: var(--ac); }
.al i { font-size: 12px; flex-shrink: 0; }
.al.danger { color: var(--dn); }
.al.danger:hover { opacity: .7; }

/* ══════════════════════════════════════════════
   LINE ITEMS TABLE (Quotation, SO, Invoice)
══════════════════════════════════════════════ */

.line-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.line-table thead tr { background: var(--th); }

.line-table thead th {
  padding: 0 8px;
  height: var(--h-thead);
  text-align: left;
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: var(--border-width) solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}

.line-table thead th.r { text-align: right; }

.line-table tbody tr { border-bottom: var(--border-width) solid var(--border); }
.line-table tbody tr:last-child { border-bottom: none; }

.line-table tbody td {
  padding: 7px 8px;
  font-size: var(--fs-sm);
  color: var(--tp);
  vertical-align: top;
}

.line-table tbody td.r { text-align: right; padding-top: 9px; }

/* Standard column widths — item column is auto (flexible) */
.col-item  { width: auto; }   /* ALWAYS flexible */
.col-num   { width: 30px; }
.col-qty   { width: 54px; }
.col-price { width: 80px; }
.col-disc  { width: 54px; }
.col-total { width: 80px; }
.col-vat   { width: 54px; }
.col-vatamt{ width: 72px; }
.col-status{ width: 80px; }
.col-proc  { width: 90px; }

/* Item cell within line table */
.item-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--tp); line-height: 1; }
.item-sku  { font-size: 10px; color: var(--ts); margin-top: 2px; }
.item-gl   { font-size: 10px; color: var(--ac); margin-top: 2px; }
.item-fit  { font-size: 10px; color: var(--ts); margin-top: 2px; }

/* ══════════════════════════════════════════════
   TOTALS BLOCK
══════════════════════════════════════════════ */

.totals {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: var(--border-width) solid var(--border);
}

.totals-inner { width: var(--w-totals); }

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--fs-sm);
}

.total-row.grand {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  border-top: var(--border-width) solid var(--border);
  margin-top: 5px;
  padding-top: 7px;
}

.total-lbl { color: var(--ts); }
.total-val { color: var(--tp); font-weight: var(--fw-medium); }

/* ══════════════════════════════════════════════
   SIDEBAR PANEL (Detail right rail)
══════════════════════════════════════════════ */

.side-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: var(--border-width) solid var(--border);
}

.side-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.side-title {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
}

.side-row { padding: 3px 0; }
.side-lbl { font-size: 10px; color: var(--ts); }
.side-val { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--tp); }

.qa-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: var(--fs-sm);
  color: var(--ts);
  cursor: pointer;
  border-bottom: var(--border-width) solid var(--border);
  transition: color var(--transition-fast);
}

.qa-link:last-child { border-bottom: none; }
.qa-link:hover { color: var(--ac); }
.qa-link i { font-size: 12px; flex-shrink: 0; }

/* ══════════════════════════════════════════════
   CUSTOM FIELDS
══════════════════════════════════════════════ */

.custom-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--border);
}

.cf-title {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.add-custom {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-sm);
  color: var(--ac);
  cursor: pointer;
  padding: 5px 10px;
  border: var(--border-width) dashed var(--ac);
  border-radius: var(--r-lg);
  background: var(--acl);
}

.add-custom i { font-size: 12px; }

/* ══════════════════════════════════════════════
   TOGGLE SWITCH
══════════════════════════════════════════════ */

.toggle {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-normal);
  display: inline-block;
  vertical-align: middle;
}

.toggle.on { background: var(--ac); }

.toggle::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--transition-normal);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle.on::after { left: 14px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: var(--border-width) solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }
.toggle-info { flex: 1; padding-right: 12px; }
.toggle-lbl { font-size: 12px; color: var(--tp); }
.toggle-sub { font-size: 10px; color: var(--ts); margin-top: 2px; }

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-bg.show { display: flex; }

.modal {
  background: var(--bg-surface);
  border-radius: var(--r-xxl);
  padding: 16px;
  min-width: 300px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: var(--fs-title);
  font-weight: var(--fw-medium);
  color: var(--tp);
  margin-bottom: 4px;
}

.modal-sub {
  font-size: var(--fs-sm);
  color: var(--ts);
  margin-bottom: 12px;
}

.modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 12px;
}

/* ══════════════════════════════════════════════
   LOCATION BADGE (warehouse locations)
══════════════════════════════════════════════ */

.loc-badge {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--acl);
  color: var(--ac);
  font-weight: var(--fw-medium);
  font-family: 'JetBrains Mono', monospace;
}

/* ══════════════════════════════════════════════
   GL PREVIEW BLOCK
══════════════════════════════════════════════ */

.gl-preview {
  background: var(--th);
  border: var(--border-width) solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  margin-top: 12px;
}

.gl-preview-title {
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--ts);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gl-preview-title i { font-size: var(--icon-sm); color: var(--ac); }

.gl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--fs-sm);
  border-bottom: var(--border-width) solid var(--border);
}

.gl-row:last-child { border-bottom: none; }
.gl-acc { color: var(--ac); font-weight: var(--fw-medium); width: 40px; flex-shrink: 0; }
.gl-desc { color: var(--ts); flex: 1; margin: 0 10px; }
.gl-dr { color: var(--dn); font-weight: var(--fw-medium); width: 80px; text-align: right; }
.gl-cr { color: var(--up); font-weight: var(--fw-medium); width: 80px; text-align: right; }

/* ══════════════════════════════════════════════
   ACTIVITY LOG ROWS
══════════════════════════════════════════════ */

.act-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-bottom: var(--border-width) solid var(--border);
}

.act-row:last-child { border-bottom: none; }

.act-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.act-icon i { font-size: 10px; color: #fff; }

.act-info { flex: 1; }

.act-title {
  font-size: var(--fs-sm);
  color: var(--tp);
  line-height: 1.3;
}

.act-sub { font-size: 10px; color: var(--ts); margin-top: 2px; }

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */

/* Text utilities */
.text-ac  { color: var(--ac); }
.text-up  { color: var(--up); }
.text-dn  { color: var(--dn); }
.text-am  { color: var(--am); }
.text-ts  { color: var(--ts); }
.text-tp  { color: var(--tp); }
.fw-500   { font-weight: var(--fw-medium); }
.fs-10    { font-size: 10px; }
.fs-11    { font-size: var(--fs-sm); }
.fs-12    { font-size: var(--fs-base); }

/* Display utilities */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.d-none   { display: none; }
.ai-center{ align-items: center; }
.jc-between { justify-content: space-between; }
.jc-end   { justify-content: flex-end; }
.gap-4    { gap: 4px; }
.gap-6    { gap: 6px; }
.gap-8    { gap: 8px; }
.gap-10   { gap: 10px; }
.ml-auto  { margin-left: auto; }
.mt-8     { margin-top: 8px; }
.mt-12    { margin-top: 12px; }
.mb-8     { margin-bottom: 8px; }
.mb-12    { margin-bottom: 12px; }

/* Border utilities */
.border-top { border-top: var(--border-width) solid var(--border); }
.border-bot { border-bottom: var(--border-width) solid var(--border); }

/* Overflow */
.overflow-x-auto { overflow-x: auto; scrollbar-width: none; }
.overflow-x-auto::-webkit-scrollbar { display: none; }

/* ── Breadcrumb (content-area, clickable; both nav layouts) ───────────── */
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px 0;
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}
.crumb-link {
  color: var(--ac, #6366f1);
  text-decoration: none;
  font-weight: 600;
}
.crumb-link:hover { text-decoration: underline; }
.crumb-sep {
  color: var(--ts);
  font-size: 14px;
  line-height: 1;
}
.crumb-cur { color: var(--tp); font-weight: 600; }

/* Always-visible sign out in the sidebar footer */
.sb-bot .user-row { display: flex; align-items: center; gap: 9px; }
.sb-signout-form { margin: 0; margin-left: auto; }
.sb-signout { background: none; border: none; cursor: pointer; padding: 6px;
  border-radius: 8px; color: var(--ts); display: flex; align-items: center; }
.sb-signout i { font-size: 18px; }
.sb-signout:hover { background: var(--th); color: #c0392b; }
