/* ============================================================
   KanameBase 部材受発注システム — MOC design system
   ============================================================ */
:root {
  --brand: #0e4b57;
  --brand-700: #0a3a44;
  --brand-600: #136173;
  --brand-100: #e6f2f4;
  --brand-50: #f2f8f9;
  --accent: #a67c2e;
  --accent-100: #f7efdd;

  --ink: #16232b;
  --ink-2: #2c3c46;
  --muted: #64757f;
  --muted-2: #8a9aa3;
  --line: #e1e8ec;
  --line-2: #eef2f5;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;

  --ok: #17795e;
  --ok-bg: #e9f6f1;
  --warn: #9a6208;
  --warn-bg: #fdf3e0;
  --danger: #b02a2a;
  --danger-bg: #fdeceb;
  --info: #1e5f8f;
  --info-bg: #eaf3fa;
  --prog: #4a4c9c;
  --prog-bg: #eeeffb;
  --neutral: #53656f;
  --neutral-bg: #eef2f4;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 34, 43, .05);
  --shadow-sm: 0 1px 3px rgba(16, 34, 43, .07), 0 1px 2px rgba(16, 34, 43, .04);
  --shadow: 0 6px 20px rgba(16, 34, 43, .09);
  --shadow-lg: 0 20px 50px rgba(13, 32, 40, .18);

  --sidebar-w: 250px;
  --topbar-h: 58px;
  --sans: "Noto Sans JP", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink); letter-spacing: .005em; }
p { margin: 0 0 8px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12px; }
::selection { background: #cfe6ea; }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--brand-50); z-index: 99; }
.boot-inner { display: flex; align-items: center; gap: 14px; }
.boot-title { font-weight: 700; letter-spacing: .12em; color: var(--brand); font-size: 15px; }
.boot-sub { font-size: 12px; color: var(--muted); }
.brandmark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, var(--brand-600), var(--brand-700));
  color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.brandmark-lg { width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }

