:root {
  --ink: #16253a;
  --muted: #65758b;
  --line: #dce5ee;
  --paper: #ffffff;
  --canvas: #f4f7fa;
  --brand: #087f95;
  --brand-dark: #07677a;
  --brand-pale: #dff7fa;
  --cyan: #12bfd0;
  --coral: #ff3850;
  --amber: #d89414;
  --red: #c94343;
  --blue: #4a94d6;
  --navy: #102a43;
  --shadow: 0 10px 30px rgba(16, 42, 67, .07);
  --sidebar: 72px;
  --neuro-bg: #e8ecf1;
  --neuro-shadow: 6px 6px 12px #c5c9ce, -6px -6px 12px #ffffff;
  --neuro-shadow-inset: inset 4px 4px 8px #c5c9ce, inset -4px -4px 8px #ffffff;
  --neuro-hover: 8px 8px 16px #c5c9ce, -8px -8px 16px #ffffff;
}
* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); font-family: "DM Sans", sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }

/* Icon-only sidebar with navy background */
.sidebar-icon {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--navy);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  align-items: center;
}

/* Brand logo at top - centered */
.brand-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px 25px;
  width: 100%;
}

.brand-symbol-nav {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.nav-icon-only {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding: 0 12px;
}

.nav-icon-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

/* Hover effect - white bounding box + scale */
.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.nav-icon-btn:hover .nav-icon-img {
  filter: brightness(0) invert(1);
}

/* Active state - WHITE background + blue_black icon */
.nav-icon-btn.active {
  background: white;
}

.nav-icon-img.active-img {
  filter: none;
}

.nav-icon-btn.active .nav-icon-img,
.nav-group.active > .nav-icon-btn .nav-icon-img {
  filter: none;
}

/* Tooltip */
.nav-icon-btn::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 16px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--paper);
  color: var(--navy);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(16, 42, 67, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 100;
}

.nav-icon-btn:hover::after {
  opacity: 1;
  visibility: visible;
  left: calc(100% + 12px);
}

/* Nav group (for purchasing submenu) */
.nav-group {
  position: relative;
}

/* Submenu always visible when group is active */
.nav-group.active .nav-submenu {
  display: block;
  position: static;
  box-shadow: none;
  margin-top: 8px;
  background: transparent;
  padding: 0;
}

.nav-group.active .nav-submenu button {
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
  padding: 8px 12px;
  font-size: 12px;
}

.nav-group.active .nav-submenu button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-group.active .nav-submenu button.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-weight: 600;
}

/* Hover submenu (for inactive group) */
.nav-group:not(.active):hover .nav-submenu {
  display: block;
}

.nav-submenu {
  display: none;
  position: absolute;
  left: calc(100% + 12px);
  top: 0;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 42, 67, 0.2);
  padding: 8px;
  min-width: 200px;
  z-index: 99;
}

