:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #17211c;
  --muted: #67736d;
  --line: #dce3dd;
  --primary: #1f6f54;
  --primary-dark: #164b3a;
  --accent: #b88746;
  --danger: #a43d3d;
  --shadow: 0 10px 30px rgba(21, 38, 31, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #1e352b, #edf2ec 58%);
}
.login-panel {
  width: min(390px, calc(100vw - 32px));
  padding: 28px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--shadow);
  border-radius: 8px;
}
.login-panel h1 { margin: 0 0 22px; font-size: 32px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }

.app { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.app.sidebar-collapsed { grid-template-columns: 74px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #16231d;
  color: #f7fbf8;
  scrollbar-width: thin;
}
.brand { padding: 6px 10px 22px; }
.brand strong { display: block; font-size: 21px; }
.brand span { display: block; margin-top: 4px; color: #aebbb4; font-size: 13px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 11px 12px;
  text-align: left;
  color: #d9e3dd;
  background: transparent;
}
.sidebar button:hover, .sidebar button.active { color: #fff; background: rgba(255,255,255,.1); }
.sidebar.collapsed { overflow-x: hidden; }
.sidebar.collapsed .brand { padding: 6px 0 18px; text-align: center; }
.sidebar.collapsed .brand strong { font-size: 15px; }
.sidebar.collapsed .brand span, .sidebar.collapsed .nav-heading, .sidebar.collapsed .nav-label, .sidebar.collapsed .nav-extra { display: none; }
.sidebar.collapsed nav button { justify-content: center; padding: 11px 0; }
.nav-group { margin-bottom: 12px; }
.nav-heading {
  display: block;
  color: #91a29a !important;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}
.nav-group.closed > div { display: none; }
.nav-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.nav-label {
  min-width: 0;
  overflow: hidden;
  flex: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-extra { color: #b9c8c0; font-size: 11px; }
.sidebar nav button.disabled { opacity: .72; }

.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 243, .92);
  backdrop-filter: blur(14px);
}
.topbar h2 { margin: 0; font-size: 24px; }
.title-block { flex: 1; }
.userbar { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.view { padding: 22px 26px 34px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel h3 { margin: 0; font-size: 16px; }
.muted-title {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.sub-head {
  min-height: 44px;
  padding-block: 11px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}
.blank-create-block {
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}
.blank-create-block .grid-form {
  padding-block: 16px;
}
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, .9fr); gap: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 26px; }
.flow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.flow-strip button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}
.flow-strip b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
}
.flow-strip span { font-weight: 850; }

form { margin: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}
textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 111, 84, .18); border-color: var(--primary); }
.inline-form, .grid-form { padding: 18px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; align-items: end; }
.master-list-head {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(320px, 1.4fr);
  gap: 14px;
  align-items: end;
  padding: 16px 18px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}