/* ---------- shell ---------- */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: #102c35; color: #c7d6dc; display: flex; flex-direction: column; z-index: 40;
}
.sidebar-head { padding: 14px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sb-brand { display: flex; align-items: center; gap: 10px; }
.sb-brand .brandmark { background: #fff; color: var(--brand-700); box-shadow: none; }
.sb-brand-txt strong { display: block; color: #fff; font-size: 13px; letter-spacing: .1em; font-weight: 700; }
.sb-brand-txt span { display: block; font-size: 11px; color: #8fb0ba; letter-spacing: .02em; }
.sb-app { margin-top: 12px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.06); }
.sb-app i { color: #7fd0d8; font-size: 13px; }
.sb-app div { min-width: 0; }
.sb-app strong { display: block; color: #eaf4f6; font-size: 12.5px; font-weight: 600; }
.sb-app span { display: block; font-size: 10.5px; color: #8fb0ba; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 10px 10px 18px; scrollbar-width: thin; }
.nav-scroll::-webkit-scrollbar { width: 6px; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }
.nav-group { margin: 10px 0 2px; padding: 0 10px; font-size: 10px; letter-spacing: .1em; color: #7b96a0; font-weight: 600; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: #c2d3d9; font-size: 12.5px; cursor: pointer; user-select: none; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item i { width: 16px; text-align: center; font-size: 12px; color: #7fa3ad; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(127,208,216,.14); color: #fff; box-shadow: inset 2px 0 0 #5fc0cb; }
.nav-item.active i { color: #7fd0d8; }
.nav-item .count { margin-left: auto; font-size: 10.5px; background: rgba(255,255,255,.12); border-radius: 20px; padding: 0 7px; color: #dbe9ed; }
.nav-item .count.hot { background: #c9713a; color: #fff; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.07); padding: 10px; }
.sb-user { display: flex; gap: 9px; align-items: center; width: 100%; border: 0; background: none; color: #c7d6dc; padding: 7px; border-radius: 8px; cursor: pointer; text-align: left; }
.sb-user:hover { background: rgba(255,255,255,.06); }
.sb-user .avatar { background: #214d59; color: #cfe9ee; }
.sb-user div { min-width: 0; }
.sb-user strong { display: block; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user span { display: block; font-size: 10.5px; color: #8fb0ba; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-demo-badge { margin: 8px 2px 0; font-size: 10px; color: #9db6bf; display: flex; align-items: center; gap: 6px; }
.sb-demo-badge b { font-weight: 600; color: #d9b06a; }

.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 22px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); min-width: 0; }
.crumb b { color: var(--ink); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb i { font-size: 9px; color: var(--muted-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); border-color: var(--line); }
.icon-btn .dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: #c9713a; }
.ctx-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); font-size: 11.5px; color: var(--ink-2); cursor: pointer;
}
.ctx-chip:hover { border-color: #c5d5db; background: var(--brand-50); }
.ctx-chip i { color: var(--brand-600); font-size: 11px; }
.ctx-chip .sep { width: 1px; height: 14px; background: var(--line); }
.ctx-chip .role { color: var(--brand-600); font-weight: 600; }
.menu-btn { display: none; }
.content { padding: 20px 22px 56px; max-width: 1520px; width: 100%; margin: 0 auto; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.page-head .lede { font-size: 12.5px; color: var(--muted); margin-top: 3px; max-width: 760px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.section-head h2 { font-size: 14px; font-weight: 600; }
.section-head .sub { font-size: 11.5px; color: var(--muted); }
.section-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ---------- cards / grid ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 13px; font-weight: 600; }
.card-head .sub { font-size: 11px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2.05fr) minmax(300px, 1fr); }
.grid-dash { grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.xs { font-size: 10.5px; }
.nowrap { white-space: nowrap; }
.tr { text-align: right; }
.tc { text-align: center; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.hr { height: 1px; background: var(--line-2); margin: 14px 0; border: 0; }
.mono-num { font-variant-numeric: tabular-nums; font-family: var(--sans); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.big { font-size: 18px; }
.amount .yen { font-size: .78em; color: var(--muted); font-weight: 500; margin-left: 2px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; text-align: left; cursor: default; }
button.kpi { cursor: pointer; transition: box-shadow .12s, border-color .12s, transform .12s; }
button.kpi:hover { border-color: #c9d8de; box-shadow: var(--shadow-sm); }
button.kpi:active { transform: translateY(1px); }
.kpi .label { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .label i { color: var(--muted-2); font-size: 11px; }
.kpi .value { font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.kpi .foot { font-size: 11px; color: var(--muted); margin-top: 3px; }
.kpi.accent { border-top: 2px solid var(--brand-600); }
.kpi.alert { border-top: 2px solid #c9713a; }
.kpi.alert .value { color: #a35122; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); border-color: #cdd9de; text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(.5px); }
.btn i { font-size: 11.5px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn.secondary { background: var(--brand-50); border-color: #cfe1e5; color: var(--brand-600); }
.btn.secondary:hover { background: var(--brand-100); }
.btn.danger { background: #fff; border-color: #eccac8; color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.sm { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; }
.btn.lg { height: 38px; padding: 0 18px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[disabled], .btn.busy { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.btn-group .btn { border: 0; border-radius: 0; height: 30px; border-right: 1px solid var(--line); }
.btn-group .btn:last-child { border-right: 0; }
.btn-group .btn.on { background: var(--brand-50); color: var(--brand); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand-600); }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand-600); font-size: inherit; cursor: pointer; text-decoration: none; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 20px; font-size: 10.8px;
  font-weight: 500; line-height: 1.6; white-space: nowrap; border: 1px solid transparent;
}
.badge i { font-size: 9px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #cbe8dd; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f3e0bb; }
.badge.danger { background: var(--danger-bg); color: var(--danger); border-color: #f3d2d0; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: #cfe3f2; }
.badge.prog { background: var(--prog-bg); color: var(--prog); border-color: #dcddf4; }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); border-color: #dde5e8; }
.badge.brand { background: var(--brand-100); color: var(--brand); border-color: #cfe3e7; }
.badge.outline { background: #fff; border-color: var(--line); color: var(--muted); }
.badge.ghost { background: none; border-color: transparent; color: var(--muted); padding-left: 0; }
.dotmark { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }
.dotmark.ok { background: var(--ok); } .dotmark.warn { background: #d18b16; } .dotmark.danger { background: var(--danger); }
.dotmark.info { background: var(--info); } .dotmark.prog { background: var(--prog); } .dotmark.neutral { background: #9aa9b1; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); font-size: 11px; }
.chip.code { font-family: var(--mono); font-size: 10.8px; background: #f1f5f7; border: 1px solid var(--line); }
.tag-now { font-size: 10px; color: var(--muted-2); border: 1px dashed var(--line); border-radius: 4px; padding: 0 4px; }
.state-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.state-line .arrow { color: var(--muted-2); font-size: 9px; }
.state-item { display: inline-flex; align-items: center; gap: 4px; font-size: 10.8px; }
.state-item .k { color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.tbl thead th {
  position: sticky; top: 0; background: #f7f9fa; color: var(--muted); font-weight: 600; font-size: 11px;
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1;
}
table.tbl tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fbfcfd; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.is-new { animation: rowflash 2.4s ease-out; }
@keyframes rowflash { 0% { background: #fdf6e3; } 100% { background: transparent; } }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.tight, table.tbl th.tight { padding: 6px 10px; }
table.tbl tr.selected { background: var(--brand-50) !important; }
table.tbl tfoot td { padding: 9px 12px; border-top: 1px solid var(--line); font-weight: 600; background: var(--panel-2); }
.cell-main { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 10.8px; color: var(--muted); margin-top: 1px; }
.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.table-note { padding: 9px 12px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line-2); display: flex; gap: 10px; align-items: center; }
.link-row { color: inherit; text-decoration: none; display: block; }
.link-row:hover { text-decoration: none; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { margin: 0; }
.filter-search { position: relative; }
.filter-search i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 11px; }
.filter-search input { padding-left: 27px; width: 210px; }
.seg { display: inline-flex; gap: 2px; background: var(--line-2); padding: 2px; border-radius: 8px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 3px 9px; border-radius: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }
.seg button .n { font-size: 10px; color: var(--muted-2); margin-left: 3px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 11.5px; font-weight: 500; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.field label .req { color: var(--danger); font-size: 10px; }
.field label .opt { color: var(--muted-2); font-size: 10px; font-weight: 400; }
.field .hint { font-size: 10.8px; color: var(--muted); }
.field .err { font-size: 10.8px; color: var(--danger); display: flex; gap: 4px; align-items: center; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=search], input[type=url], input[type=month], select, textarea {
  width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; font-size: 12.5px; color: var(--ink);
}
textarea { height: auto; min-height: 74px; padding: 7px 9px; resize: vertical; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2364757f' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px; }
input:focus, select:focus, textarea:focus { border-color: #6ea9b5; box-shadow: 0 0 0 3px rgba(20,102,122,.11); }
input:disabled, select:disabled, textarea:disabled { background: #f5f8f9; color: var(--muted); }
input.invalid, select.invalid, textarea.invalid { border-color: #cf6d63; box-shadow: 0 0 0 3px rgba(176,42,42,.07); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-600); width: 13px; height: 13px; }
.check { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; cursor: pointer; }
.check input { margin-top: 3px; flex: none; }
.check .desc { font-size: 11px; color: var(--muted); }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.inline-fields { display: flex; gap: 8px; align-items: flex-end; }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted-2); pointer-events: none; }
.input-unit input { padding-right: 30px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 2px; margin: 0 0 14px; }
fieldset legend { font-size: 11.5px; font-weight: 600; color: var(--ink); padding: 0 6px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding-top: 6px; }
.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.radio-card { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; cursor: pointer; background: #fff; }
.radio-card input { display: none; }
.radio-card .t { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.radio-card .d { font-size: 10.8px; color: var(--muted); margin-top: 2px; }
.radio-card.on { border-color: #7bb0ba; background: var(--brand-50); box-shadow: inset 0 0 0 1px #a8ccd3; }
.seg-inline { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-inline label { padding: 4px 10px; font-size: 11.5px; cursor: pointer; border-right: 1px solid var(--line); color: var(--muted); }
.seg-inline label:last-child { border-right: 0; }
.seg-inline input { display: none; }
.seg-inline label.on { background: var(--brand-50); color: var(--brand); font-weight: 600; }

/* ---------- definition lists ---------- */
.dl { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 6px 12px; font-size: 12.3px; }
.dl dt { color: var(--muted); font-size: 11.5px; }
.dl dd { margin: 0; color: var(--ink-2); }
.dl.tight { gap: 4px 10px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12.3px; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-variant-numeric: tabular-nums; }
.kv-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 600; color: var(--ink); font-size: 14px; }
.money-box { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand-600); font-weight: 600; }
.tabs button .n { font-size: 10px; background: var(--line-2); border-radius: 10px; padding: 0 5px; margin-left: 4px; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 13px; }
.tl-item::before { content: ""; position: absolute; left: -16px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: #fff; border: 1.6px solid #9db3bb; }
.tl-item.ok::before { border-color: var(--ok); background: var(--ok); }
.tl-item.warn::before { border-color: #d18b16; background: #d18b16; }
.tl-item.danger::before { border-color: var(--danger); background: var(--danger); }
.tl-item.info::before { border-color: var(--info); background: var(--info); }
.tl-item.current::before { box-shadow: 0 0 0 3px rgba(20,97,115,.14); }
.tl-time { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 12.3px; color: var(--ink); font-weight: 500; margin-top: 1px; }
.tl-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tl-body { font-size: 11.5px; color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 9px; margin-top: 3px; white-space: pre-wrap; }

/* ---------- progress ---------- */
.pipeline { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.pipe-step { display: flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; border-radius: 20px; font-size: 10.8px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-2); }
.pipe-step i { font-size: 9px; }
.pipe-step.done { background: var(--ok-bg); color: var(--ok); border-color: #d5ece3; }
.pipe-step.now { background: #fff7e8; color: #96620b; border-color: #f0dfba; font-weight: 600; }
.pipe-step.blocked { background: var(--danger-bg); color: var(--danger); border-color: #f2d5d2; }
.pipe-sep { width: 10px; height: 1px; background: var(--line); margin: 0 1px; flex: none; }
.bar { height: 5px; background: var(--line-2); border-radius: 20px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand-600); border-radius: 20px; }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: #d18b16; } .bar.danger > span { background: var(--danger); }

/* ---------- alert / notice ---------- */
.notice { display: flex; gap: 9px; padding: 9px 12px; border-radius: 8px; font-size: 11.8px; border: 1px solid; align-items: flex-start; }
.notice i { margin-top: 2px; font-size: 12px; }
.notice .body { min-width: 0; }
.notice strong { font-weight: 600; }
.notice.info { background: var(--info-bg); border-color: #d4e6f4; color: #194e75; }
.notice.warn { background: #fdf7ea; border-color: #f1e2c2; color: #7d5008; }
.notice.danger { background: #fdf0ef; border-color: #f4d7d4; color: #8f2020; }
.notice.ok { background: var(--ok-bg); border-color: #d2ece1; color: #11624b; }
.notice.neutral { background: var(--panel-2); border-color: var(--line); color: var(--ink-2); }
.notice a { color: inherit; text-decoration: underline; }
.demo-note { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: #8a6a1f; background: #fdf6e4; border: 1px dashed #e8d3a2; border-radius: 5px; padding: 1px 7px; }
.demo-note i { font-size: 10px; }

/* ---------- empty / loading ---------- */
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 22px; color: #c3d0d6; display: block; margin-bottom: 8px; }
.empty .t { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.empty .d { font-size: 11.5px; margin-top: 3px; max-width: 420px; margin-left: auto; margin-right: auto; }
.empty .a { margin-top: 12px; }
.skeleton { background: linear-gradient(90deg, #eef2f4 25%, #f6f9fa 50%, #eef2f4 75%); background-size: 400% 100%; animation: sk 1.3s infinite; border-radius: 5px; height: 12px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.loading-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 20px; justify-content: center; }
.spinner { width: 14px; height: 14px; border: 2px solid #dbe5e9; border-top-color: var(--brand-600); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal / drawer ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12, 27, 33, .42); backdrop-filter: blur(1.5px); z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 40px 18px; overflow-y: auto; animation: fadein .12s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 660px; animation: modalin .16s ease-out; margin: auto; }
.modal.wide { max-width: 900px; }
.modal.xwide { max-width: 1080px; }
.modal.slim { max-width: 460px; }
@keyframes modalin { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { font-size: 15px; font-weight: 600; }
.modal-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 16px 20px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line-2); background: var(--panel-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; align-items: center; }
.drawer-backdrop { justify-content: flex-end; padding: 0; }
.drawer { max-width: 560px; height: 100%; border-radius: 0; margin: 0; animation: slidein .18s ease-out; display: flex; flex-direction: column; }
@keyframes slidein { from { transform: translateX(24px); opacity: .8; } to { transform: none; opacity: 1; } }
.drawer .modal-body { max-height: none; flex: 1; }
.drawer .modal-foot { border-radius: 0; }

/* ---------- toasts ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; max-width: 380px; }
.toast { display: flex; gap: 9px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 8px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 12px; animation: toastin .18s ease-out; }
@keyframes toastin { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.ok { border-left-color: var(--ok); }
.toast.ok > i { color: var(--ok); }
.toast.danger { border-left-color: var(--danger); }
.toast.danger > i { color: var(--danger); }
.toast.warn { border-left-color: #d18b16; }
.toast.warn > i { color: #b87b10; }
.toast.info { border-left-color: var(--info); }
.toast.info > i { color: var(--info); }
.toast .t { font-weight: 600; color: var(--ink); font-size: 12px; }
.toast .d { color: var(--muted); font-size: 11.3px; margin-top: 1px; }
.toast .x { margin-left: auto; border: 0; background: none; color: var(--muted-2); cursor: pointer; padding: 0 2px; }

/* ---------- misc widgets ---------- */
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-100); color: var(--brand); display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.avatar.lg { width: 38px; height: 38px; font-size: 13px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.gray { background: #eef2f4; color: var(--muted); }
.org-dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.list-clean { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row .body { min-width: 0; flex: 1; }
.list-row .t { font-size: 12.3px; font-weight: 500; color: var(--ink); }
.list-row .d { font-size: 11.3px; color: var(--muted); }
.list-row .r { margin-left: auto; text-align: right; font-size: 11px; color: var(--muted); white-space: nowrap; }
.activity-item { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 11.8px; }
.activity-item:last-child { border-bottom: 0; }
.activity-item .when { color: var(--muted-2); font-size: 10.5px; white-space: nowrap; margin-left: auto; }
.selectable-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.selectable-card:hover { border-color: #c3d5db; box-shadow: var(--shadow-sm); }
.product-thumb { aspect-ratio: 4 / 3; background: linear-gradient(145deg, #eef4f5, #e2ecee); display: grid; place-items: center; color: #7f9aa3; font-size: 22px; position: relative; }
.product-thumb .cat { position: absolute; top: 7px; left: 7px; font-size: 9.5px; background: rgba(255,255,255,.9); border-radius: 4px; padding: 0 5px; color: var(--ink-2); }
.product-thumb .oos { position: absolute; inset: 0; background: rgba(245,248,249,.72); display: grid; place-items: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.toggle { position: relative; display: inline-flex; width: 34px; height: 19px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track { position: absolute; inset: 0; background: #cfdae0; border-radius: 20px; transition: background .15s; cursor: pointer; }
.toggle .track::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--shadow-xs); }
.toggle input:checked + .track { background: var(--brand-600); }
.toggle input:checked + .track::after { transform: translateX(15px); }
.toggle input:disabled + .track { opacity: .5; cursor: not-allowed; }
.seq { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seq .s { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.seq .s.done { background: var(--ok-bg); border-color: #d5ece3; color: var(--ok); }
.seq .s.now { background: #fff7e8; border-color: #f0dfba; color: #8a5c07; font-weight: 600; }
.seq .s.skip { color: var(--muted-2); text-decoration: line-through; }
.seq .ar { color: var(--muted-2); font-size: 9px; }
.metric-line { display: flex; justify-content: space-between; font-size: 11.5px; padding: 3px 0; }
.metric-line .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.mini-bars span { flex: 1; background: #cfe0e4; border-radius: 2px 2px 0 0; min-height: 3px; }
.doc-preview { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 26px 30px; font-size: 11.5px; color: #26333a; box-shadow: var(--shadow-sm); }
.doc-preview h4 { font-size: 17px; letter-spacing: .16em; text-align: center; margin-bottom: 4px; font-weight: 600; }
.doc-preview .doc-meta { display: flex; justify-content: space-between; font-size: 10.8px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.doc-preview .doc-to { font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--ink-2); display: inline-block; padding-bottom: 2px; margin-bottom: 10px; }
.doc-preview table { width: 100%; border-collapse: collapse; font-size: 10.8px; margin-top: 8px; }
.doc-preview th, .doc-preview td { border-bottom: 1px solid var(--line-2); padding: 5px 4px; text-align: left; }
.doc-preview th { color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); }
.doc-preview td.n, .doc-preview th.n { text-align: right; font-variant-numeric: tabular-nums; }
.doc-preview .doc-total { display: flex; justify-content: flex-end; gap: 20px; margin-top: 10px; font-size: 12px; font-weight: 600; }
.doc-stamp { border: 1.5px solid #b8433c; color: #b8433c; border-radius: 4px; font-size: 10px; padding: 1px 6px; display: inline-block; transform: rotate(-4deg); letter-spacing: .1em; }
.mail-preview { background: #fbfcfd; border: 1px solid var(--line); border-radius: 6px; }
.mail-preview .mh { padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 11.5px; }
.mail-preview .mh div { display: flex; gap: 8px; padding: 1px 0; }
.mail-preview .mh .k { color: var(--muted); width: 48px; flex: none; }
.mail-preview .mb { padding: 12px; font-size: 11.8px; white-space: pre-wrap; font-family: var(--sans); max-height: 320px; overflow-y: auto; }
.map-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.flow-lane { display: grid; grid-template-columns: 1fr 26px 1fr 26px 1fr; align-items: stretch; gap: 0; }
.flow-node { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; font-size: 11.5px; }
.flow-node .org { font-weight: 600; color: var(--ink); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.flow-node .role { font-size: 10px; color: var(--muted); }
.flow-node .rel { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.flow-arrow { display: grid; place-items: center; color: #a9bcc3; font-size: 11px; }
.two-col-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 14px); }
.cart-line { display: grid; grid-template-columns: 1fr 74px 92px 26px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.cart-line:last-child { border-bottom: 0; }
.cart-line input { height: 28px; }
.status-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.status-cell { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.status-cell .k { font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; }
.status-cell .v { margin-top: 3px; }
.perm-y { color: var(--ok); } .perm-n { color: #c4ced3; }
.perm-y-cell { text-align: center; }

/* ---------- role switch + login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); background: #fff; }
.login-left { background: radial-gradient(1200px 600px at 15% 10%, #1b5b68 0%, #0d333d 55%, #0a2831 100%); color: #d8e7eb; padding: 46px 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-left::after { content: ""; position: absolute; right: -120px; bottom: -140px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); }
.login-left h2 { color: #fff; font-size: 25px; line-height: 1.45; letter-spacing: .01em; margin-top: 30px; font-weight: 600; }
.login-left p { color: #9fbcc4; font-size: 12.5px; max-width: 440px; }
.login-left .feat { display: grid; gap: 10px; margin-top: 26px; max-width: 460px; }
.login-left .feat div { display: flex; gap: 9px; font-size: 12px; color: #c5dade; align-items: flex-start; }
.login-left .feat i { color: #6fc3ce; margin-top: 3px; font-size: 11px; }
.login-left .foot { margin-top: auto; font-size: 10.5px; color: #7d9aa3; padding-top: 30px; }
.login-right { padding: 40px 44px; display: flex; flex-direction: column; justify-content: center; background: #fbfcfd; }
.login-card { width: 100%; max-width: 460px; margin: 0 auto; }
.login-card h1 { font-size: 18px; }
.login-card .lede { font-size: 12px; color: var(--muted); margin: 4px 0 16px; }
.persona-list { display: grid; gap: 7px; margin: 10px 0 14px; max-height: 330px; overflow-y: auto; padding-right: 2px; }
.persona { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; width: 100%; }
.persona:hover { border-color: #b9cfd5; background: var(--brand-50); }
.persona.on { border-color: var(--brand-600); background: var(--brand-50); box-shadow: inset 0 0 0 1px #9ec4cb; }
.persona .nm { font-size: 12.3px; font-weight: 600; color: var(--ink); }
.persona .mt { font-size: 10.8px; color: var(--muted); }
.persona .r { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid-main, .grid-dash, .two-col-form { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .content { padding: 14px 12px 70px; }
  .topbar { padding: 0 12px; }
  .ctx-chip .ctx-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-left { display: none; }
  .login-right { padding: 24px 18px; }
  .page-head h1 { font-size: 17px; }
  .kpi .value { font-size: 19px; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { border-radius: 14px 14px 0 0; }
  .modal-body { max-height: 72vh; }
  .form-grid, .form-grid.c3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2, .form-grid .span3 { grid-column: auto; }
  .drawer { max-width: 100%; }
  .doc-preview { padding: 16px 14px; }
  .filters { padding: 9px 10px; }
  .filter-search input { width: 100%; }
  .flow-lane { grid-template-columns: 1fr; }
  .flow-arrow { height: 20px; transform: rotate(90deg); }
  .results-line { font-size: 10.5px; }
}
@media (min-width: 901px) { .sidebar-scrim { display: none !important; } }
.sidebar-scrim { position: fixed; inset: 0; background: rgba(10,25,31,.4); z-index: 35; }

/* print (invoice preview) */
@media print {
  .sidebar, .topbar, .no-print, .toast-root, .filters { display: none !important; }
  .main-wrap { margin: 0; }
  .content { padding: 0; }
  .modal-backdrop { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: none; }
  .modal-body { max-height: none; overflow: visible; }
  .doc-preview { border: 0; box-shadow: none; }
}

/* filterBar inner uses flex too */
.filters-inner { display: contents; }