.nav-submenu button {
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-submenu button:hover {
  background: var(--canvas);
  color: var(--brand);
}

.nav-submenu button.active {
  background: var(--brand-pale);
  color: var(--brand);
  font-weight: 600;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  background: var(--coral);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(255, 56, 80, 0.4);
}

.badge-sm {
  min-width: 18px;
  height: 18px;
  background: var(--coral);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
}

/* Sub-navigation bar - VERTICAL */
.sub-nav {
  position: fixed;
  left: var(--sidebar);
  top: 0;
  bottom: 0;
  width: 200px;
  background: white;
  border-right: 1px solid var(--line);
  padding: 100px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 15;
}

.sub-nav-item {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.sub-nav-item:hover {
  background: var(--canvas);
  color: var(--ink);
}

.sub-nav-item.active {
  background: var(--navy);
  color: white;
}

.sub-nav-badge {
  min-width: 18px;
  height: 18px;
  background: var(--coral);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(255, 56, 80, 0.4);
}

/* Main content adjusts when sub-nav is present */
.main-icon {
  margin-left: var(--sidebar);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.main-icon.with-subnav {
  margin-left: calc(var(--sidebar) + 200px);
}

/* Hide old sidebar */
.sidebar { display: none; }
.main { display: none; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 25px; color: white; }
.brand-symbol { width: 37px; height: 37px; object-fit: contain; }
.brand strong { display: block; font: 800 16px Manrope; }
.brand small { color: #8fa9c0; font-size: 11px; }
.nav-label {
  padding: 12px 12px 7px;
  background: var(--navy);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.nav { display: grid; gap: 3px; }
.nav button { width: 100%; border: 0; border-radius: 6px; color: #b9cadd; background: transparent; padding: 10px 12px; text-align: left; display: flex; gap: 11px; align-items: center; }
.nav button:hover { color: white; background: rgba(255,255,255,.06); }
.nav button.active { color: white; background: rgba(18,191,208,.15); box-shadow: inset 3px 0 var(--cyan); }
.nav-icon { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.17); border-radius: 6px; font: 700 10px Manrope; }
.nav .badge { margin-left: auto; background: var(--coral); color: white; min-width: 20px; padding: 2px 6px; border-radius: 10px; text-align: center; font-size: 10px; }
.nav .badge + .badge { margin-left: 4px; }
.nav .badge-info { background: #2c7fb7; }
.nav .badge-warn { background: var(--coral); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.1); color: #7894ad; font-size: 11px; line-height: 1.7; }
.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar { height: 72px; padding: 0 32px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.crumb { color: var(--muted); font-size: 12px; }
.crumb strong { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.search-mini { width: 220px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); outline: none; }
.search-mini:focus { border-color: var(--brand); background: white; }
.role-switch { display: flex; align-items: center; gap: 10px; border-left: 1px solid var(--line); padding-left: 16px; }
.profile-trigger { display: flex; align-items: center; gap: 10px; border: 0; padding: 3px 5px; border-radius: 7px; color: inherit; background: transparent; text-align: left; }
.profile-trigger:hover, .profile-trigger:focus-visible { background: var(--canvas); outline: none; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #dff7fa; color: #087f95; font-weight: 800; flex: 0 0 auto; }
.account-identity { display: grid; gap: 1px; }
.account-identity strong { font-size: 11px; }
.role-switch select { border: 0; background: transparent; color: var(--muted); font-size: 10px; max-width: 142px; padding: 0; }
.logout { width: 32px; height: 32px; border: 0; border-radius: 6px; color: var(--muted); background: var(--canvas); font-size: 17px; }
.logout:hover { color: var(--coral); }
.content { padding: 28px 32px 44px; max-width: 1600px; margin: auto; }
.main-icon.with-subnav .content { max-width: none; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 18px; }
.eyebrow { color: var(--brand); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .13em; margin-bottom: 5px; }
h1, h2, h3 { font-family: Manrope, sans-serif; margin: 0; }
h1 { font-size: 25px; letter-spacing: 0; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.button { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 13px; color: var(--ink); background: white; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:hover { border-color: #aec3be; background: #f9fbfa; }
.button.primary { border-color: var(--brand); color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.danger { border-color: #f1c8c8; color: var(--red); background: #fff8f8; }
.button.small { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.button.icon { width: 38px; padding: 0; }
/* Bootstrap-style button classes */
.btn { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 13px; color: var(--ink); background: white; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #aec3be; background: #f9fbfa; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { border-color: var(--brand); color: white; background: var(--brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-secondary { border-color: var(--line); color: var(--ink); background: var(--canvas); }
.btn-secondary:hover:not(:disabled) { background: #e8ecf0; }
.btn-success { border-color: #10b981; color: white; background: #10b981; }
.btn-success:hover:not(:disabled) { background: #059669; border-color: #059669; }
.btn-danger { border-color: #ef4444; color: white; background: #ef4444; }
.btn-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }
.btn-sm { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { min-height: 130px; padding: 18px; border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat:first-child { border-top: 3px solid var(--brand); }
.stat:nth-child(2) { border-top: 3px solid var(--amber); }
.stat:nth-child(3) { border-top: 3px solid var(--blue); }
.stat:nth-child(4) { border-top: 3px solid var(--coral); }
.stat .label { color: var(--muted); font-weight: 600; }
.stat .value { margin-top: 9px; font: 800 27px Manrope; }
.stat .trend { margin-top: 10px; font-size: 11px; color: var(--muted); }
.trend.good { color: var(--brand); }
.stat-glyph { position: absolute; right: 13px; bottom: -16px; font: 800 58px Manrope; color: rgba(23,107,97,.055); }
.dashboard-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 18px; }
.panel { border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); }
.panel-head { min-height: 58px; padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { font-size: 15px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 18px; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pipe { padding: 13px 10px; background: var(--canvas); border-top: 3px solid var(--brand); }
.pipe:nth-child(2) { border-color: var(--amber); }
.pipe:nth-child(3) { border-color: var(--blue); }
.pipe:nth-child(4) { border-color: var(--coral); }
.pipe:nth-child(5) { border-color: var(--red); }
.pipe strong { display: block; font: 800 21px Manrope; }
.pipe span { color: var(--muted); font-size: 10px; }
.bar-chart { height: 190px; display: flex; align-items: end; gap: 13px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bar-group { height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.bar { width: 62%; max-width: 34px; min-height: 6px; background: var(--brand); border-radius: 3px 3px 0 0; position: relative; }
.bar:hover { background: var(--coral); }
.bar-group small { color: var(--muted); font-size: 10px; }
.activity { display: grid; gap: 0; }
.activity-row { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border: 0; }
.activity-dot { width: 9px; height: 9px; margin: 5px auto; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px var(--brand-pale); }
.activity-row strong { font-size: 12px; }
.activity-row p { margin: 3px 0; color: var(--muted); font-size: 11px; }
.activity-row time { color: #9aa7a4; font-size: 10px; }
.filterbar { display: flex; align-items: center; gap: 9px; padding: 13px 16px; border: 1px solid var(--line); border-bottom: 0; background: white; }
.filterbar-multi { display: block; padding: 17px 20px 14px; }
.filterbar-heading { display: flex; align-items: center; gap: 9px; min-height: 28px; margin-bottom: 16px; color: var(--ink); }
.filterbar-heading strong { font: 700 13px Manrope, sans-serif; }
.filterbar-heading__icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: var(--brand); background: var(--brand-pale); font-size: 14px; line-height: 1; }
.filterbar-multi .filter-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 12px; }
.filterbar-multi .filter-field { min-width: 0; }
.filterbar-multi .filter-field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.filterbar-multi .filter-field .field-control { height: 40px; }
.filterbar-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 46px; margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--line); }
.filterbar-multi .filter-actions, .bulk-actions { display: flex; align-items: center; gap: 8px; }
.filterbar-multi .filter-actions { justify-content: flex-end; margin-top: 0; }
.bulk-actions { min-width: 0; }
.bulk-select-all { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; white-space: nowrap; color: var(--ink); font-size: 12px; font-weight: 700; }
.selection-count { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--canvas); font-size: 10px; font-weight: 600; }
.filterbar .bulk-select-all input { flex: 0 0 auto; width: 16px; min-width: 16px; height: 16px; }
.bulk-select-all input, .selection-cell input, [data-bulk-row] { width: 16px; height: 16px; accent-color: var(--brand); }
.selection-cell { width: 42px; min-width: 42px; padding-left: 12px; padding-right: 4px; text-align: center; }
.bulk-row-checkbox { display: inline-flex; align-items: center; margin-right: 8px; }
.crm-task-card > .bulk-row-checkbox { display: block; margin: -4px 0 6px; }
.filterbar input { flex: 1; min-width: 160px; }
.filterbar-multi .filter-actions .button, .bulk-actions .button { min-width: 112px; }
.filterbar-multi .filter-actions .button, .filterbar-multi .bulk-actions .button { width: auto; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.field-control { width: 100%; max-width: 100%; min-width: 0; height: 38px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; background: white; outline: none; }
.field-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,107,97,.08); }
.field-control:disabled { color: var(--muted); background: #f1f4f5; cursor: not-allowed; opacity: .75; }
.project-link-field.is-disabled { opacity: .62; }
.table-wrap { overflow: auto; border: 1px solid var(--line); background: white; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
.delivery-item-summary { margin-top: 4px; color: var(--text-muted); line-height: 1.45; }
.work-tabs { display: flex; align-items: center; gap: 4px; margin: 0 0 14px; padding: 4px; border: 1px solid var(--line); background: #f8faf9; width: fit-content; }
.work-tab { border: 0; padding: 9px 13px; color: var(--muted); background: transparent; font: 700 11px Manrope, sans-serif; cursor: pointer; }
.work-tab span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 5px; padding: 0 5px; border-radius: 10px; color: var(--muted); background: #e8eeec; font-size: 10px; }
.work-tab.is-active { color: var(--brand-dark); background: white; box-shadow: 0 1px 4px rgba(21,63,59,.08); }
.work-tab.is-active span { color: white; background: var(--brand); }
.delivery-meta { color: #71807c; font-size: 10px; }
.overdue-label { color: var(--red); }
.delivery-queue-table td:last-child { min-width: 190px; }
th { height: 42px; padding: 0 14px; color: #71807c; background: #f8faf9; border-bottom: 1px solid var(--line); text-align: left; text-transform: uppercase; letter-spacing: .04em; font-size: 9px; }
td { padding: 13px 14px; border-bottom: 1px solid #e8eeec; vertical-align: middle; }
tbody tr:hover { background: #fbfdfc; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.needs-action { background: #fffbf5; border-left: 3px solid #ff9f43; }
tbody tr.needs-action:hover { background: #fff8ed; }
.cell-title { font-weight: 700; color: var(--ink); }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 11px; }
.money { white-space: nowrap; font-weight: 700; }
.category-spend { margin-top: 18px; }
.viz-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.viz-card .panel-body { display: grid; gap: 14px; }
.viz-donut { display: grid; gap: 14px; justify-items: center; }
.viz-donut svg { width: 150px; height: 150px; }
.viz-donut .viz-legend { justify-self: stretch; }
.viz-donut-value { font: 800 17px Manrope; fill: var(--ink); }
.viz-donut-label { font-size: 10px; fill: var(--muted); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink); }
.viz-donut .viz-legend { flex-direction: column; flex-wrap: nowrap; }
.viz-legend li { display: flex; align-items: center; gap: 7px; min-width: 0; }
.viz-swatch { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.viz-legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-legend-value { margin-left: auto; padding-left: 8px; color: var(--muted); white-space: nowrap; }
.viz-bars { display: grid; gap: 10px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 12px; }
.viz-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.viz-bar-value { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.viz-bar-track { display: block; height: 14px; }
.viz-bar, .viz-stack { display: flex; height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; overflow: hidden; gap: 2px; }
.viz-segment { min-width: 2px; height: 100%; }
.viz-hit { cursor: default; }
.viz-bar-row.viz-hit:hover .viz-bar, .viz-segment:hover, .viz-donut circle:hover { filter: brightness(.9); }
.viz-tip { position: fixed; left: 0; top: 0; z-index: 1000; max-width: 280px; padding: 8px 10px; border-radius: 8px; background: #16253a; color: #fff; font-size: 12px; line-height: 1.45; white-space: pre-line; pointer-events: none; box-shadow: 0 6px 18px rgba(22, 37, 58, .25); }
@media (max-width: 1280px) { .viz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) { .viz-grid { grid-template-columns: 1fr; } }
.category-spend .table-wrap { border: 0; box-shadow: none; }
.category-spend tfoot td { border-top: 1px solid var(--line); border-bottom: 0; background: #f8faf9; }
.status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; padding: 4px 7px; border-radius: 4px; background: #edf1ef; color: #54635f; font-size: 10px; font-weight: 700; }
.status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-approved, .status-paid, .status-received, .status-invoice-uploaded, .status-closed { color: #17705f; background: #e1f3ed; }
.status-pending-approval, .status-pending, .status-pending-invoice, .status-waiting-delivery { color: #9a6706; background: #fff1cf; }
.status-need-revision, .status-partially-paid, .status-partially-received { color: #315f9d; background: #e8effb; }
.status-rejected, .status-overdue { color: #b33d3d; background: #fbe6e6; }
.status-cancelled { color: #6b7280; background: #eef0f3; text-decoration: line-through; }
.status-ordered { color: #684ea4; background: #eee9fa; }
.actions { display: flex; gap: 5px; justify-content: flex-end; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.progress { width: 100px; height: 6px; border-radius: 4px; background: #e8eeec; overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: var(--brand); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.master-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.master-card { border: 1px solid var(--line); background: white; padding: 17px; box-shadow: var(--shadow); }
.master-card h3 { font-size: 14px; }
.master-card p { min-height: 34px; color: var(--muted); font-size: 11px; }
.master-card .count { font: 800 23px Manrope; color: var(--brand); }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; padding: 20px; display: grid; place-items: center; background: rgba(10,31,28,.55); backdrop-filter: blur(3px); }
body.modal-open { overflow: hidden; }
.modal { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.22); animation: rise .22s ease-out; }
.modal.small-modal { width: min(500px, 100%); }
.modal.wide-modal { width: min(860px, 100%); }
.modal.pr-form-modal { width: min(1040px, 100%); }
.pr-form-modal { overflow-x: hidden; }
.pr-form-modal .field { align-content: start; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.modal-head { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 17px; }
.close { border: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--canvas); font-size: 18px; }
.modal-body { padding: 20px 22px; }
.modal-inline-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  color: #8e2c3a;
  background: #fff0f2;
}
.modal-inline-error[hidden] { display: none; }
.export-dialog fieldset { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.export-dialog legend { padding: 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.export-dialog-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.export-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 14px; max-height: 180px; overflow: auto; }
.export-options--rows { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 240px; }
.export-row-option, .export-column-option { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--ink); font-size: 12px; }
.export-row-option span, .export-column-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .export-options, .export-options--rows { grid-template-columns: 1fr; } }
.modal[role="dialog"]:focus,
.modal[role="alertdialog"]:focus { outline: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid > * { min-width: 0; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 700; }
.field textarea { height: 76px; resize: vertical; }
.field input[type="file"] { width: 100%; max-width: 100%; min-width: 0; padding: 6px; font-size: 11px; overflow: hidden; }
.field input[type="file"]::file-selector-button { max-width: 120px; margin-right: 7px; border: 0; border-radius: 4px; padding: 6px 8px; color: var(--ink); background: var(--canvas); font-weight: 700; }
.file-picker-preview { margin-top: 8px; }
.file-picker-preview__label { color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.file-picker-preview__list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-picker-preview__item { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--canvas); font-size: 11px; }
.file-picker-preview__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-picker-preview__item button { border: 0; padding: 0; color: var(--red); background: transparent; line-height: 1; font-size: 16px; }
.callout { padding: 12px 14px; color: #6f581d; background: #fff6dc; border-left: 3px solid var(--amber); font-size: 11px; line-height: 1.6; }
.revision-callout { color: #245d75; background: #eaf8fb; border-color: var(--cyan); }
.revision-items { display: grid; gap: 12px; margin-top: 18px; }
.revision-item { padding: 15px; border: 1px solid var(--line); background: #f8fafc; }
.revision-item-head { margin-bottom: 12px; font: 700 12px Manrope; color: var(--brand-dark); }
.pr-form-layout { display: grid; gap: 16px; }
.pr-form-section { padding: 17px; border: 1px solid var(--line); background: white; }
.pr-form-section > h3 { margin-bottom: 14px; font-size: 14px; }
.pr-form-section-head { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pr-form-section-head h3 { font-size: 14px; }
.pr-form-section-head p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.purchase-item { padding: 16px 0; border-top: 1px solid var(--line); }
.purchase-item:first-child { padding-top: 0; border-top: 0; }
.purchase-item-head { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.purchase-item-head > div { display: flex; align-items: center; gap: 8px; }
.purchase-item-head span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--brand); font-size: 9px; font-weight: 800; }
.calculated-value { height: 38px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--brand-dark); background: var(--canvas); font-weight: 800; }
.pr-form-total { padding-top: 14px; border-top: 2px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 20px; }
.pr-form-total span { color: var(--muted); }
.pr-form-total strong { font: 800 21px Manrope; color: var(--brand-dark); }
.payment-toggles { display: flex; flex-wrap: wrap; gap: 18px; }
.purchase-item-source { margin-bottom: 12px; display: grid; gap: 10px; }
.combobox { position: relative; }
.issue-lines-head { margin: 18px 0 8px; }
.issue-line { display: grid; grid-template-columns: minmax(0, 3fr) minmax(90px, 1fr) minmax(90px, 1fr) auto; gap: 10px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.material-images { display: flex; flex-wrap: wrap; gap: 10px; }
.material-image { position: relative; margin: 0; }
.material-image img { width: 120px; height: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; display: block; }
.material-image-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; color: white; background: rgba(15, 23, 42, .65); cursor: pointer; line-height: 1; }
.material-image-upload { margin: 0; cursor: pointer; }
.material-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.material-thumb--empty { background: var(--soft, #f1f4f5); }
.issue-photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.issue-photos img { width: 120px; height: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 640px) { .issue-line { grid-template-columns: 1fr 1fr; } .issue-line .combobox { grid-column: 1 / -1; } }
.crm-notification-entry { position: relative; }
.crm-notification-action { margin: -4px 12px 10px; padding: 4px 10px; border: 1px solid var(--brand); border-radius: 6px; color: var(--brand); background: white; font-size: 12px; font-weight: 700; cursor: pointer; }
.crm-notification-action:hover { color: white; background: var(--brand); }
.combobox-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; margin: 0; padding: 4px; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: 6px; background: white; box-shadow: 0 10px 24px rgba(15, 40, 38, .14); }
.combobox-list [role="option"] { padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.combobox-list [role="option"] .cell-sub { display: block; }
.combobox-list [role="option"]:hover, .combobox-list [role="option"].active { background: rgba(23, 107, 97, .08); }
.combobox-empty, .combobox-more { padding: 8px 10px; color: var(--muted); font-size: 12px; }
.payment-toggles label { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.payment-toggles input { accent-color: var(--brand); }
.deposit-fields { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.master-config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.master-config { border: 1px solid var(--line); background: white; box-shadow: var(--shadow); }
.master-values { max-height: 330px; overflow: auto; padding: 0 16px; }
.master-value { min-height: 49px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.master-value:last-child { border-bottom: 0; }
.master-value.inactive > span { color: var(--muted); text-decoration: line-through; }
.delete-warning { padding: 5px 0; display: grid; gap: 5px; }
.delete-warning > strong { font: 700 16px Manrope; }
.delete-warning > span { color: var(--muted); }
.delete-warning p { margin: 12px 0 0; padding: 12px; border-left: 3px solid var(--coral); color: #8e2c3a; background: #fff0f2; line-height: 1.6; }
.field > small { color: var(--muted); font-size: 10px; }
.modal .form-group {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}
.modal .form-group > label {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.modal .form-group .form-control {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  outline: none;
}
.modal .form-group textarea.form-control {
  min-height: 96px;
  resize: vertical;
}
.crm-customer-search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.crm-customer-search-row .form-control { flex: 1; min-width: 0; }
.crm-customer-search-row .btn { white-space: nowrap; }
.approval-review-files {
  display: grid;
  gap: 8px;
}

.approval-review-files.is-dragover {
  outline: 2px dashed var(--brand);
  background: var(--brand-pale);
  outline-offset: 4px;
  border-radius: 6px;
}
.approval-review-files input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}
.approval-review-files small {
  color: var(--muted);
  font-size: 10px;
}
.approval-review-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.approval-review-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #b8d7df;
  border-radius: 6px;
  color: var(--ink);
  background: #f1fafb;
  font-size: 11px;
}
.approval-review-file-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.approval-review-file-remove {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #7f8d91;
  background: transparent;
  font-size: 16px;
  line-height: 1;
}
.approval-review-file-remove:hover,
.approval-review-file-remove:focus-visible {
  color: #a92f3b;
  background: #fee7e8;
  outline: none;
}
.auto-filled { color: var(--brand-dark); background: var(--brand-pale); font-weight: 700; }
.quotation-link { display: block; max-width: 100%; margin: 3px 0; padding: 0; border: 0; color: var(--brand); background: transparent; text-align: left; text-decoration: underline; font-weight: 700; }
.receiving-instruction { margin: 17px 0 10px; padding: 11px 13px; border-left: 3px solid var(--cyan); color: #245d75; background: #eaf8fb; font-size: 11px; }
.delivery-checklist { display: grid; gap: 8px; margin-bottom: 17px; }
.delivery-check { min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr 110px; align-items: center; gap: 11px; cursor: pointer; }
.delivery-check:has(input[type="checkbox"]:checked) { border-color: var(--cyan); background: #f0fcfd; }
.delivery-check.complete { opacity: .58; background: var(--canvas); }
.delivery-check > input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
.delivery-check > div { display: grid; gap: 3px; }
.delivery-check > div span { color: var(--muted); font-size: 11px; }
.delivery-check > input[data-delivery-quantity] { text-align: center; }
.item-source { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 9px; font-size: 10px; font-weight: 600; vertical-align: middle; white-space: nowrap; }
.item-source.from-list { background: var(--brand-pale); color: var(--brand-dark); }
.item-source.manual { background: #fff3dc; color: #8a5a00; }
.receiving-form-grid { align-items: start; }
.receiving-form-grid > .field { min-width: 0; }
.receiving-form-grid > .field > .field-control { box-sizing: border-box; height: 46px; }
.receiving-form-grid > .field > input[type="file"] { display: block; padding: 7px 9px; line-height: 28px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.pr-detail-modal { width: min(1100px, 100%); }
.pr-detail-head { align-items: flex-start; }
.pr-detail-head h2 { max-width: 780px; font-size: 20px; }
.pr-detail-body { display: grid; gap: 16px; background: var(--canvas); }
.pr-detail-status { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); background: white; }
.pr-detail-status > strong { font: 800 22px Manrope; color: var(--brand-dark); }
.pr-section { padding: 17px; border: 1px solid var(--line); background: white; }
.pr-section h3 { margin-bottom: 14px; font-size: 13px; }
.pr-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pr-info-grid > div { display: grid; gap: 3px; }
.pr-info-grid span, .pr-purpose > span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pr-info-grid strong { font-size: 12px; }
.pr-purpose { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.pr-purpose p { margin: 6px 0 0; line-height: 1.65; }
.pr-items-wrap { overflow-x: auto; border: 1px solid var(--line); }
.pr-items { min-width: 940px; box-shadow: none; }
.pr-items th { white-space: nowrap; }
.pr-items tfoot td { padding: 12px 14px; border-top: 2px solid var(--line); background: #f8fafc; font-weight: 800; text-align: right; }
.pr-detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pr-related-po { min-height: 54px; padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; }
.pr-related-po:last-child { border-bottom: 0; }
.pr-related-po > div { display: grid; }
.pr-related-po > div span { color: var(--muted); font-size: 11px; }
.pr-history-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pr-history-row:last-child { border-bottom: 0; }
.pr-history-row p { margin: 3px 0; color: var(--muted); font-size: 11px; }
.pr-history-row time { color: #91a0ad; font-size: 10px; }
.pr-empty-note { padding: 18px 0; color: var(--muted); font-size: 11px; }
.po-detail-modal { width: min(1080px, 100%); }
.po-detail-modal { overflow-x: hidden; }
.po-detail-head { align-items: flex-start; }
.po-detail-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.po-detail-body { display: grid; gap: 16px; background: var(--canvas); }
.po-detail-body > *, .po-detail-columns > *, .po-detail-modal .pr-section { min-width: 0; }
.po-detail-modal .pr-items-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.po-status-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: white; }
.po-status-strip > div { min-height: 66px; padding: 12px 14px; border-right: 1px solid var(--line); display: grid; align-content: center; gap: 6px; }
.po-status-strip > div { min-width: 0; }
.po-status-strip > div:last-child { border-right: 0; }
.po-status-strip > div > span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.po-status-strip .status { width: fit-content; }
.po-status-strip .status { max-width: 100%; white-space: normal; }
.po-detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.po-schedule-row { min-height: 57px; padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; }
.po-schedule-row > div { display: grid; gap: 2px; }
.po-schedule-row > div span { color: var(--muted); font-size: 10px; }
.po-history-row { min-height: 50px; padding: 9px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.po-history-row span { color: var(--muted); font-size: 10px; }
.transfer-box, .bank-box, .invoice-box { margin-top: 13px; padding: 11px 12px; border-left: 3px solid var(--cyan); background: #eef9fb; display: grid; gap: 3px; }
.bank-box { border-color: var(--blue); background: #eff6fc; }
.invoice-box { border-color: var(--coral); background: #fff3f5; }
.transfer-box span, .bank-box span, .invoice-box span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.transfer-box strong { overflow-wrap: anywhere; font-size: 11px; }
.bank-box p, .invoice-box p { margin: 0; color: var(--muted); font-size: 10px; }
.toast { position: fixed; right: 25px; bottom: 25px; z-index: 100; max-width: 360px; padding: 12px 16px; border-radius: 7px; color: white; background: #153f3b; box-shadow: 0 14px 38px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.mobile-menu { display: none; }
.app-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: var(--app-icon) center / contain no-repeat;
  mask: var(--app-icon) center / contain no-repeat;
}
.app-icon-menu { --app-icon: url('/static/icons/menu-2.svg'); }
.account-summary { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); max-width: 680px; gap: 12px; margin-bottom: 18px; }
.account-summary > div { padding: 15px 17px; border: 1px solid var(--line); background: white; box-shadow: var(--shadow); display: grid; }
.account-summary strong { font: 800 23px Manrope; color: var(--brand); }
.account-summary span { color: var(--muted); font-size: 11px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { width: 34px; height: 34px; font-size: 11px; }
.role-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.role-tags span { padding: 4px 7px; border-radius: 4px; color: #28658d; background: #e5f2fb; font-size: 10px; font-weight: 700; }
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-option { min-height: 54px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; gap: 9px; cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--cyan); background: #f0fcfd; }
.role-option input { accent-color: var(--brand); }
.role-option span { display: grid; }
.role-option small { color: var(--muted); }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.25fr) minmax(420px, .75fr); grid-template-areas: "brand login"; background: white; }
.login-brand { grid-area: brand; position: relative; overflow: hidden; padding: 52px clamp(40px, 7vw, 110px); color: white; background: var(--navy); display: flex; flex-direction: column; justify-content: space-between; }
.login-brand::after { content: ''; position: absolute; width: 520px; height: 520px; right: -210px; bottom: -260px; border: 70px solid rgba(18,191,208,.13); border-radius: 50%; }
.login-brand > img { width: min(430px, 72%); height: 88px; object-fit: contain; object-position: left center; filter: drop-shadow(0 2px 10px rgba(0,0,0,.08)); }
.login-brand > div { position: relative; z-index: 1; }
.login-brand span { color: #6de4ed; font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .13em; }
.login-brand h1 { margin-top: 14px; max-width: 670px; font-size: clamp(38px, 4.5vw, 68px); line-height: 1.08; }
.login-brand p { max-width: 560px; color: #b8ccdd; font-size: 16px; line-height: 1.7; }
.login-brand small { color: #7591aa; }
.login-panel { grid-area: login; padding: 40px clamp(32px, 6vw, 90px); display: grid; place-items: center; background: #f8fafc; }
.login-form { width: min(430px, 100%); }
.login-symbol { width: 58px; height: 58px; margin-bottom: 26px; }
.login-symbol img { width: 100%; height: 100%; object-fit: contain; }
.login-form h2 { font-size: 28px; }
.login-form > p { color: var(--muted); margin: 7px 0 26px; }
.login-form .field { margin-top: 14px; }
.login-form .field-control { height: 46px; background: white; }
.login-submit { width: 100%; min-height: 46px; margin-top: 20px; }
.login-error { padding: 10px 12px; margin-bottom: 14px; border-left: 3px solid var(--coral); color: #a72e41; background: #fff0f2; font-size: 12px; }
.demo-account { margin-top: 22px; padding: 12px 14px; border: 1px dashed #b9cad9; color: var(--muted); display: grid; font-size: 11px; }
.demo-account strong { color: var(--ink); }
@media (max-width: 1100px) {
  :root { --sidebar: 210px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .master-grid { grid-template-columns: 1fr 1fr; }
  .filterbar-multi .filter-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { transform: translateX(-100%); width: 244px; transition: transform .2s; }
  .sidebar.open { transform: none; }
  .mobile-menu { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); color: var(--ink); background: white; }
  .topbar { height: 62px; padding: 0 16px; }
  .crumb, .search-mini { display: none; }
  .content { padding: 20px 14px 36px; }
  .page-head { align-items: flex-start; }
  h1 { font-size: 21px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { min-height: 112px; padding: 13px; }
  .stat .value { font-size: 21px; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .master-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .filterbar { flex-wrap: wrap; }
  .filterbar input { flex-basis: 100%; }
  .filterbar-multi .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-tabs { width: 100%; overflow-x: auto; }
  .work-tab { flex: 1 0 auto; }
  .filterbar-footer { align-items: stretch; flex-direction: column; gap: 12px; }
  .bulk-actions, .filterbar-multi .filter-actions { width: 100%; justify-content: space-between; }
  .filterbar-multi .filter-actions .button, .bulk-actions .button { flex: 1 1 0; min-width: 0; }
  .role-switch { border: 0; padding: 0; }
  .role-switch .avatar { display: none; }
  .account-identity strong { display: none; }
  .logout { width: 30px; }
  .page-head p { font-size: 12px; }
  .login-page { grid-template-columns: 1fr; grid-template-areas: "brand" "login"; }
  .login-brand { min-height: 240px; padding: 28px 24px; justify-content: flex-start; gap: 30px; }
  .login-brand > img { width: 250px; height: 55px; }
  .login-brand h1 { font-size: 30px; margin: 8px 0; }
  .login-brand p, .login-brand small { display: none; }
  .login-panel { padding: 34px 22px; place-items: start center; }
  .login-symbol { display: none; }
  .account-summary { grid-template-columns: 1fr; }
  .role-picker { grid-template-columns: 1fr; }
  .master-config-grid { grid-template-columns: 1fr; }
  .pr-form-section { padding: 14px; }
  .pr-form-section-head { align-items: flex-start; }
  .pr-form-total { justify-content: space-between; }
  .pr-form-total strong { font-size: 17px; }
  .payment-toggles { display: grid; }
  .delivery-check { grid-template-columns: auto 1fr; }
  .delivery-check > input[data-delivery-quantity] { grid-column: 2; width: 100%; }
  .pr-detail-modal { max-height: calc(100vh - 20px); }
  .pr-detail-body { padding: 14px; }
  .pr-detail-status { align-items: flex-start; }
  .pr-detail-status > strong { font-size: 17px; }
  .pr-info-grid { grid-template-columns: 1fr 1fr; }
  .pr-detail-columns { grid-template-columns: 1fr; }
  .po-detail-columns { grid-template-columns: 1fr; }
  .po-status-strip { grid-template-columns: 1fr 1fr; }
  .po-status-strip > div:nth-child(2) { border-right: 0; }
  .po-status-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .po-schedule-row { grid-template-columns: 1fr auto; }
  .po-schedule-row .status { grid-column: 1 / -1; }
  .po-history-row { grid-template-columns: auto 1fr; }
  .po-history-row span:last-child { grid-column: 2; }
  .pr-section { padding: 14px; }
}
.payment-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 16px; border: 1px solid var(--line); background: white; }
.payment-detail-grid > div { display: grid; gap: 4px; min-width: 0; }
.payment-detail-grid__wide { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); }
.payment-detail-grid .cell-sub { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.payment-detail-grid strong, .payment-detail-grid > div > span:not(.cell-sub) { overflow-wrap: anywhere; font-size: 12px; }
.payment-detail-section { padding: 16px; border: 1px solid var(--line); background: white; }
.payment-detail-section h3 { margin: 0 0 12px; font-size: 13px; }
.payment-detail-proofs { display: flex; flex-wrap: wrap; gap: 8px; }
.payment-detail-proofs a { display: inline-flex; align-items: center; padding: 7px 10px; border: 1px solid var(--line); color: var(--brand-dark); font-size: 11px; font-weight: 700; text-decoration: none; }
@media (max-width: 700px) {
  .payment-detail-grid { grid-template-columns: 1fr 1fr; }
  .payment-detail-grid__wide { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .filterbar-multi .filter-fields { grid-template-columns: 1fr; }
  .filterbar-multi { padding: 14px; }
  .filterbar-footer { gap: 10px; }
  .bulk-actions, .filterbar-multi .filter-actions { flex-wrap: wrap; }
  .bulk-actions .bulk-select-all { width: 100%; }
  .payment-detail-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat { min-height: 104px; }
  .stat .value { font-size: 23px; }
}

/* Applied roles for users with several roles */
.role-apply-trigger { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); color: var(--ink); font-size: 12px; font-weight: 600; cursor: pointer; }
.role-apply-trigger span { padding: 1px 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; }
.role-apply-trigger:hover, .role-apply-trigger:focus-visible { border-color: var(--brand); outline: none; }
.role-apply-help { margin: 0 0 12px; color: var(--muted); }
.role-apply-list { display: grid; gap: 8px; }
.role-apply-option { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.role-apply-option:has(input:checked) { border-color: var(--brand); background: var(--canvas); }

/* Purchasing payments split by paying account (frontend/modules/purchasing/payments.js). */
.payment-account-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.payment-account-tab { position: relative; display: grid; gap: 4px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--paper); text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.payment-account-tab:hover { border-color: var(--brand); }
.payment-account-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.payment-account-tab.is-active { border-color: var(--brand); background: var(--brand-pale); box-shadow: inset 0 -3px 0 var(--brand); }
.payment-account-tab__label { padding-right: 96px; font: 800 16px Manrope, sans-serif; }
.payment-account-tab.is-active .payment-account-tab__label { color: var(--brand-dark); }
.payment-account-tab__meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.payment-account-tab__action { position: absolute; top: 14px; right: 16px; padding: 3px 10px; border-radius: 999px; color: white; background: #ff9f43; font: 700 11px Manrope, sans-serif; white-space: nowrap; }
.payment-account-section { margin-top: 12px; }
.payment-account-section .table-wrap { border: 0; box-shadow: none; }
.record-link { padding: 0; white-space: nowrap; border: 0; color: var(--brand); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.record-link:hover, .record-link:focus-visible { text-decoration: underline; }
.payment-account-total { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 600px) {
  .payment-account-section .panel-head { flex-wrap: wrap; }
  .payment-account-tabs { grid-template-columns: 1fr; }
}

.list-pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 4px; flex-wrap: wrap; }
.list-pager__range { margin-right: auto; color: var(--muted); font-size: 13px; }
.list-pager__page { font-size: 13px; font-weight: 600; }
.supplier-send-guide { margin: 14px 0; font-size: 12px; }
.supplier-send-guide ol { margin: 6px 0 8px; padding-left: 18px; }
.supplier-send-guide p { margin: 0; }

/* Purchasing guide: flowchart + RACI */
.guide-panel { padding: 20px; margin-bottom: 20px; }
.guide-legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.guide-legend__note { color: var(--muted); font-size: 12px; margin-left: 6px; }
.guide-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.guide-column h2 { font-size: 16px; margin: 0 0 6px; }
.guide-column__hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.guide-flow { display: flex; flex-direction: column; align-items: stretch; }
.guide-role { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--role-ink); background: var(--role-bg); }
.guide-role--purchaser { --role-ink: #07677a; --role-bg: #dff7fa; --role-line: #087f95; }
.guide-role--manager { --role-ink: #6b3fa0; --role-bg: #efe7fb; --role-line: #8256c2; }
.guide-role--accountant { --role-ink: #8a5a00; --role-bg: #fff3d6; --role-line: #d89414; }
.guide-role--technician { --role-ink: #24703a; --role-bg: #e2f5e7; --role-line: #2f9150; }
.guide-role--system { --role-ink: #44546a; --role-bg: #eaeef3; --role-line: #8795a8; }
.guide-role--field { --role-ink: #a03a5c; --role-bg: #fbe6ee; --role-line: #c2507a; }
.guide-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.guide-tab { border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 7px 16px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.guide-tab.active { background: #087f95; border-color: #087f95; color: #fff; }
.guide-rules + .guide-rules { margin-top: 12px; }
.guide-rules ol { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.guide-node { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 12px 14px; }
.guide-node--step { border-left: 5px solid var(--role-line); }
.guide-node--step strong { display: block; font-size: 14px; margin: 6px 0 4px; }
.guide-node--step ul { margin: 0; padding-left: 18px; color: #3c4b5f; font-size: 12.5px; line-height: 1.55; }
.guide-node__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.guide-node__number { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; background: var(--role-line); color: #fff; font-size: 12px; font-weight: 700; }
.guide-node__screen { margin-left: auto; font-size: 11px; color: var(--muted); }
.guide-node__screen::before { content: "Màn hình: "; }
.guide-node--terminal { text-align: center; font-weight: 700; border-radius: 999px; background: var(--canvas); }
.guide-node--done { background: #e2f5e7; border-color: #b9e3c5; color: #24703a; }
.guide-arrow { position: relative; height: 30px; display: flex; justify-content: center; }
.guide-arrow::before { content: ""; width: 2px; background: #9aa9bb; height: 100%; }
.guide-arrow::after { content: ""; position: absolute; bottom: 0; border: 6px solid transparent; border-top: 8px solid #9aa9bb; border-bottom: 0; }
.guide-arrow span { position: absolute; left: calc(50% + 10px); top: 6px; font-size: 11px; font-weight: 700; color: #24703a; }
.guide-decision { margin: 0; border: 1px dashed var(--amber); border-radius: 12px; background: #fffaf0; padding: 10px 12px; }
.guide-decision__question { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.guide-decision__question::before { content: "◆ "; color: var(--amber); }
.guide-decision__branches { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.guide-branch { border-radius: 8px; padding: 7px 9px; font-size: 12px; line-height: 1.45; background: #fff; border: 1px solid var(--line); }
.guide-branch > b { display: block; margin-bottom: 2px; }
.guide-branch--go > b { color: #24703a; }
.guide-branch--warn > b { color: #8a5a00; }
.guide-branch--stop > b { color: var(--red); }
.guide-rules { margin-top: 18px; border-radius: 12px; background: var(--canvas); padding: 12px 14px; }
.guide-rules h3 { margin: 0 0 6px; font-size: 14px; }
.guide-rules ul { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.guide-raci-table td:not(:first-child), .guide-raci-table th:not(:first-child) { text-align: center; }
.guide-raci { display: inline-block; min-width: 34px; padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.guide-raci--a { background: #087f95; color: #fff; }
.guide-raci--r { background: #dff7fa; color: #07677a; }
.guide-raci--c { background: #fff3d6; color: #8a5a00; }
.guide-raci--i { background: #eaeef3; color: #44546a; }
.guide-raci--none { color: #b2bccb; }
@media (max-width: 960px) {
  .guide-columns { grid-template-columns: 1fr; }
}
.modal-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Shared PR / PO / payment dialog */
.record-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 24px; margin-bottom: 16px; padding: 14px 16px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.record-progress .crm-progress-track { margin: 0; }
.order-flow { margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 12px; background: white; }
.order-flow .crm-progress-track__steps li[title] { cursor: help; }
.order-flow__now { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; }
.order-flow__now > div { display: grid; align-content: start; gap: 4px; min-width: 0; }
.order-flow__now > div > span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.order-flow__now small { color: var(--muted); }
.order-flow__roles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.order-flow__done { margin: 12px 0 0; color: var(--brand-dark); font-size: 12px; font-weight: 700; }
.role-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--canvas); font-size: 11px; font-weight: 600; cursor: help; }
.role-chip small { min-width: 18px; padding: 0 5px; border-radius: 999px; background: white; color: var(--muted); font-size: 10px; text-align: center; }
.role-chip__people { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; display: none; min-width: 160px; max-width: 260px; padding: 8px 10px; border-radius: 8px; background: #1f2a30; color: white; font-size: 11px; font-weight: 500; line-height: 1.6; white-space: normal; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.role-chip:hover .role-chip__people, .role-chip:focus .role-chip__people { display: block; }
.next-step-mine { padding: 1px 8px; border-radius: 999px; color: white; background: var(--brand); font-size: 10px; font-weight: 700; }
.record-modal .pr-detail-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.record-modal .pr-info-grid p { margin: 2px 0 0; }
.record-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; width: 100%; }
.record-thumbs img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.record-delivery { margin-bottom: 14px; }
.record-delivery__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.record-delivery__items { margin: 8px 0; padding: 8px; background: var(--canvas); border-radius: 6px; }
.record-delivery__items div { display: flex; justify-content: space-between; padding: 3px 0; }
.pr-profit { margin-top: 14px; border-radius: 10px; background: var(--brand-pale); border-color: transparent; }
.pr-profit span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pr-profit p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.pr-profit.is-loss { background: #fdeaea; }
.pr-profit.is-loss > strong { color: var(--red); }
.record-modal .pr-detail-body > *, .record-modal .po-detail-columns > *, .record-progress > * { min-width: 0; }

/* Tabs splitting a record dialog's content (recordTabsHTML in app.js). */
.record-tabs { margin: 0; max-width: 100%; overflow-x: auto; background: white; }
.record-tabs .work-tab { white-space: nowrap; }
.record-tab-panel { display: grid; gap: 16px; min-width: 0; }
.record-tab-panel[hidden] { display: none; }

/* Search box above list tables (frontend/shared/table-search.js). */
.table-search { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; }
.table-search .field-control { max-width: 360px; }
.table-search-count { color: var(--muted); font-size: 12px; }
.table-search.is-empty .table-search-count { color: #b33d3d; }