.master-list-head h4 { margin: 0; font-size: 15px; }
.master-list-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 750; }
.master-filter {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, .45fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid #cad8d0;
  border-radius: 8px;
  background: #eef5f1;
}
.master-filter label { color: #46564e; }
.master-filter input, .master-filter select { border-color: #c5d4cc; background: #fff; }
.master-filter-chips { padding: 10px 18px 0; }
.role-form { padding-bottom: 8px; }
.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  padding: 0 18px 18px;
}
.permission-context { margin: 12px 0 16px; padding: 12px; border: 1px solid var(--line); background: #f7f9fb; color: var(--muted); }
.permission-inherited { opacity: .58; }
.permission-grid fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.permission-grid legend { color: var(--muted); font-size: 12px; font-weight: 800; }
.check { display: flex; align-items: center; gap: 8px; margin: 7px 0; color: var(--ink); font-size: 12px; font-weight: 650; }
.check input { width: auto; min-height: auto; }
.form-note { color: var(--muted); font-size: 12px; line-height: 1.45; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px 18px; }
.transaction-wrap + .form-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
}
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 18px 18px; color: var(--muted); font-size: 13px; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.primary, .ghost, .icon-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 13px;
  font-weight: 750;
}
.primary { color: #fff; background: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.ghost, .icon-btn { color: var(--ink); background: #fff; border-color: var(--line); }
.icon-btn { width: 38px; padding: 0; }
.danger { color: #fff; background: var(--danger); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0; background: #f9fbf8; }
td input, td select { min-width: 82px; }
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #d7dfd9;
  border-radius: 999px;
  padding: 3px 9px;
  color: #3f4b45;
  background: #f4f7f5;
  font-size: 12px;
  font-weight: 850;
}
.status-draft { color: #5f5a3a; background: #f5f2df; border-color: #e1d9a8; }
.status-confirmed, .status-active, .status-issued, .status-reserved { color: #185a43; background: #e7f3ed; border-color: #bdd9cd; }
.status-partially-dispatched, .status-partially-consumed { color: #5b4a24; background: #f4ecd9; border-color: #ddc895; }
.status-fully-dispatched, .status-consumed, .status-used, .status-closed { color: #294d63; background: #e4eff5; border-color: #b9d2df; }
.status-cancelled, .status-void, .status-inactive { color: #783333; background: #f4e6e6; border-color: #dfbbbb; }
.status-shortage { color: #74461f; background: #f5eadf; border-color: #ddb98e; }
.status-printed, .status-revised, .status-released { color: #4b5060; background: #eceff4; border-color: #cbd1dc; }
.transaction-wrap { padding: 0 18px; }
.transaction-table th:nth-child(1) { min-width: 160px; }
.transaction-table th:nth-child(10), .transaction-table th:nth-child(12) { min-width: 92px; }
.transaction-table tr.stock-warning td { background: #fff6e8; }
.transaction-table tr.stock-warning [name="available_cft"] { color: #74461f; font-weight: 850; border-color: #ddc895; }
.transaction-table tr.order-overage td { background: #fff0f0; }
.transaction-table tr.order-overage [name="variance"] { color: #a33b3b; font-weight: 850; border-color: #d8a2a2; }
.dispatch-pending-summary { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); background: #f7f9fb; color: var(--muted); font-size: 13px; }
.dispatch-pending-summary strong { color: var(--ink); }
.dispatch-adjustment-box { display: grid; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid #d8c8a2; background: #fffaf0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.field-help { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.danger-text { color: #a33b3b; }
.stock-mini-panel {
  margin: 12px 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.stock-mini-panel .panel-head { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.stock-mini-panel .panel-head h3 { font-size: 13px; }
.stock-mini-panel .table-wrap { max-height: 240px; }
.stock-mini-panel table { font-size: 12px; }
.stock-mini-panel th, .stock-mini-panel td { padding: 8px 10px; }
.doc-badge { color: var(--muted); font-size: 12px; }
.activity-list { padding: 6px 18px 18px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 10px; padding: 18px; }
.activity { padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity strong { display: block; }
.activity span { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 18px; }
.chart-bars { display: grid; gap: 10px; padding: 18px; }
.chart-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(160px, 1fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  font-size: 12px;
}
.chart-row > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-row > div {
  display: grid;
  gap: 3px;
  min-height: 18px;
  align-content: center;
}
.chart-row i {
  display: block;
  height: 7px;
  min-width: 2px;
  border-radius: 3px;
  background: var(--primary);
}
.chart-row i:nth-child(2) { background: var(--accent); }
.chart-row b { text-align: right; font-variant-numeric: tabular-nums; }
.report-title > div:first-child { min-width: 0; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.report-actions button:disabled { opacity: .45; cursor: not-allowed; }
.report-filter {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(4, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.more-filters {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}
.more-filters summary {
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}
.more-filters > div {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  padding: 0 12px 12px;
}
.report-filter-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 14px;
}
.filter-chip {
  min-height: 30px;
  border: 1px solid #c9d8d0;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--primary-dark);
  background: #eef6f2;
  font-size: 12px;
  font-weight: 750;
}
.report-totals {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin: 0;
  padding: 0 18px 18px;
}
.report-totals .empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.report-table-wrap {
  max-width: 100%;
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.report-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.report-table th.num, .report-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report-table tfoot td {
  position: sticky;
  bottom: 0;
  color: var(--ink);
  background: #edf5f1;
  font-weight: 850;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  color: #fff;
  background: #18231e;
  box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }
.footer { padding: 0 26px 22px; color: var(--muted); font-size: 12px; }
.dropdown-list {
  position: absolute;
  z-index: 20;
  min-width: 260px;
  max-height: 240px;
  overflow: auto;
  margin-top: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.dropdown-option {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 9px 11px;
  color: var(--ink);
  text-align: left;
  background: #fff;
}
.dropdown-option:hover, .dropdown-option.active { background: #edf5f1; }
.dropdown-option.clear { color: var(--danger); border-top: 1px solid var(--line); }
.signature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  padding: 42px 18px 18px;
  color: var(--muted);
  font-size: 13px;
}
.signature-row span { border-top: 1px solid var(--line); padding-top: 10px; text-align: center; }
.opening-table thead th { position: sticky; top: 0; z-index: 1; }
.pi-total-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 16px 18px 0;
}
.pi-total-grid > div {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}
.pi-total-grid span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.pi-total-grid strong { display: block; margin-top: 8px; font-size: 18px; }
.pi-print { padding-bottom: 8px; }
.pi-letterhead {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.pi-letterhead > div:first-child { display: flex; gap: 14px; align-items: flex-start; }
.pi-letterhead img { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }
.pi-letterhead h1, .pi-letterhead h2 { margin: 0; letter-spacing: 0; }
.pi-letterhead h1 { font-size: 24px; }
.pi-letterhead h2 { font-size: 22px; text-align: right; }
.pi-letterhead p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }
.pi-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 18px 24px;
}
.pi-two-col section, .pi-summary, .pi-bank {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.pi-two-col h4, .pi-summary h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0; }
.pi-two-col p, .pi-summary p { margin: 6px 0; line-height: 1.5; white-space: pre-wrap; }
.pi-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  margin: 18px 24px 0;
}
.totals-box { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; align-self: start; }
.totals-box p {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.totals-box p:last-child { border-bottom: 0; }
.totals-box .grand { color: #fff; background: var(--primary); font-size: 16px; }
.pi-bank { margin: 18px 24px 0; color: var(--muted); }
.gate-a4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0;
  min-height: 1080px;
  padding: 10px;
  background: #fff;
}
.gate-a6-two {
  grid-template-rows: 1fr;
  min-height: 148mm;
}
.gate-copy {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  padding: 12px;
  border: 1px dashed #9aa7a0;
  font-size: 11px;
  overflow: hidden;
}
.gate-detail-print {
  margin-top: 10mm;
  padding: 12px;
  background: #fff;
  page-break-before: always;
}
.gate-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.gate-head strong { display: block; font-size: 14px; }
.gate-head span { display: block; color: var(--muted); font-weight: 800; }
.gate-head b { display: block; margin-top: 2px; font-size: 13px; text-align: right; }
.reprint { display: block; color: var(--danger); font-size: 10px; text-align: right; }
.gate-grid {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 4px 8px;
  margin-top: 8px;
}
.gate-grid span { color: var(--muted); font-weight: 800; }
.gate-grid b { min-height: 14px; white-space: normal; }
.gate-material { margin-top: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 4px; }
.gate-material p { margin: 5px 0; white-space: pre-wrap; line-height: 1.35; }
.gate-material div { display: flex; justify-content: space-between; gap: 8px; }
.gate-remarks { min-height: 24px; margin: 7px 0 0; color: var(--muted); white-space: pre-wrap; }
.gate-sign {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: auto;
  padding-top: 26px;
  color: var(--muted);
  font-size: 10px;
}
.blank-copy .gate-sign { grid-template-columns: repeat(4, 1fr); }
.gate-sign span { border-top: 1px solid var(--line); padding-top: 4px; text-align: center; }
.blank-page { page-break-after: always; }
.blank-pass-sheet {
  gap: 8px;
  padding: 8px;
  background: #fff;
}
.blank-pass-copy {
  display: flex;
  flex-direction: column;
  min-height: 512px;
  padding: 13px;
  border: 1px solid #1f2937;
  outline: 1px dashed #a8b0aa;
  outline-offset: -7px;
  color: #111827;
  background: #fff;
  font-size: 11px;
  overflow: hidden;
}
.blank-pass-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
  align-items: start;
}
.blank-pass-top strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
}
.blank-pass-top span {
  display: block;
  margin-top: 3px;
  color: #4b5563;
  line-height: 1.35;
}
.blank-serial {
  padding: 7px 8px;
  border: 1px solid #111827;
  text-align: center;
}
.blank-serial small {
  display: block;
  color: #6b7280;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.blank-serial b {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  letter-spacing: 0;
}
.blank-pass-title {
  margin: 10px 0 8px;
  padding: 5px 8px;
  border-block: 1px solid #111827;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}
.blank-lines {
  display: grid;
  gap: 8px;
}
.blank-lines div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 74px minmax(0, 1fr);
  gap: 6px;
  align-items: end;
}
.blank-lines .wide {
  grid-template-columns: 92px minmax(0, 1fr);
}
.blank-lines span {
  color: #374151;
  font-weight: 850;
}
.blank-lines i {
  display: block;
  min-height: 22px;
  border-bottom: 1px solid #111827;
}
.blank-lines .wide i {
  min-height: 34px;
}
.blank-pass-note {
  margin-top: 9px;
  padding: 5px 7px;
  border: 1px solid #d1d5db;
  color: #4b5563;
  font-size: 9px;
  font-weight: 750;
}
.blank-signatures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: auto;
  padding-top: 30px;
  color: #4b5563;
  font-size: 10px;
}
.blank-signatures span {
  border-top: 1px solid #111827;
  padding-top: 4px;
  text-align: center;
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .sidebar, .topbar, .footer, .no-print, .toast { display: none !important; }
  .app { display: block; }
  .view { padding: 0; }
  .panel { box-shadow: none; border: 0; }
  .form-actions { position: static; display: none !important; }
  th, td { white-space: normal; }
  .gate-a4 { min-height: calc(297mm - 24mm); padding: 0; page-break-after: always; }
  .gate-copy { min-height: calc((297mm - 24mm) / 2); box-shadow: none; }
  .gate-a6-two { grid-template-rows: 1fr; min-height: 148mm; page-break-after: always; }
  .gate-a6-two .gate-copy { min-height: 148mm; max-height: 148mm; }
  .gate-detail-print { page-break-before: always; }
  .blank-pass-sheet { gap: 0; min-height: 148mm; padding: 0; }
  .blank-pass-copy { min-height: 148mm; max-height: 148mm; box-shadow: none; break-inside: avoid; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 55vh; height: auto; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .split, .metric-grid, .flow-strip { grid-template-columns: 1fr 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .pi-total-grid { grid-template-columns: repeat(2, 1fr); }
  .report-filter, .more-filters > div, .report-totals { grid-template-columns: 1fr 1fr; }
  .master-list-head { grid-template-columns: 1fr; }
  .master-filter { grid-template-columns: 1fr 1fr auto; }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .view { padding: 16px; }
  .grid-form, .inline-form { grid-template-columns: 1fr; }
  .flow-strip { grid-template-columns: 1fr; }
  .master-filter { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .pi-letterhead, .pi-two-col, .pi-summary { grid-template-columns: 1fr; display: grid; }
  .pi-letterhead h2 { text-align: left; }
  .pi-summary { margin: 14px 16px 0; }
  .report-filter, .more-filters > div, .report-totals { grid-template-columns: 1fr; }
  .form-actions { justify-content: stretch; flex-direction: column; }
  .form-actions button { width: 100%; }
  .transaction-wrap { padding: 0; }
  .transaction-table th, .transaction-table td { padding: 8px; }
}

/* Simple timber workflow redesign */
:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #647084;
  --line: #d8e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(15, 23, 42, .07);
}

body {
  background: linear-gradient(180deg, #f8fafc 0, #eef2f6 340px, #eef2f6 100%);
}

.login-shell {
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .96), rgba(15, 118, 110, .9)),
    #1d4ed8;
}

.login-panel {
  border: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .24);
}

.login-panel h1 {
  color: #111827;
  font-size: 30px;
}

.app {
  grid-template-columns: 252px minmax(0, 1fr);
}

.app.sidebar-collapsed,
.app:has(.sidebar-state:checked) {
  grid-template-columns: 78px minmax(0, 1fr);
}

.sidebar-state {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  padding: 16px 12px;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 18px rgba(15, 23, 42, .035);
}

.brand {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 8px 18px;
}

.brand::before {
  content: "MK";
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: #17202a;
  font-size: 13px;
  font-weight: 900;
}

.brand strong {
  grid-column: 2;
  color: #111827;
  font-size: 18px;
  line-height: 1.1;
}

.brand span {
  grid-column: 2;
  color: #69758a;
  font-size: 12px;
}

.sidebar.collapsed .brand,
.app:has(.sidebar-state:checked) .sidebar .brand {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 8px 0 18px;
}

.sidebar.collapsed .brand strong,
.app:has(.sidebar-state:checked) .sidebar .brand strong {
  display: none;
}

.app:has(.sidebar-state:checked) .sidebar {
  overflow-x: hidden;
}

.app:has(.sidebar-state:checked) .sidebar .brand span,
.app:has(.sidebar-state:checked) .sidebar .nav-heading,
.app:has(.sidebar-state:checked) .sidebar .nav-label,
.app:has(.sidebar-state:checked) .sidebar .nav-extra {
  display: none;
}

.app:has(.sidebar-state:checked) .sidebar nav button {
  justify-content: center;
  padding: 11px 0;
}

.app:has(.sidebar-state:checked) .sidebar button.active::before {
  left: 0;
}

.sidebar button {
  position: relative;
  min-height: 42px;
  border-radius: 8px;
  color: #344054;
  font-weight: 760;
}

.sidebar button:hover {
  color: var(--primary-dark);
  background: #eff6ff;
}

.sidebar button.active {
  color: var(--primary-dark);
  background: #dbeafe;
}

.sidebar button.active::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.nav-heading {
  min-height: auto !important;
  padding: 12px 10px 6px !important;
  color: #98a2b3 !important;
  background: transparent !important;
  font-size: 10px;
  letter-spacing: .06em;
}

.nav-icon {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.nav-extra {
  color: #69758a;
}

.main {
  background: transparent;
}

.topbar {
  padding: 15px 24px;
  background: rgba(248, 250, 252, .9);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}

.topbar h2 {
  color: #111827;
  font-size: 22px;
}

.view {
  padding: 22px 24px 36px;
}

.panel,
.metric,
.flow-strip button,
.workbench-panel {
  border-color: var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 56px;
  background: #fff;
}

.panel h3,
.panel-head h3 {
  color: #1f2937;
  font-size: 15px;
}

.workbench-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .5fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 20px;
  background: #ffffff;
}

.workbench-panel h3 {
  max-width: 720px;
  margin: 0;
  color: #111827;
  font-size: 26px;
  line-height: 1.2;
}

.workbench-panel p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.workbench-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.uom-bar {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin: 0 18px 16px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.uom-bar strong {
  align-self: center;
  color: #1d4ed8;
  font-size: 13px;
}

.uom-bar label {
  color: #334155;
}

.uom-bar select:disabled {
  color: #475569;
  background: #e2e8f0;
}

.uom-bar span {
  align-self: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.flow-strip {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.flow-strip button {
  min-height: 72px;
  align-items: center;
  padding: 13px 14px;
  background: #ffffff;
  box-shadow: none;
}

.flow-strip button:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.flow-strip b {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #111827;
}

.flow-strip span {
  display: grid;
  gap: 2px;
  color: #1f2937;
  font-size: 16px;
}

.flow-strip em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-grid {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
}

.metric {
  padding: 15px;
  border-left: 4px solid #93c5fd;
}

.metric:nth-child(2n) {
  border-left-color: #5eead4;
}

.metric:nth-child(3n) {
  border-left-color: #fbbf24;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  margin-top: 7px;
  color: #111827;
  font-size: 22px;
}

.split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.primary {
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost,
.icon-btn {
  color: #263241;
  background: #fff;
  border-color: #cfd8e3;
}

.ghost:hover,
.icon-btn:hover {
  color: var(--primary-dark);
  border-color: #93c5fd;
  background: #f8fbff;
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  user-select: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(37, 99, 235, .14);
  border-color: var(--primary);
}

th {
  color: #667085;
  background: #f8fafc;
}

.master-list-head,
.report-filter,
.master-filter {
  background: #f8fafc;
}

.master-filter,
.more-filters,
.report-table-wrap {
  border-color: #cfd8e3;
}

.filter-chip {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.chart-row i {
  background: var(--primary);
}

.chart-row i:nth-child(2) {
  background: var(--accent);
}

.footer {
  color: #7b8798;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 980px) {
  .app:has(.sidebar-state:checked) {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    max-height: none;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .workbench-panel {
    grid-template-columns: 1fr;
  }

  .uom-bar {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid,
  .flow-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workbench-panel h3 {
    font-size: 22px;
  }

  .workbench-actions,
  .uom-bar,
  .metric-grid,
  .flow-strip,
  .split {
    grid-template-columns: 1fr;
  }
}
