:root {
  --bg: #f3f5f7;
  --bg-strong: #e8edf1;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --surface-raised: #ffffff;
  --ink: #111827;
  --ink-soft: #26323d;
  --muted: #697782;
  --line: #d9e0e6;
  --line-strong: #b8c3cc;
  --accent: #333333;
  --accent-strong: #222222;
  --accent-soft: #f0f0f0;
  --supply: #b45b1b;
  --supply-soft: #fff4eb;
  --calc: #198038;
  --calc-soft: #edf8f0;
  --warning: #8a5b00;
  --warning-soft: #fff4ce;
  --danger: #da1e28;
  --danger-soft: #fff1f1;
  --sidebar: #101820;
  --sidebar-2: #18232d;
  --shadow-sm: 0 1px 2px rgba(18, 28, 36, .08);
  --shadow-md: 0 10px 28px rgba(18, 28, 36, .1);
  --radius: 8px;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f7f9fb 0, var(--bg) 220px),
    var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 700;
}

a:hover { color: var(--accent); }

.app-shell {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 98, 254, .08), transparent 38%),
    linear-gradient(180deg, #f7f9fb, #eef2f5);
}

.mobile-appbar,
.mobile-nav-backdrop { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 20px 14px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #fff;
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand,
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: #fff;
}

.brand:hover,
.mobile-brand:hover { color: #fff; }

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 7px;
  background: #f5f7f9;
  color: #101820;
  font-weight: 900;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.brand b,
.mobile-brand b {
  display: block;
  overflow: hidden;
  font-size: 17px;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand small,
.mobile-brand small {
  display: block;
  margin-top: 2px;
  color: #a9b5bf;
  font-size: 12px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #d7dee5;
  font-weight: 750;
}

.nav-link:hover {
  border-color: rgba(255,255,255,.1);
  background: rgba(255,255,255,.07);
  color: #fff;
}

.nav-link.is-active {
  border-color: rgba(255,255,255,.18);
  background: #f5f7f9;
  color: #101820;
}

.nav-link-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav-badge,
.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(16, 24, 32, .12);
  background: #e8edf3;
  color: #24313d;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.sidebar .nav-badge {
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.16);
  color: #f1f5f9;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}

.user-block {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.07);
}

.user-avatar,
.chat-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 7px;
  background: #dfe7ee;
  color: #18324a;
  font-weight: 900;
}

.user-block b {
  display: block;
  overflow: hidden;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-block span {
  display: block;
  color: #a9b5bf;
  font-size: 12px;
}

.app-main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 28px;
  background: rgba(243, 245, 247, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.topbar strong { font-size: 15px; }

.content {
  width: 100%;
  padding: 28px;
}

.auth-content { width: min(430px, 100%); }

.login-box {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.1;
}

.login-box p {
  margin: 0 0 22px;
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.page-head p {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
}

.page-head .request-owner,
.request-owner-inline {
  color: #3d4b56;
  font-size: 12px;
  font-weight: 700;
}

.page-head .request-owner {
  margin-top: 3px;
}

.request-owner-inline {
  display: block;
  margin-top: 3px;
  line-height: 1.25;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.request-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.request-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.request-head-actions .inline-form {
  display: inline-flex;
}

.request-head-actions button.danger {
  min-height: 34px;
  padding: 7px 11px;
  border-color: #ead3d5;
  background: transparent;
  color: #9f2932;
  font-size: 13px;
  box-shadow: none;
}

.request-head-actions button.danger:hover {
  border-color: #c94b55;
  background: #fff4f5;
  color: #8f1f28;
}

.request-head-actions button.danger:focus-visible {
  outline: 2px solid rgba(218, 30, 40, .18);
  outline-offset: 2px;
}

.supply-action-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--supply);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.supply-action-strip strong {
  display: block;
  color: var(--ink-soft);
  font-size: 15px;
}

.supply-action-strip form {
  display: flex;
  justify-content: flex-end;
  margin: 0;
}

.sales-action-strip {
  border-left-color: #2868a9;
}

.sales-action-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.supply-decision-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.supply-decision-buttons form {
  margin: 0;
}

.request-workflow-history {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.request-workflow-history .panel-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.request-workflow-history .panel-head h2 {
  margin: 0;
  font-size: 15px;
}

.request-workflow-list {
  display: grid;
}

.request-workflow-event {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr);
  gap: 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
}

.request-workflow-event:last-child {
  border-bottom: 0;
}

.request-workflow-event.is-supply_revision {
  border-left-color: #d97706;
}

.request-workflow-event.is-supply_refusal {
  border-left-color: #c93636;
}

.request-workflow-event.is-sales_return_supply {
  border-left-color: #167a4a;
}

.request-workflow-event div,
.request-workflow-event p {
  min-width: 0;
}

.request-workflow-event strong,
.request-workflow-event span {
  display: block;
}

.request-workflow-event span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.request-workflow-event p {
  margin: 0;
  white-space: pre-wrap;
}

.request-decision-dialog {
  width: min(620px, 100%);
}

.request-decision-dialog .modal-head h2 {
  margin-top: 3px;
  font-size: 20px;
}

.request-decision-form {
  display: grid;
  gap: 12px;
}

.request-decision-form label {
  display: grid;
  gap: 7px;
  font-weight: 750;
}

.request-decision-form textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
}

.request-decision-form small {
  color: var(--muted);
}

.request-revision-strip {
  border-left-color: #d97706;
}

.request-sales-comment {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.request-sales-comment p {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  white-space: pre-wrap;
}

.request-sales-comment-author {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.supply-assign-panel .panel-head {
  margin-bottom: 8px;
}

.supply-assign-form {
  display: grid;
  gap: 8px;
}

.supply-assign-toolbar {
  display: flex;
  justify-content: flex-end;
}

.supply-assign-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.supply-assign-city {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, var(--supply) 6%);
  overflow: hidden;
}

.supply-assign-city-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, var(--supply) 14%);
}

.supply-assign-city-head strong {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.2;
}

.supply-assign-city-head small {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
  background: var(--surface);
}

.supply-assign-list {
  display: grid;
  gap: 1px;
}

.supply-assign-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 9px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.supply-assign-option:hover {
  background: color-mix(in srgb, var(--surface) 88%, var(--supply) 12%);
}

.supply-assign-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.supply-assign-check {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--supply) 30%);
  border-radius: 5px;
  background: var(--surface);
}

.supply-assign-option input:checked + .supply-assign-check {
  border-color: var(--supply);
  background: var(--supply);
}

.supply-assign-option input:checked + .supply-assign-check::after {
  content: "";
  width: 8px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg) translate(1px, -1px);
}

.supply-assign-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.supply-assign-copy strong,
.supply-assign-copy small {
  overflow-wrap: anywhere;
}

.supply-assign-copy strong {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.15;
}

.supply-assign-copy small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.15;
}

.supply-assign-submit {
  min-height: 34px;
  padding: 8px 14px;
}

.panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.panel p:first-child { margin-top: 0; }
.muted { color: var(--muted); margin: 4px 0 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics div {
  display: grid;
  gap: 8px;
  min-height: 94px;
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metrics strong {
  align-self: end;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.calendar-widget {
  margin-bottom: 18px;
}

.calendar-tabs,
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.calendar-tabs .is-active,
.report-tabs .is-active {
  background: #333;
  color: #fff;
}

.calendar-board {
  min-height: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(248, 250, 252, .96), var(--surface));
}

.calendar-day-schedule {
  display: grid;
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.calendar-hour-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.calendar-hour-row:last-child {
  border-bottom: 0;
}

.calendar-hour-row > time {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-hour-lane {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 6px 8px;
}

.calendar-hour-empty {
  display: block;
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(15, 98, 254, .12), transparent);
}

.calendar-event-chip,
.calendar-event-pill {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(51, 51, 51, .12);
  border-radius: 8px;
  background: #333;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.calendar-event-chip {
  gap: 8px;
  padding: 6px 9px;
}

.calendar-event-chip strong,
.calendar-event-pill time {
  color: rgba(255,255,255,.72);
  font-size: 11px;
}

.calendar-event-chip span,
.calendar-event-pill span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calendar-event-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.calendar-event-meta {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, .68);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.calendar-week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.calendar-week-day {
  display: grid;
  grid-template-rows: auto minmax(130px, 1fr);
  min-width: 110px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.calendar-week-day header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.calendar-week-day header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.calendar-week-day header strong {
  color: var(--ink);
  font-size: 13px;
}

.calendar-week-day.is-today {
  border-color: #333;
  box-shadow: inset 0 0 0 1px #333;
}

.calendar-day-events {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 8px;
}

.calendar-event-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  padding: 6px 7px;
}

.calendar-muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr));
  gap: 6px;
  overflow-x: auto;
}

.calendar-month-label {
  padding: 0 4px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.calendar-month-day {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 78px;
  min-width: 86px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.calendar-month-day > time {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.calendar-month-day.is-today > time {
  background: #333;
  color: #fff;
}

.calendar-month-day.is-muted {
  opacity: .45;
}

.calendar-month-events {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.calendar-month-events span,
.calendar-month-events b {
  overflow: hidden;
  padding: 3px 5px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 13, 18, .45);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: min(520px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
}

.calendar-add-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.autosave-status {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.compact-metrics {
  margin: 14px 0;
}

body.theme-dark {
  --bg: #111315;
  --bg-strong: #181b1f;
  --surface: #1c2024;
  --surface-soft: #22272d;
  --surface-raised: #242a30;
  --ink: #f3f5f7;
  --ink-soft: #d7dde4;
  --muted: #a9b3bd;
  --line: #3a424b;
  --line-strong: #505a64;
  --supply-soft: #3a2a1f;
  --warning-soft: #3a321c;
  --danger-soft: #3a2023;
  --sidebar: #0d0f11;
  --sidebar-2: #15181c;
  background: var(--bg);
}

body.theme-dark a {
  color: #d8dee4;
}

body.theme-dark a:hover {
  color: #fff;
}

body.theme-dark .nav-link.is-active,
body.theme-dark .nav-link.is-active:hover {
  border-color: #4b5560;
  background: #e8edf3;
  color: #111820;
}

body.theme-dark .nav-link.is-active .nav-link-text,
body.theme-dark .nav-link.is-active:hover .nav-link-text,
body.theme-dark .nav-link.is-active .nav-badge,
body.theme-dark .nav-link.is-active:hover .nav-badge {
  color: #111820;
}

body.theme-dark .sidebar .nav-badge {
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.15);
  color: #f3f5f7;
}

body.theme-dark .nav-link.is-active .nav-badge,
body.theme-dark .nav-link.is-active:hover .nav-badge {
  border-color: rgba(17, 24, 32, .14);
  background: rgba(17, 24, 32, .1);
  color: #111820;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #15191d;
  color: var(--ink);
  border-color: var(--line-strong);
}

body.theme-dark th,
body.theme-dark tbody tr:hover td,
body.theme-dark .excel-formula-bar,
body.theme-dark .formula-name-box,
body.theme-dark .formula-fx,
body.theme-dark .zoom-controls button,
body.theme-dark .notification-toast,
body.theme-dark .chat-list-panel,
body.theme-dark .chat-list-item,
body.theme-dark .chat-quick-card,
body.theme-dark .incoming-call-card,
body.theme-dark .chat-context-menu,
body.theme-dark .compose-voice-preview,
body.theme-dark .compose-file-preview-card {
  background: var(--surface-raised);
  color: var(--ink);
}

body.theme-dark .excel-scroll,
body.theme-dark .excel-table,
body.theme-dark .excel-table textarea,
body.theme-dark .excel-table input[type="date"],
body.theme-dark .readonly-cell,
body.theme-dark .excel-table td.section-sales,
body.theme-dark .excel-table td.section-supply,
body.theme-dark .excel-table td.section-sales_calc,
body.theme-dark .excel-table td.section-template {
  background: #1b2026;
  color: var(--ink);
}

body.theme-dark .excel-table tbody tr.excel-row-sales td.section-sales,
body.theme-dark .section-sales {
  background: #1f3145;
}

body.theme-dark .excel-table tbody tr.excel-row-supply td.section-supply,
body.theme-dark .section-supply {
  background: #3a2a1f;
}

body.theme-dark .section-sales_calc {
  background: #1f3a2b;
}

body.theme-dark .section-template {
  background: #232a32;
}

body.theme-dark .chat-panel,
body.theme-dark .chat-panel .panel-head,
body.theme-dark .call-incoming-list,
body.theme-dark .chat-compose {
  background: #171b20;
  color: var(--ink);
}

body.theme-dark .chat-bubble,
body.theme-dark .chat-compose textarea,
body.theme-dark .chat-action-row select,
body.theme-dark .chat-action-row .chat-icon-button {
  background: #242a30;
  color: var(--ink);
}

body.theme-dark .chat-message.is-own .chat-bubble {
  background: #20362b;
}

body.theme-dark .chat-bubble::before {
  border-top-color: #242a30;
}

body.theme-dark .chat-message.is-own .chat-bubble::before {
  border-top-color: #20362b;
}

body.theme-dark .chat-text,
body.theme-dark .incoming-call-card span,
body.theme-dark .chat-context-menu button,
body.theme-dark .chat-list-item {
  color: var(--ink);
}

.grid-two,
.request-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.request-activity-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.request-workspace {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  align-items: stretch;
}

.sales-zone { border-top: 4px solid var(--accent); }
.supply-zone { border-top: 4px solid var(--supply); }

.sales-zone h2::after,
.supply-zone h2::after {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.sales-zone h2::after {
  content: "sales";
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.supply-zone h2::after {
  content: "supply";
  color: #7b3f20;
  background: var(--supply-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.panel > table,
.table-wrap table { min-width: 720px; }

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #465565;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  background: #f1f4f7;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }

tr.clickable-row {
  cursor: pointer;
}

tr.clickable-row:focus {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

tr.clickable-row:hover td,
tr.clickable-row:focus td {
  background: #eef3f7;
}

body.theme-dark tr.clickable-row:hover td,
body.theme-dark tr.clickable-row:focus td,
body.theme-dark tr.clickable-row:active td {
  background: #26313a;
  color: var(--ink);
}

body.theme-dark tr.clickable-row:focus {
  outline-color: #94a3b8;
}

.excel-panel {
  margin-bottom: 18px;
  padding: 14px;
}

.excel-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  max-height: 72vh;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.excel-table {
  --excel-zoom: 1;
  min-width: max-content;
  table-layout: fixed;
  font-size: calc(12px * var(--excel-zoom));
  border-collapse: separate;
  border-spacing: 0;
}

.excel-table th,
.excel-table td {
  border-right: 1px solid #c8d0d8;
  border-bottom: 1px solid #c8d0d8;
  padding: 0;
  vertical-align: top;
}

.excel-table tbody tr {
  height: calc(var(--excel-row-height, 88px) * var(--excel-zoom));
}

.excel-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: calc(58px * var(--excel-zoom));
  padding: calc(8px * var(--excel-zoom));
  color: #20303f;
  text-align: center;
  box-shadow: 0 1px 0 #c8d0d8;
}

.excel-table .row-num {
  position: sticky;
  left: 0;
  z-index: 5;
  width: calc(44px * var(--excel-zoom));
  min-width: calc(44px * var(--excel-zoom));
  padding: calc(10px * var(--excel-zoom)) calc(4px * var(--excel-zoom));
  background: #edf1f5;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.row-num-col { width: calc(44px * var(--excel-zoom)); }

.excel-table th[data-column-header],
.excel-table tbody .row-num {
  overflow: visible;
}

.excel-col-resize {
  position: absolute;
  top: 0;
  right: calc(-4px * var(--excel-zoom));
  z-index: 8;
  width: calc(8px * var(--excel-zoom));
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.excel-col-resize::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transform: translateX(-50%);
}

.excel-row-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  height: calc(10px * var(--excel-zoom));
  cursor: row-resize;
  touch-action: none;
}

.excel-row-resize::after {
  content: "";
  position: absolute;
  right: 18%;
  bottom: 50%;
  left: 18%;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  transform: translateY(50%);
}

.excel-col-resize:hover::after,
.excel-col-resize:active::after,
body.is-table-col-resizing .excel-col-resize::after,
.excel-row-resize:hover::after,
.excel-row-resize:active::after,
body.is-table-row-resizing .excel-row-resize::after {
  background: #0f62fe;
}

.excel-letters th {
  top: 0;
  height: calc(28px * var(--excel-zoom));
  padding: calc(5px * var(--excel-zoom)) calc(6px * var(--excel-zoom));
  background: #edf1f5;
  color: #526170;
  font-size: calc(11px * var(--excel-zoom));
  cursor: pointer;
}

.excel-sections th {
  top: calc(28px * var(--excel-zoom));
  height: calc(34px * var(--excel-zoom));
  padding: calc(8px * var(--excel-zoom));
  color: #172331;
  font-size: calc(13px * var(--excel-zoom));
  font-weight: 850;
  text-transform: none;
}

.excel-table .corner-cell { z-index: 7; }
.excel-table tbody .row-num { background: #f5f7f9; }

.excel-table tbody tr.excel-row-sales_header .readonly-cell,
.excel-table tbody tr.excel-row-supply_header .readonly-cell {
  min-height: calc(52px * var(--excel-zoom));
  color: #152433;
  font-weight: 850;
  text-align: center;
}

.excel-table tbody tr.excel-row-title {
  display: none;
}

.excel-table tbody tr.excel-row-sales_header .readonly-cell {
  background: #d7e8ff;
  box-shadow: inset 0 3px 0 #1d4ed8;
}

.excel-table tbody tr.excel-row-supply_header .readonly-cell {
  background: #ffe0c2;
  box-shadow: inset 0 3px 0 #c2410c;
}

.excel-table textarea,
.excel-table input[type="date"] {
  min-height: calc(var(--excel-row-height, 88px) * var(--excel-zoom));
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: calc(10px * var(--excel-zoom));
  line-height: 1.35;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: calc(12px * var(--excel-zoom));
  text-align: center;
}

.excel-table textarea {
  resize: vertical;
}

.excel-table input[type="date"] {
  width: 100%;
  height: 100%;
  color: #2d3a45;
  outline: none;
}

.excel-table input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.excel-table td {
  text-align: center;
  vertical-align: middle;
}

.readonly-cell {
  min-height: calc(var(--excel-row-height, 88px) * var(--excel-zoom));
  padding: calc(10px * var(--excel-zoom));
  white-space: pre-wrap;
  color: #2d3a45;
  background: rgba(246,248,250,.78);
  line-height: 1.35;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.section-sales { background: #d7e8ff; }
.section-supply { background: #ffe0c2; }
.section-sales_calc { background: #d8f3dc; }
.section-template { background: #e8edf3; }
.excel-table td.section-sales { background: #eef6ff; }
.excel-table td.section-supply { background: #fff2e4; }
.excel-table td.section-sales_calc { background: #edf9ef; }
.excel-table td.section-template { background: #f6f8fb; }

.excel-table tbody tr.excel-row-sales td.section-sales {
  box-shadow: inset 0 0 0 1px rgba(29,78,216,.18);
}

.excel-table tbody tr.excel-row-supply td.section-supply {
  box-shadow: inset 0 0 0 1px rgba(194,65,12,.2);
}

.excel-table tbody tr.excel-row-summary .readonly-cell {
  background: #e9eef5;
  color: #172331;
  font-weight: 850;
}

.excel-table td.is-formula .readonly-cell {
  background: #edf8f0;
  color: #1d522d;
  font-weight: 780;
  text-align: right;
}

.excel-table th.is-selected-column,
.excel-table td.is-selected-column {
  box-shadow: inset 0 0 0 2px rgba(15,98,254,.42);
}

.excel-table th.is-selected-column {
  background: #dceaff;
  color: #0b3b82;
}

.excel-table td.is-selected-column { background: #f1f7ff; }

.excel-table td.is-selected-column textarea,
.excel-table td.is-selected-column .readonly-cell {
  background: rgba(241,247,255,.92);
}

.excel-table td.is-selected-range {
  background: #dceaff;
  box-shadow: inset 0 0 0 1px rgba(15,98,254,.5);
}

.excel-table td.is-selected-range textarea,
.excel-table td.is-selected-range .readonly-cell {
  background: rgba(220,234,255,.95);
}

.excel-table td.is-selection-anchor {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.excel-table th.section-sales { border-top: 4px solid #1d4ed8; }
.excel-table th.section-supply { border-top: 4px solid #c2410c; }
.excel-table th.section-sales_calc { border-top: 4px solid #15803d; }

.formula-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  margin-left: 5px;
  border-radius: 999px;
  background: #d7f0de;
  color: #1d522d;
  font-size: 10px;
  font-weight: 900;
}

.excel-row-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  margin: -2px 0 10px;
}

.excel-row-tools button {
  width: auto;
  min-height: 36px;
  padding: 8px 12px;
}

.excel-context-menu {
  position: fixed;
  z-index: 1800;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.excel-context-menu[hidden] {
  display: none;
}

.excel-context-menu button {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.excel-context-menu button:hover {
  background: var(--surface-soft);
}

.excel-table tbody tr.is-context-row .row-num,
.excel-table tbody tr.is-context-row td {
  background: #e7f0ff;
}

body.theme-dark .excel-table tbody tr.is-context-row .row-num,
body.theme-dark .excel-table tbody tr.is-context-row td {
  background: #25364f;
}

.excel-table td.is-required-missing {
  position: relative;
  background: #fff8f8 !important;
  box-shadow: inset 0 0 0 2px var(--danger), inset 4px 0 0 var(--danger) !important;
}

.excel-table td.is-required-missing textarea,
.excel-table td.is-required-missing input[type="date"] {
  color: #111827;
  background: #fff8f8;
  caret-color: #111827;
}

.excel-table td.is-required-missing textarea::placeholder,
.excel-table td.is-required-missing input[type="date"]::placeholder {
  color: #6b7280;
}

.excel-formula-bar {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 42px minmax(260px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: -2px 0 12px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #f7f9fb;
}

.formula-name-box,
.formula-fx {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.formula-name-box {
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  color: #1f2d38;
  font-weight: 850;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.formula-fx {
  justify-content: center;
  color: var(--accent-strong);
  font-style: italic;
  font-weight: 900;
}

.excel-formula-bar input,
.formula-field input {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
}

.formula-panel { display: none; }

.excel-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.excel-summary div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.excel-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.excel-summary strong {
  display: block;
  margin-top: 3px;
  color: #0b2744;
  font-size: 17px;
}

.table-legend,
.excel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-legend {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.table-legend b {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.lg-sales { background: var(--accent); }
.lg-supply { background: var(--supply); }
.lg-calc { background: var(--calc); }

.excel-tools {
  justify-content: flex-end;
  gap: 14px;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid #b8c3cc;
  border-radius: var(--radius);
  background: #f3f6f9;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.7);
}

.zoom-controls button {
  min-width: 34px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #b8c3cc;
  background: #ffffff;
  color: #1f2937;
  font-weight: 900;
}

.zoom-controls button:hover,
.zoom-controls button:focus-visible {
  border-color: #0f62fe;
  background: #e8f0ff;
  color: #0f62fe;
  outline: none;
}

.zoom-controls output {
  min-width: 48px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15,98,254,.18);
  border-color: var(--accent);
}

.has-required-field input[required],
.has-required-field select[required],
.has-required-field textarea[required],
.has-required-marker {
  border-left-color: var(--line-strong);
  box-shadow: inset 2px 0 0 rgba(51, 51, 51, .18);
}

.required-mark {
  display: none;
}

.field-label-text {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
}

.required-field-note {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: #44525f;
  font-size: 13px;
  font-weight: 700;
}

.form,
.compact {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide { grid-column: 1 / -1; }

.organization-transfer {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.organization-transfer h3,
.organization-transfer p {
  margin: 0;
}

.organization-transfer-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.organization-transfer-form button {
  min-height: 42px;
}

body.theme-dark .organization-transfer-form label {
  color: var(--ink);
}

@media (max-width: 600px) {
  .organization-transfer-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.organization-picker {
  position: relative;
}

.organization-picker-results {
  position: absolute;
  top: calc(100% - 2px);
  right: 0;
  left: 0;
  z-index: 30;
  display: grid;
  max-height: 310px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(13, 19, 26, .18);
}

.organization-picker-results[hidden] {
  display: none;
}

.organization-picker-option {
  justify-content: flex-start;
  display: grid;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.organization-picker-option strong,
.organization-picker-option small {
  overflow: hidden;
  max-width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.organization-picker-option strong {
  font-size: 13px;
  line-height: 1.25;
}

.organization-picker-option small {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.organization-picker-option:hover,
.organization-picker-option.is-active {
  background: var(--surface-soft);
  color: var(--ink);
}

.organization-picker-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.contact-builder {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.contact-builder .panel-head {
  margin-bottom: 0;
}

.contact-draft {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.contact-draft button {
  align-self: end;
  min-width: 150px;
}

.contact-list {
  display: grid;
  gap: 8px;
}

.contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.contact-row-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.contact-row-info strong,
.contact-row-info span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.contact-row-info span {
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.table-actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #333;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

button:hover,
.button:hover {
  border-color: #222;
  background: #222;
  color: #fff;
}

.button.is-disabled {
  opacity: .48;
  cursor: default;
  pointer-events: none;
}

.primary,
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary:hover,
button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

.ghost {
  background: transparent;
  color: var(--ink);
}

.ghost:hover {
  color: #fff;
}

button.danger,
.button.danger {
  border-color: #f2b8bd;
  background: var(--danger-soft);
  color: var(--danger);
}

button.danger:hover,
.button.danger:hover {
  border-color: var(--danger);
  background: #ffe3e5;
  color: var(--danger);
}

.compact-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.request-list-filters {
  grid-template-columns: minmax(240px, 1fr) minmax(260px, .7fr) auto auto;
}

.request-list-filters.has-sales-filter {
  grid-template-columns: minmax(220px, 1fr) minmax(200px, .55fr) minmax(230px, .65fr) auto auto;
}

.request-list-filters label,
.request-list-filters select {
  width: 100%;
}

.chat-readonly-note {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.request-list-panel {
  overflow-x: auto;
}

.request-list-panel > table {
  min-width: 760px;
  table-layout: fixed;
}

.request-list-panel th:nth-child(1) { width: 13%; }
.request-list-panel th:nth-child(2) { width: 25%; }
.request-list-panel th:nth-child(3) { width: 14%; }
.request-list-panel th:nth-child(4) { width: 18%; }
.request-list-panel th:nth-child(5) { width: 25%; }
.request-list-panel th:nth-child(6) { width: 5%; }

.request-list-sort {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.request-list-sort:hover,
.request-list-sort:focus-visible {
  color: var(--accent-strong);
}

.request-list-sort-icon {
  display: inline-grid;
  flex: 0 0 22px;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.request-list-sort.is-active .request-list-sort-icon {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

.request-list-panel td {
  overflow-wrap: anywhere;
}

.organization-search {
  grid-template-columns: minmax(220px, 1fr) minmax(140px, auto) minmax(140px, auto) minmax(180px, auto) minmax(190px, auto) auto;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
}

.pagination-bar-bottom {
  justify-content: flex-end;
  margin: 12px 0 0;
}

.pagination-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pagination-button,
.pagination-current {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.pagination-button:hover {
  border-color: #333;
  background: #333;
  color: #fff;
}

.pagination-button.is-disabled {
  opacity: .48;
  pointer-events: none;
}

.pagination-current {
  background: var(--surface-soft);
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2f5;
  color: #30404f;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status.muted-status {
  border-color: #d7dde3;
  background: #f4f6f8;
  color: #7b8794;
}

.status.waiting {
  border-color: #cbd4dd;
  background: #eef2f5;
  color: #30404f;
}

.status.in_work {
  border-color: #ecd397;
  background: var(--warning-soft);
  color: var(--warning);
}

.status.done {
  border-color: #abd9b8;
  background: #e7f6eb;
  color: #19632e;
}

.status.awaiting_sales {
  border-color: #a8c8e8;
  background: #edf6ff;
  color: #245f98;
}

.status.needs_sales_revision {
  border-color: color-mix(in srgb, #d97706 46%, var(--line));
  background: color-mix(in srgb, #d97706 13%, var(--surface));
  color: color-mix(in srgb, #8a4800 82%, var(--ink));
}

.status.refused {
  border-color: color-mix(in srgb, #c93636 50%, var(--line));
  background: color-mix(in srgb, #c93636 13%, var(--surface));
  color: color-mix(in srgb, #991f1f 82%, var(--ink));
}

.notification-history-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.notification-history-list {
  display: grid;
  gap: 8px;
}

.notification-history-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.notification-history-item.is-unread {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}

.notification-history-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.notification-history-item.is-unread .notification-history-state {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.notification-history-copy {
  min-width: 0;
}

.notification-history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.notification-history-head time,
.notification-history-copy small {
  color: var(--muted);
  font-size: 12px;
}

.notification-history-copy p {
  margin: 5px 0;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.notification-history-copy small {
  display: block;
}

.flashes { margin-bottom: 16px; }

.flash {
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.flash.danger {
  border-color: #f2b8bd;
  background: var(--danger-soft);
  color: var(--danger);
}

.flash.warning {
  border-color: #ecd397;
  background: var(--warning-soft);
  color: var(--warning);
}

.flash.success {
  border-color: #abd9b8;
  background: #e7f6eb;
  color: #19632e;
}

.notification-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  pointer-events: none;
}

.notification-toast {
  pointer-events: auto;
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 14px 38px rgba(17, 24, 39, .18);
  animation: notification-in .16s ease-out;
}

.notification-bulk-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(17, 24, 39, .14);
}

.notification-bulk-actions[hidden] {
  display: none;
}

.notification-bulk-actions span {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.notification-bulk-actions .button {
  width: auto;
  min-height: 32px;
  margin-left: auto;
  padding: 6px 10px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .notification-stack {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - 16px);
    scrollbar-gutter: auto;
  }
}

body.theme-dark .notification-bulk-actions {
  border-color: #64748b;
  background: #101820;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .48);
}

body.theme-dark .notification-bulk-actions span {
  color: #f8fafc;
}

.notification-toast.request_taken,
.notification-toast.request_done {
  border-left-color: var(--supply);
}

.notification-toast.general_message {
  border-left-color: var(--calc);
}

.notification-toast.warning,
.notification-toast.local-notice.warning {
  border-left-color: var(--warning);
}

.notification-toast.danger,
.notification-toast.local-notice.danger {
  border-left-color: var(--danger);
}

.notification-toast.success,
.notification-toast.local-notice.success {
  border-left-color: #19632e;
}

.notification-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.notification-head strong {
  color: #1d2a35;
  font-size: 14px;
}

.notification-head time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.notification-close {
  width: auto;
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.notification-toast p {
  margin: 7px 0 12px;
  color: #33414f;
}

body.theme-dark .notification-toast {
  border-color: #64748b;
  background: #101820;
  color: #f8fafc;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .58), 0 0 0 1px rgba(255, 255, 255, .05);
}

body.theme-dark .notification-head strong {
  color: #ffffff;
  font-size: 15px;
  font-weight: 850;
}

body.theme-dark .notification-head time {
  color: #cbd5e1;
}

body.theme-dark .notification-toast p {
  color: #eef2f7;
  font-size: 14px;
  font-weight: 650;
}

body.theme-dark .notification-close {
  border-color: #94a3b8;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 850;
}

body.theme-dark .notification-close:hover {
  border-color: #ffffff;
  background: #ffffff;
  color: #020617;
}

body.theme-dark .notification-toast.warning,
body.theme-dark .notification-toast.local-notice.warning {
  border-left-color: #fbbf24;
}

body.theme-dark .notification-toast.danger,
body.theme-dark .notification-toast.local-notice.danger {
  border-left-color: #fb7185;
}

body.theme-dark .notification-toast.success,
body.theme-dark .notification-toast.local-notice.success,
body.theme-dark .notification-toast.request_done {
  border-left-color: #4ade80;
}

body.theme-dark .notification-toast.request_taken {
  border-left-color: #fb923c;
}

body.theme-dark .notification-toast.general_message {
  border-left-color: #38bdf8;
}

.notification-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.notification-actions .button,
.notification-actions button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
}

@keyframes notification-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check input { width: auto; }

.doc {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.doc:last-child { border-bottom: 0; }
.doc h2 { margin: 0 0 6px; }
.doc p { color: #354350; }
.doc small { color: var(--muted); }

.doc-body {
  white-space: pre-wrap;
  color: #354350;
  line-height: 1.55;
}

.doc-body a {
  color: #125d8f;
  font-weight: 700;
}

.doc-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 8px;
}

.doc-file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #c8d5de;
  border-radius: 8px;
  background: #f7fafc;
  color: #1d2b36;
  text-decoration: none;
}

.doc-file small {
  color: #125d8f;
  font-weight: 700;
}

.doc-edit {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.doc-edit summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 850;
}

.doc-edit form {
  display: grid;
  gap: 8px;
  max-width: 680px;
}

.doc-edit form.compact input,
.doc-edit form.compact textarea {
  width: 100%;
}

.doc-edit form.compact textarea {
  min-height: 92px;
}

.doc-edit button {
  width: fit-content;
}

.files-panel,
.chat-panel {
  width: 100%;
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.file-item,
.file-empty {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.file-item:hover {
  border-color: var(--accent);
  background: #f3f7ff;
}

.file-item span {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-item small,
.file-empty {
  color: var(--muted);
  font-size: 12px;
}

.file-drop-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.file-drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 18px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f7f9fb;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.file-drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-drop-zone strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-drop-zone span {
  color: var(--muted);
  font-size: 13px;
}

.file-drop-form button {
  align-self: stretch;
  min-width: 150px;
}

.file-drop-form.is-dragging .file-drop-zone {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(15,98,254,.25);
}

body.theme-dark .file-drop-zone,
body.theme-dark .file-drop-zone.has-required-field {
  border-color: #505a64;
  background: #1a1f24;
  color: var(--muted);
}

body.theme-dark .file-drop-zone strong,
body.theme-dark .file-drop-zone.has-required-field strong {
  color: var(--ink);
}

body.theme-dark .file-drop-form.is-dragging .file-drop-zone {
  border-color: #8ab4ff;
  background: #202b39;
  box-shadow: inset 0 0 0 1px rgba(138, 180, 255, .28);
}

.chat-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: calc(100vh - 118px);
  overflow: hidden;
  border: 1px solid #d1d7db;
  border-radius: var(--radius);
  background: #f0f2f5;
  box-shadow: var(--shadow-sm);
}

.chat-list-panel {
  position: sticky;
  top: 64px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  max-height: calc(100vh - 82px);
  height: 100%;
  overflow: hidden;
  margin: 0;
  border: 0;
  border-right: 1px solid #d1d7db;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  align-content: stretch;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #efeae2;
  box-shadow: none;
}

.chat-panel .panel-head {
  grid-row: 1;
  min-height: 64px;
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid #d1d7db;
  background: #f0f2f5;
}

.chat-panel .panel-head h2 {
  font-size: 17px;
}

.chat-panel > .call-incoming-list {
  grid-row: 2;
}

.chat-panel > .call-dock {
  grid-row: 3;
}

.chat-panel > .chat-thread {
  grid-row: 4;
  align-self: stretch;
}

.chat-panel > .chat-compose {
  grid-row: 5;
}

.chat-action-stack {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.chat-quick-card {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid #dce3e8;
  border-radius: 8px;
  background: #f7fafc;
}

.chat-action-label {
  color: #54656f;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.chat-action-row {
  display: grid;
  gap: 7px;
  align-items: center;
}

.chat-action-row.is-call {
  grid-template-columns: minmax(0, 1fr) 40px 40px;
}

.chat-action-row.is-dialog {
  grid-template-columns: minmax(0, 1fr) 40px;
}

.chat-action-row select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border-radius: 999px;
  background: #fff;
}

.chat-action-row .chat-icon-button {
  background: #fff;
  color: #075e54;
}

.call-incoming-list {
  display: grid;
  gap: 8px;
  padding: 0 14px;
  background: #f0f2f5;
}

.incoming-call-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.incoming-call-card span {
  color: #111b21;
  font-weight: 750;
}

.incoming-call-card button {
  width: auto;
  min-height: 32px;
  padding: 6px 10px;
  border-color: #00a884;
  background: #00a884;
  color: #fff;
}

.call-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #d1d7db;
  background: #e7ffdb;
}

.call-dock[hidden] {
  display: none;
}

.call-dock strong {
  display: block;
  color: #111b21;
}

.call-dock p {
  margin: 2px 0 0;
  color: #54656f;
  font-size: 12px;
}

.call-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.call-participant {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--avatar-bg, #d9fdd3);
  color: var(--avatar-fg, #075e54);
  font-size: 12px;
  font-weight: 900;
}

.call-audio-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.call-remote {
  display: grid;
  gap: 2px;
  min-width: 180px;
}

.call-remote span {
  color: #54656f;
  font-size: 11px;
  font-weight: 800;
}

.call-remote audio {
  width: 180px;
  height: 32px;
}

.call-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.call-controls button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
}

.chat-create-form {
  display: grid;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.chat-start-form {
  margin: 0;
}

.chat-user-checks {
  display: grid;
  gap: 6px;
  max-height: 104px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 0;
  overflow-y: auto;
  margin: 0 -14px -14px;
  padding: 0;
}

.chat-list-item {
  display: grid;
  gap: 4px;
  min-height: 60px;
  padding: 9px 14px 8px;
  border: 0;
  border-bottom: 1px solid #edf0f2;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.chat-list-item:hover,
.chat-list-item.is-active {
  background: #f0f2f5;
  color: var(--ink);
}

.chat-list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.chat-list-title strong,
.chat-list-subtitle,
.chat-list-last {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-list-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.chat-list-position {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

.chat-list-last {
  color: #31414f;
  font-size: 12px;
  font-weight: 650;
}

.chat-list-item time {
  color: var(--muted);
  font-size: 11px;
}

.chat-thread {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 18px 48px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 18px 18px, rgba(0,0,0,.035) 1.4px, transparent 1.6px) 0 0 / 34px 34px,
    #efeae2;
}

.chat-panel .chat-thread {
  min-height: 0;
  max-height: none;
}

.chat-message {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 9px;
  align-items: end;
  max-width: min(78%, 620px);
}

.chat-message.is-own {
  grid-template-columns: minmax(0, 1fr) 36px;
  justify-self: end;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--avatar-bg, #d9fdd3);
  color: var(--avatar-fg, #075e54);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.38);
}

.chat-avatar.avatar-color-0 { --avatar-bg: #d9fdd3; --avatar-fg: #075e54; }
.chat-avatar.avatar-color-1 { --avatar-bg: #cfe9ff; --avatar-fg: #075985; }
.chat-avatar.avatar-color-2 { --avatar-bg: #ffe0b2; --avatar-fg: #9a3412; }
.chat-avatar.avatar-color-3 { --avatar-bg: #f5d0fe; --avatar-fg: #86198f; }
.chat-avatar.avatar-color-4 { --avatar-bg: #bbf7d0; --avatar-fg: #166534; }
.chat-avatar.avatar-color-5 { --avatar-bg: #fecdd3; --avatar-fg: #9f1239; }
.chat-avatar.avatar-color-6 { --avatar-bg: #ddd6fe; --avatar-fg: #5b21b6; }
.chat-avatar.avatar-color-7 { --avatar-bg: #bae6fd; --avatar-fg: #0c4a6e; }
.chat-avatar.avatar-color-8 { --avatar-bg: #fde68a; --avatar-fg: #854d0e; }
.chat-avatar.avatar-color-9 { --avatar-bg: #ccfbf1; --avatar-fg: #115e59; }
.chat-avatar.avatar-color-10 { --avatar-bg: #e9d5ff; --avatar-fg: #6b21a8; }
.chat-avatar.avatar-color-11 { --avatar-bg: #fed7aa; --avatar-fg: #7c2d12; }

.chat-bubble {
  position: relative;
  padding: 7px 9px 5px;
  border: 0;
  border-radius: 0 8px 8px 8px;
  background: #fff;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
}

.chat-message.is-own .chat-bubble {
  border-radius: 8px 0 8px 8px;
  background: #d9fdd3;
}

.chat-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #fff;
  border-left: 8px solid transparent;
}

.chat-message.is-own .chat-bubble::before {
  left: auto;
  right: -8px;
  border-top-color: #d9fdd3;
  border-left: 0;
  border-right: 8px solid transparent;
}

.chat-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.chat-meta strong {
  color: #075e54;
  font-size: 12px;
}

.chat-meta span { color: #667781; font-size: 11px; }
.chat-text { white-space: pre-wrap; color: #111b21; }

.chat-edit-form {
  margin-top: 6px;
}

.chat-edit-form textarea {
  min-height: 72px;
}

.chat-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chat-edit-actions .primary {
  min-height: 32px;
}

.chat-edit-actions button {
  min-height: 32px;
}

.chat-context-menu {
  position: fixed;
  z-index: 1200;
  display: grid;
  min-width: 174px;
  padding: 6px;
  border: 1px solid #d1d7db;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(11, 20, 26, .18);
}

.chat-context-menu[hidden] {
  display: none;
}

.chat-context-menu button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #111b21;
  font-size: 13px;
  text-align: left;
}

.chat-context-menu button:hover {
  background: #f0f2f5;
}

.chat-context-menu button.danger {
  color: #8a2334;
}

.chat-context-menu button.danger:hover {
  background: #fff0f3;
}

.chat-edited {
  margin-top: 4px;
  color: #667781;
  font-size: 11px;
}

.chat-bubble time {
  display: block;
  margin-top: 3px;
  color: #667781;
  font-size: 11px;
  text-align: right;
}

.chat-empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.chat-compose {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid #d1d7db;
  background: #f0f2f5;
}

.chat-compose textarea {
  min-height: 44px;
  max-height: 118px;
  border: 0;
  border-radius: 22px;
  background: #fff;
  padding: 11px 14px;
  resize: vertical;
}

.chat-icon-button,
.chat-send-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  border-radius: 999px;
  background: transparent;
  color: #54656f;
}

.chat-icon-button:hover {
  border-color: transparent;
  background: rgba(84, 101, 111, .12);
  color: #075e54;
}

.chat-icon-button svg,
.chat-send-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-send-button,
.chat-compose > button.chat-send-button.primary {
  grid-column: auto;
  grid-row: auto;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 999px;
  border-color: #00a884;
  background: #00a884;
  color: #fff;
}

.chat-send-button:hover,
.chat-compose > button.chat-send-button.primary:hover {
  border-color: #008f72;
  background: #008f72;
  color: #fff;
}

.voice-compose-controls {
  grid-column: 1 / -1;
  grid-row: auto;
  display: grid;
  gap: 7px;
}

.voice-compose-controls[hidden],
.compose-voice-preview[hidden],
.compose-file-preview-list[hidden] {
  display: none;
}

.chat-icon-button.is-recording {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.chat-icon-button.is-ready {
  background: #d9fdd3;
  color: #075e54;
}

.voice-compose-controls > span {
  color: #54656f;
  font-size: 12px;
  font-weight: 750;
}

.compose-preview-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.compose-voice-preview,
.compose-file-preview-card {
  display: grid;
  align-items: center;
  gap: 9px;
  min-width: min(100%, 260px);
  max-width: 100%;
  padding: 7px 8px;
  border: 1px solid #d9e5e1;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(17, 27, 33, .08);
}

.compose-voice-preview {
  grid-template-columns: 32px minmax(160px, 320px) 30px;
}

.compose-file-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compose-file-preview-card {
  grid-template-columns: 34px minmax(120px, 220px) 30px;
}

.compose-voice-icon,
.compose-file-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e7f7f2;
  color: #008069;
  font-size: 10px;
  font-weight: 900;
}

.compose-voice-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compose-file-info {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.compose-file-info strong {
  overflow: hidden;
  color: #111b21;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-file-info small {
  color: #667781;
  font-size: 11px;
}

.compose-preview-remove {
  display: grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f0f2f5;
  color: #54656f;
}

.compose-preview-remove:hover {
  background: #ffe5e5;
  color: #c41e3a;
}

.compose-preview-remove svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compose-voice-preview audio,
.voice-message-player {
  width: min(320px, 100%);
  height: 36px;
}

.voice-message-player {
  display: block;
  margin-top: 8px;
}

.chat-file-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.chat-file-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: min(300px, 100%);
  padding: 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .045);
  color: #111b21;
  font-weight: 700;
}

.chat-file-card:hover {
  background: rgba(0, 0, 0, .075);
  color: #111b21;
}

.chat-file-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #00a884;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.chat-file-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-file-info strong {
  overflow: hidden;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-file-info small {
  color: #667781;
  font-size: 11px;
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-two,
  .request-workspace,
  .chat-workspace { grid-template-columns: 1fr; }
  .excel-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .excel-formula-bar {
    grid-template-columns: minmax(130px, 190px) 42px minmax(220px, 1fr) auto;
  }
  .excel-formula-bar .primary { grid-column: 3 / -1; }
}

@media (max-width: 900px) {
  body.app-shell {
    display: block;
    padding-top: 58px;
    overflow-x: hidden;
  }

  body.nav-open {
    overflow: hidden;
  }

  .mobile-appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 8px 14px;
    background: #101820;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
  }

  .mobile-brand .brand-mark {
    width: 36px;
    height: 36px;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
  }

  .mobile-icon-button {
    display: inline-grid;
    place-items: center;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 8px;
    background: rgba(255,255,255,.07);
    color: #fff;
    box-shadow: none;
  }

  .mobile-icon-button:hover,
  .mobile-icon-button:focus-visible {
    border-color: rgba(255,255,255,.34);
    background: rgba(255,255,255,.13);
    color: #fff;
  }

  .mobile-theme-toggle span[aria-hidden="true"] {
    font-size: 20px;
    line-height: 1;
  }

  .nav-toggle {
    position: relative;
    gap: 0;
  }

  .nav-toggle span {
    position: absolute;
    display: block;
    width: 19px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
    transition: transform .18s ease, opacity .18s ease;
  }

  .nav-toggle span:nth-child(1) {
    transform: translateY(-6px);
  }

  .nav-toggle span:nth-child(3) {
    transform: translateY(6px);
  }

  body.nav-open .nav-toggle span:nth-child(1) {
    transform: rotate(45deg);
  }

  body.nav-open .nav-toggle span:nth-child(2) {
    opacity: 0;
  }

  body.nav-open .nav-toggle span:nth-child(3) {
    transform: rotate(-45deg);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 58px 0 0 0;
    z-index: 45;
    display: block;
    pointer-events: none;
    background: rgba(9, 18, 26, .36);
    opacity: 0;
    transition: opacity .18s ease;
  }

  .sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    z-index: 50;
    width: min(86vw, 320px);
    height: calc(100dvh - 58px);
    grid-template-rows: 1fr auto;
    gap: 14px;
    padding-top: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-104%);
    transition: transform .18s ease;
    box-shadow: 18px 0 34px rgba(5, 12, 18, .22);
  }

  .sidebar > .brand {
    display: none;
  }

  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .mobile-nav-backdrop {
    pointer-events: auto;
    opacity: 1;
  }

  .topbar { display: none; }
  .content {
    width: 100%;
    padding: 18px 14px 24px;
    overflow-x: hidden;
  }

  .page-head,
  .page-head.row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .page-head h1 { font-size: 26px; }
  .page-head .button,
  .page-head button { width: 100%; }

  .request-head-actions {
    justify-content: stretch;
    width: 100%;
  }

  .request-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .request-head-actions .status,
  .request-head-actions form,
  .request-head-actions .button,
  .request-head-actions button {
    width: 100%;
  }

  .supply-action-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .supply-action-strip form,
  .supply-action-strip button {
    width: 100%;
  }

  .sales-action-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    display: grid;
    width: 100%;
  }

  .supply-decision-buttons {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .request-workflow-event {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .notification-history-item {
    grid-template-columns: 8px minmax(0, 1fr);
  }

  .notification-history-item > .button {
    grid-column: 2;
    width: 100%;
  }

  .notification-history-head {
    display: grid;
    gap: 3px;
  }

  .metrics,
  .contact-draft,
  .calendar-add-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .contact-draft button {
    width: 100%;
  }

  .panel {
    padding: 14px;
    border-radius: 7px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .incoming-call-card,
  .call-controls,
  .call-controls button {
    width: 100%;
  }

  .call-dock {
    grid-template-columns: 1fr;
  }

  .search,
  .file-drop-form {
    grid-template-columns: 1fr;
  }

  .organization-search {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-controls {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .pagination-button,
  .pagination-current {
    justify-content: center;
    width: 100%;
  }

  .chat-workspace {
    min-height: auto;
    overflow: visible;
    border-radius: 8px;
  }

  .chat-workspace .chat-panel {
    order: 1;
    min-height: calc(100dvh - 92px);
  }

  .chat-workspace .chat-list-panel {
    order: 2;
  }

  .chat-thread {
    padding: 14px 12px;
  }

  .chat-compose {
    grid-template-columns: auto minmax(72px, 1fr) auto auto;
    gap: 6px;
  }

  .voice-compose-controls {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .file-drop-form button {
    width: 100%;
  }

  .chat-panel .chat-thread {
    min-height: 440px;
    max-height: 68vh;
  }

  .chat-workspace .chat-panel .chat-thread {
    min-height: 0;
    max-height: none;
  }

  .chat-list-panel {
    position: static;
    max-height: none;
  }

  .chat-workspace .chat-list-panel {
    max-height: 48dvh;
    height: auto;
  }

  .table-legend {
    white-space: normal;
  }

  .excel-scroll {
    max-height: 64vh;
    margin-left: -8px;
    margin-right: -8px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .excel-formula-bar {
    grid-template-columns: 1fr 42px;
  }

  .excel-formula-bar input,
  .excel-formula-bar button,
  .excel-formula-bar .primary {
    grid-column: 1 / -1;
  }

  .excel-summary {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }
}

/* Virtualized workbook used by inventory and production plan. */
.virtual-workbook { position: relative; min-width: 0; padding: 0; overflow: visible; }
.workbook-titlebar, .workbook-toolbar, .workbook-formula-bar, .workbook-statusbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.workbook-titlebar { justify-content: space-between; }
.workbook-title, .workbook-primary-actions, .workbook-tool-group, .workbook-format-tools, .workbook-search-wrap {
  display: flex; align-items: center; gap: 8px;
}
.workbook-title { min-width: 0; }
.workbook-title strong { color: var(--ink); font-size: 15px; }
.workbook-title span, .workbook-search-wrap span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.workbook-toolbar { flex-wrap: wrap; padding-block: 8px; background: color-mix(in srgb, var(--surface) 92%, var(--page)); }
.workbook-search-wrap { flex: 1 1 280px; }
.workbook-search-wrap input { width: min(420px, 100%); min-height: 34px; margin: 0; }
.workbook-tool-group { min-height: 34px; padding-left: 8px; border-left: 1px solid var(--line); }
.workbook-tool-group button, .workbook-format-tools label {
  min-height: 32px; margin: 0; padding: 6px 9px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 750;
}
.workbook-tool-group button:hover:not(:disabled), .workbook-tool-group button:focus-visible { border-color: var(--accent); color: var(--accent); }
.workbook-tool-group button:disabled { opacity: .42; }
.workbook-format-tools label { display: inline-flex; align-items: center; gap: 6px; }
.workbook-format-tools input[type="color"] { width: 22px; height: 20px; padding: 0; border: 0; background: transparent; }
.workbook-save { min-width: 106px; border-color: #178447; background: #178447; color: #fff; }
.workbook-save.is-saved, .workbook-save:disabled { border-color: var(--line-strong); background: #697482; color: #fff; opacity: 1; }
.workbook-save.is-saving { background: #9a6a08; }
.workbook-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.workbook-filter-chips[hidden] { display: none; }
.workbook-filter-chips button { min-height: 28px; padding: 4px 8px; border: 1px solid #7aa6e8; border-radius: 6px; background: #edf5ff; color: #174f96; font-size: 11px; }
.workbook-formula-bar { padding-block: 7px; }
.workbook-name-box { flex: 0 0 92px; min-height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); background: var(--page); color: var(--ink); font-weight: 800; }
.workbook-fx { color: var(--muted); font-family: Georgia, serif; font-size: 17px; font-style: italic; font-weight: 700; }
.workbook-formula-bar input { flex: 1; min-width: 0; min-height: 32px; margin: 0; border-radius: 3px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.workbook-loading { min-height: 58vh; display: grid; grid-template-columns: auto minmax(180px, 420px); align-content: center; justify-content: center; gap: 14px 18px; padding: 28px; background: var(--surface); }
.workbook-loading[hidden] { display: none; }
.workbook-loading > div:nth-child(2) { display: grid; align-content: center; gap: 3px; }
.workbook-loading > div:nth-child(2) span { color: var(--muted); font-size: 12px; }
.workbook-loading-ring { grid-row: span 2; width: 66px; height: 66px; display: grid; place-items: center; border: 5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: inventory-loader-spin 1.1s linear infinite; }
.workbook-loading-ring span { color: var(--ink); font-size: 12px; font-weight: 900; animation: inventory-loader-spin 1.1s linear infinite reverse; }
.workbook-loading-track { grid-column: 2; width: 100%; height: 7px; overflow: hidden; border-radius: 4px; background: var(--line); }
.workbook-loading-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .18s ease; }
.virtual-workbook.is-loading .workbook-viewport, .virtual-workbook.is-loading .workbook-statusbar { display: none; }
.workbook-viewport { position: relative; width: 100%; height: min(72vh, 820px); min-height: 420px; overflow: auto; overscroll-behavior: contain; background: var(--surface); outline: none; }
.workbook-canvas { position: relative; min-width: 100%; background: var(--surface); }
.workbook-header-layer { position: sticky; top: 0; left: 0; z-index: 20; background: #e9eef4; box-shadow: 0 1px 0 #bac5d1; }
.workbook-row-layer { position: absolute; inset: 0 auto auto 0; }
.workbook-column-header, .workbook-corner, .workbook-cell, .workbook-row-number { position: absolute; box-sizing: border-box; border-right: 1px solid #cdd5de; border-bottom: 1px solid #cdd5de; }
.workbook-corner { top: 0; bottom: 0; z-index: 35; background: #dfe6ee; }
.workbook-column-header { top: 0; bottom: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 7px 8px; background: #e9eef4; color: #172434; overflow: hidden; }
.workbook-column-header.is-frozen { z-index: 30; box-shadow: 1px 0 0 #aeb9c5; }
.workbook-column-letter { min-width: 25px; height: 24px; display: grid; place-items: center; border: 1px solid #bdc7d2; border-radius: 5px; background: #f8fafc; color: #506176; font-size: 10px; font-weight: 900; }
.workbook-column-title { min-width: 0; overflow: hidden; color: #172434; font-size: 12px; font-weight: 850; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.workbook-filter-button { width: 25px; height: 25px; display: grid; place-items: center; margin: 0; padding: 0; border: 1px solid #bac5d1; border-radius: 5px; background: #f8fafc; color: #506176; }
.workbook-filter-button.is-active { border-color: #1769c2; background: #1769c2; color: #fff; }
.workbook-column-resize { position: absolute; top: 0; right: -4px; z-index: 8; width: 8px; height: 100%; cursor: col-resize; }
.workbook-row { position: absolute; left: 0; }
.workbook-row-number { top: 0; height: 100%; z-index: 12; display: grid; place-items: center; background: #f1f4f7; color: #667587; font-size: 11px; font-weight: 800; user-select: none; }
.workbook-row-resize { position: absolute; right: 0; bottom: -4px; left: 0; z-index: 4; height: 8px; cursor: row-resize; }
.workbook-cell { top: 0; height: 100%; display: flex; align-items: center; justify-content: center; padding: 5px 7px; overflow: hidden; background: var(--surface); color: var(--ink); font-size: 12px; line-height: 1.25; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; }
.workbook-cell.is-frozen { z-index: 10; box-shadow: 1px 0 0 #c3ccd6; }
.workbook-cell[contenteditable="true"] { cursor: cell; }
.workbook-cell.is-selected { box-shadow: inset 0 0 0 1px #2f6fed; }
.workbook-cell.is-active { z-index: 14; overflow: visible; box-shadow: inset 0 0 0 2px #1467c8; }
.workbook-cell.is-invalid { box-shadow: inset 0 0 0 2px #c52b2b; }
.workbook-cell.has-formula::after { content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0; border-top: 7px solid #178447; border-left: 7px solid transparent; }
.workbook-statusbar { min-height: 38px; justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); font-size: 11px; }
.workbook-statusbar [data-workbook-selection] { margin-right: auto; color: var(--ink); font-weight: 750; }
.workbook-popover, .workbook-context-menu { z-index: 1000; padding: 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); box-shadow: 0 14px 40px rgb(15 23 42 / 20%); }
.workbook-popover { position: absolute; width: min(360px, calc(100vw - 28px)); max-height: min(620px, 72vh); overflow: auto; }
.workbook-context-menu { position: fixed; width: 228px; max-height: calc(100dvh - 16px); display: grid; gap: 2px; overflow-y: auto; overscroll-behavior: contain; }
.workbook-popover[hidden], .workbook-context-menu[hidden] { display: none; }
.workbook-popover label, .workbook-popover-head, .workbook-popover-actions, .workbook-sort-actions { display: flex; align-items: center; gap: 8px; }
.workbook-popover label { align-items: stretch; flex-direction: column; margin-top: 10px; font-size: 12px; font-weight: 750; }
.workbook-popover-head { justify-content: space-between; margin-bottom: 10px; }
.workbook-selection-hint { margin: 0 0 8px; padding: 6px 8px; border-left: 3px solid #1769c2; background: var(--page); color: var(--muted); font-size: 11px; }
.workbook-popover-head button { width: 28px; min-height: 28px; padding: 0; }
.workbook-sort-actions, .workbook-popover-actions { margin-top: 10px; }
.workbook-sort-actions button, .workbook-popover-actions button { flex: 1; }
.workbook-column-list, .workbook-history-list { display: grid; gap: 5px; margin-top: 10px; }
.workbook-filter-value-head { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.workbook-filter-value-head strong { margin-right: auto; }
.workbook-filter-value-head button { min-height: 26px; padding: 3px 7px; }
.workbook-filter-values { display: grid; max-height: 190px; overflow: auto; margin-top: 5px; border: 1px solid var(--line); }
.workbook-filter-values label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; margin: 0; padding: 5px 7px; border-bottom: 1px solid var(--line); font-weight: 500; }
.workbook-column-list label { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; margin: 0; padding: 6px; border-bottom: 1px solid var(--line); }
.workbook-column-list select { width: 92px; min-height: 28px; margin: 0; padding: 3px 5px; font-size: 11px; }
.workbook-history-list article { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.workbook-conflict-list { display: grid; gap: 8px; margin-top: 10px; }
.workbook-conflict-list article { display: grid; gap: 6px; padding: 9px; border: 1px solid #d79a2b; background: color-mix(in srgb, #f4b942 12%, var(--surface)); }
.workbook-conflict-list article > div:not(.workbook-popover-actions) { white-space: pre-wrap; font-size: 11px; line-height: 1.45; }
.workbook-history-list small { color: var(--muted); }
.workbook-history-list article div { max-height: 64px; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.workbook-context-menu button { width: 100%; justify-content: flex-start; border: 0; background: transparent; color: var(--ink); text-align: left; }
.workbook-context-menu button:hover { background: var(--page); }
.workbook-context-menu .context-menu-group-start { margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--line); border-radius: 0 0 4px 4px; }
.workbook-column-list > button { width: 100%; margin-top: 4px; }
.workbook-history-change { padding: 6px 7px; border-left: 3px solid #178447; background: var(--page); }
body.theme-dark .workbook-header-layer, body.theme-dark .workbook-column-header { background: #28323d; color: #f4f7fa; }
body.theme-dark .workbook-corner { background: #202933; }
body.theme-dark .workbook-column-title { color: #f4f7fa; }
body.theme-dark .workbook-column-letter, body.theme-dark .workbook-filter-button, body.theme-dark .workbook-row-number { border-color: #526171; background: #333f4c; color: #dce5ee; }
body.theme-dark .workbook-column-header, body.theme-dark .workbook-cell, body.theme-dark .workbook-row-number, body.theme-dark .workbook-corner { border-color: #465360; }
body.theme-dark .workbook-cell.is-selected { box-shadow: inset 0 0 0 1px #7da7e8; }
body.theme-dark .workbook-cell.is-active { box-shadow: inset 0 0 0 2px #75adff; }
body.theme-dark .workbook-filter-chips button { border-color: #4e83be; background: #183b60; color: #dbeeff; }
body.theme-dark .workbook-popover, body.theme-dark .workbook-context-menu { box-shadow: 0 16px 44px rgb(0 0 0 / 48%); }
.excel-selection-status { display: flex; justify-content: flex-end; gap: 16px; min-height: 34px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-top: 0; background: var(--surface); color: var(--muted); font-size: 11px; }
.excel-selection-status [data-excel-selection-address] { margin-right: auto; color: var(--ink); font-weight: 750; }
@media (max-width: 760px) {
  .workbook-titlebar { align-items: flex-start; flex-direction: column; }
  .workbook-primary-actions { width: 100%; }
  .workbook-primary-actions > * { flex: 1; }
  .workbook-toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .workbook-search-wrap { flex: 0 0 250px; }
  .workbook-tool-group, .workbook-format-tools { flex: 0 0 auto; }
  .workbook-formula-bar { gap: 5px; }
  .workbook-name-box { flex-basis: 64px; }
  .workbook-viewport { height: 68vh; min-height: 360px; }
  .workbook-statusbar [data-workbook-calculation] { display: none; }
}
@media (pointer: coarse) {
  .workbook-column-resize { right: -7px; width: 14px; }
  .workbook-row-resize { bottom: -7px; height: 14px; }
  .workbook-filter-button { width: 30px; height: 30px; }
  .workbook-cell { min-height: 34px; }
}

@media (max-width: 760px) {
  .request-list-filters {
    grid-template-columns: 1fr auto;
  }

  .request-list-filters > input,
  .request-list-filters > label {
    grid-column: 1 / -1;
  }

  .list-panel,
  .panel:has(> table:not(.excel-table)),
  .panel:has(> .table-wrap) {
    overflow: visible;
  }

  table:not(.excel-table),
  table:not(.excel-table) thead,
  table:not(.excel-table) tbody,
  table:not(.excel-table) tr,
  table:not(.excel-table) td {
    display: block;
  }

  table:not(.excel-table) {
    min-width: 0 !important;
    background: transparent;
  }

  table:not(.excel-table) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table:not(.excel-table) tbody {
    display: grid;
    gap: 10px;
  }

  table:not(.excel-table) tbody tr {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  table:not(.excel-table) tbody tr:hover td {
    background: transparent;
  }

  table:not(.excel-table) td {
    display: grid;
    grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 34px;
    padding: 7px 0;
    border-bottom: 1px solid #edf0f2;
    word-break: break-word;
  }

  table:not(.excel-table) td:last-child {
    border-bottom: 0;
  }

  table:not(.excel-table) td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    line-height: 1.3;
    text-transform: uppercase;
  }

  table:not(.excel-table) td[colspan] {
    display: block;
  }

  table:not(.excel-table) td[colspan]::before {
    content: "";
  }

  .table-actions {
    width: auto;
    text-align: left;
    white-space: normal;
  }

  .table-actions .inline-form,
  .table-actions button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 13px;
  }

  .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .login-box {
    padding: 22px;
  }

  .metrics div {
    min-height: auto;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-actions button,
  .form-actions .button,
  .compact > button,
  .form > button,
  .form-grid > button,
  .search button,
  .file-drop-form button,
  .page-head .button,
  .page-head button {
    width: 100%;
  }

  .inline-form {
    width: 100%;
  }

  .inline-form button {
    width: 100%;
  }

  .chat-icon-button,
  .chat-send-button,
  .chat-compose > button.chat-send-button.primary,
  .compose-preview-remove,
  .zoom-controls button {
    width: auto;
  }

  .chat-compose {
    position: sticky;
    bottom: 0;
    z-index: 8;
    grid-template-columns: 40px minmax(0, 1fr) 40px 44px;
    padding: 8px;
  }

  .chat-thread {
    padding: 12px 8px;
  }

  .chat-message {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 6px;
  }

  .chat-message.is-own {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .chat-avatar {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }

  .chat-bubble {
    padding: 7px 8px 5px;
  }

  .chat-meta {
    flex-wrap: wrap;
    gap: 3px 6px;
  }

  .chat-file-card {
    grid-template-columns: 36px minmax(0, 1fr);
    min-width: 0;
  }

  .chat-file-icon {
    width: 36px;
    height: 36px;
  }

  .compose-voice-preview,
  .compose-file-preview-card {
    width: 100%;
    min-width: 0;
  }

  .compose-voice-preview,
  .compose-file-preview-card {
    grid-template-columns: 32px minmax(0, 1fr) 30px;
  }

  .voice-message-player,
  .compose-voice-preview audio {
    width: 100%;
  }

  .excel-tools {
    justify-content: flex-start;
    width: 100%;
  }

  .zoom-controls {
    width: 100%;
    justify-content: space-between;
  }

  .zoom-controls button {
    flex: 1;
  }

  .nav-toggle {
    width: 42px;
    min-width: 42px;
  }
}

@media (max-width: 420px) {
  .content {
    padding-left: 8px;
    padding-right: 8px;
  }

  .panel {
    padding: 12px;
  }

  .page-head h1 {
    font-size: 23px;
  }

  .metrics strong {
    font-size: 24px;
  }

  table:not(.excel-table) td {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  table:not(.excel-table) td::before {
    font-size: 10px;
  }

  .excel-panel {
    padding-left: 8px;
    padding-right: 8px;
  }

  .excel-row-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chat-workspace {
    margin-left: -8px;
    margin-right: -8px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .chat-workspace .chat-panel {
    min-height: calc(100dvh - 58px);
  }

  .chat-context-menu {
    max-width: calc(100vw - 16px);
  }
}

body.theme-dark .panel,
body.theme-dark .metrics div,
body.theme-dark .table-wrap,
body.theme-dark table,
body.theme-dark table:not(.excel-table) tbody tr,
body.theme-dark .calendar-board,
body.theme-dark .calendar-event-card,
body.theme-dark .calendar-empty,
body.theme-dark .contact-row,
body.theme-dark .modal-dialog,
body.theme-dark .notification-toast,
body.theme-dark .chat-list-panel,
body.theme-dark .chat-list-item,
body.theme-dark .chat-quick-card,
body.theme-dark .incoming-call-card,
body.theme-dark .chat-context-menu,
body.theme-dark .compose-voice-preview,
body.theme-dark .compose-file-preview-card {
  background: var(--surface);
  color: var(--ink);
}

body.theme-dark th,
body.theme-dark tbody tr:hover td,
body.theme-dark .chat-panel .panel-head,
body.theme-dark .call-incoming-list,
body.theme-dark .chat-compose,
body.theme-dark .excel-formula-bar,
body.theme-dark .formula-name-box,
body.theme-dark .formula-fx,
body.theme-dark .zoom-controls button {
  background: var(--surface-soft);
  color: var(--ink);
}

body.theme-dark .zoom-controls {
  border-color: #4b5563;
  background: #202730;
  box-shadow: none;
}

body.theme-dark .zoom-controls button {
  border-color: #4b5563;
}

body.theme-dark .zoom-controls output {
  color: #d5dde6;
}

body.theme-dark .excel-scroll,
body.theme-dark .excel-table,
body.theme-dark .excel-table textarea,
body.theme-dark .excel-table input[type="date"],
body.theme-dark .readonly-cell,
body.theme-dark .excel-table td.section-template,
body.theme-dark .excel-table td.section-sales,
body.theme-dark .excel-table td.section-supply,
body.theme-dark .excel-table td.section-sales_calc {
  color: var(--ink);
}

body.theme-dark .excel-scroll,
body.theme-dark .excel-table,
body.theme-dark .excel-table td.section-template {
  background: #1b2026;
}

body.theme-dark .excel-table td.section-sales {
  background: #1f3145;
}

body.theme-dark .excel-table td.section-supply {
  background: #3a2a1f;
}

body.theme-dark .excel-table td.section-sales_calc,
body.theme-dark .excel-table td.is-formula .readonly-cell {
  background: #1f3a2b;
}

body.theme-dark .excel-table textarea,
body.theme-dark .excel-table input[type="date"],
body.theme-dark .excel-table .readonly-cell {
  color: #f3f6f9;
  background: transparent;
  caret-color: #ffffff;
}

body.theme-dark .excel-table td.is-required-missing {
  background: #2b1b1e !important;
  box-shadow: inset 0 0 0 2px #ff6b74, inset 4px 0 0 #ff6b74 !important;
}

body.theme-dark .excel-table td.is-required-missing textarea,
body.theme-dark .excel-table td.is-required-missing input[type="date"] {
  color: #fff7f7;
  background: #2b1b1e;
  caret-color: #ffffff;
}

body.theme-dark .excel-table td.is-required-missing textarea::placeholder,
body.theme-dark .excel-table td.is-required-missing input[type="date"]::placeholder {
  color: #d6b4b7;
}

body.theme-dark .excel-table input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

body.theme-dark .excel-table tbody tr.excel-row-sales_header .readonly-cell {
  background: #243b56;
  color: #f3f8ff;
  box-shadow: inset 0 3px 0 #5b9dff;
}

body.theme-dark .excel-table tbody tr.excel-row-supply_header .readonly-cell {
  background: #4b3322;
  color: #fff5ec;
  box-shadow: inset 0 3px 0 #f59e0b;
}

body.theme-dark .excel-table .row-num,
body.theme-dark .excel-letters th {
  background: #202730;
  color: #d5dde6;
}

body.theme-dark .excel-table td.is-selected-column,
body.theme-dark .excel-table td.is-selected-range {
  background: #26384b;
}

body.theme-dark .excel-table td.is-selected-column textarea,
body.theme-dark .excel-table td.is-selected-column .readonly-cell,
body.theme-dark .excel-table td.is-selected-range textarea,
body.theme-dark .excel-table td.is-selected-range .readonly-cell {
  background: rgba(38, 56, 75, .9);
  color: #ffffff;
}

body.theme-dark .chat-panel {
  background: #171b20;
}

body.theme-dark .chat-bubble,
body.theme-dark .chat-compose textarea,
body.theme-dark .chat-action-row select,
body.theme-dark .chat-action-row .chat-icon-button {
  background: #242a30;
  color: var(--ink);
}

body.theme-dark .chat-message.is-own .chat-bubble {
  background: #20362b;
}

body.theme-dark .chat-bubble::before {
  border-top-color: #242a30;
}

body.theme-dark .chat-message.is-own .chat-bubble::before {
  border-top-color: #20362b;
}

body.theme-dark .chat-text,
body.theme-dark .chat-context-menu button,
body.theme-dark .incoming-call-card span,
body.theme-dark .chat-list-item {
  color: var(--ink);
}

body.theme-dark .topbar {
  background: rgba(28, 32, 36, .94);
  color: var(--ink);
  border-bottom-color: var(--line);
}

body.theme-dark .topbar .ghost {
  color: var(--ink);
  border-color: var(--line-strong);
}

body.theme-dark .topbar .ghost:hover {
  background: #333;
  color: #fff;
}

body.theme-dark .request-head-actions button.danger {
  border-color: #5a3a3f;
  background: transparent;
  color: #f1a4aa;
}

body.theme-dark .request-head-actions button.danger:hover {
  border-color: #b95a64;
  background: #2b1f22;
  color: #ffd8dc;
}

/* CRM-native chat palette overrides. Keep chat aligned with the rest of the app. */
.chat-workspace,
.chat-panel,
.chat-panel .panel-head,
.chat-list-panel,
.chat-list-item,
.chat-compose,
.call-incoming-list,
.call-dock {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.chat-panel .panel-head,
.chat-compose,
.call-incoming-list,
.call-dock {
  background: var(--surface-raised);
}

.chat-thread {
  gap: 8px;
  background: var(--surface-soft);
}

.chat-bubble {
  padding: 9px 11px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.chat-bubble::before,
.chat-message.is-own .chat-bubble::before {
  content: none;
}

.chat-message.is-own .chat-bubble {
  border-color: #333;
  border-radius: 8px;
  background: #333;
  color: #fff;
}

.chat-meta strong,
.chat-text,
.chat-list-last,
.incoming-call-card span,
.call-dock strong {
  color: var(--ink);
}

.chat-meta span,
.chat-bubble time,
.chat-edited,
.call-dock p,
.call-remote span {
  color: var(--muted);
}

.chat-message.is-own .chat-meta strong,
.chat-message.is-own .chat-meta span,
.chat-message.is-own .chat-text,
.chat-message.is-own .chat-bubble time,
.chat-message.is-own .chat-edited {
  color: #fff;
}

.chat-compose textarea,
.chat-action-row select,
.chat-action-row .chat-icon-button,
.incoming-call-card,
.chat-context-menu,
.compose-voice-preview,
.compose-file-preview-card {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.chat-icon-button {
  color: var(--muted);
}

.chat-icon-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.chat-send-button,
.chat-compose > button.chat-send-button.primary,
.incoming-call-card button {
  border-color: #333;
  background: #333;
  color: #fff;
}

.chat-send-button:hover,
.chat-compose > button.chat-send-button.primary:hover,
.incoming-call-card button:hover {
  border-color: #222;
  background: #222;
  color: #fff;
}

body.theme-dark .chat-workspace,
body.theme-dark .chat-panel,
body.theme-dark .chat-panel .panel-head,
body.theme-dark .chat-list-panel,
body.theme-dark .chat-list-item,
body.theme-dark .chat-compose,
body.theme-dark .call-incoming-list,
body.theme-dark .call-dock,
body.theme-dark .chat-bubble,
body.theme-dark .chat-compose textarea,
body.theme-dark .chat-action-row select,
body.theme-dark .chat-action-row .chat-icon-button,
body.theme-dark .incoming-call-card,
body.theme-dark .chat-context-menu,
body.theme-dark .compose-voice-preview,
body.theme-dark .compose-file-preview-card {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

body.theme-dark .chat-thread,
body.theme-dark .chat-panel .panel-head,
body.theme-dark .chat-compose,
body.theme-dark .call-incoming-list,
body.theme-dark .call-dock {
  background: var(--surface-soft);
}

body.theme-dark .chat-message.is-own .chat-bubble {
  border-color: #3f4650;
  background: #3f4650;
}

.inventory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.inventory-tabs .is-active {
  background: #333;
  color: #fff;
}

.inventory-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.inventory-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.inventory-picker-item:hover,
.inventory-picker-item:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  outline: none;
}

.inventory-picker-item span {
  display: grid;
  gap: 6px;
}

.inventory-picker-item strong {
  font-size: 20px;
}

.inventory-picker-item small,
.inventory-picker-item em {
  color: var(--muted);
  font-style: normal;
}

.inventory-panel {
  padding: 12px;
}

.inventory-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 750;
}

.inventory-meta > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.inventory-meta strong {
  color: var(--ink);
  font-size: 16px;
}

.inventory-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.inventory-format-tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.inventory-format-tools label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.inventory-format-tools input[type="color"] {
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
}

.inventory-meta .button,
.inventory-meta button {
  width: auto;
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
}

.inventory-save-button {
  border-color: #b8c3cc;
  background: #eef1f4;
  color: #465565;
  font-weight: 850;
}

.inventory-save-button.is-dirty {
  border-color: #16833a;
  background: #198038;
  color: #ffffff;
}

.inventory-save-button.is-saving {
  border-color: #6b7280;
  background: #6b7280;
  color: #ffffff;
}

.inventory-save-button:disabled {
  cursor: default;
  opacity: 1;
}

.inventory-load-screen {
  display: none;
  min-height: min(62vh, 620px);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(51,51,51,.06), rgba(15,98,254,.05)),
    var(--surface);
}

.inventory-panel.is-loading .inventory-load-screen {
  display: flex;
}

.inventory-panel.is-loading .inventory-scroll {
  display: none;
}

.inventory-panel.is-loaded .inventory-load-screen {
  display: none;
}

.inventory-loader-card {
  width: min(420px, calc(100% - 32px));
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.inventory-loader-ring {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface-raised) 56%, transparent 57%),
    conic-gradient(from 0deg, #0f62fe, #16a34a, #d1a400, #0f62fe);
  animation: inventory-loader-spin 1.8s linear infinite;
}

.inventory-loader-ring span {
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  animation: inventory-loader-spin 1.8s linear infinite reverse;
}

.inventory-loader-copy {
  display: grid;
  gap: 4px;
  text-align: center;
}

.inventory-loader-copy strong {
  color: var(--ink);
  font-size: 18px;
}

.inventory-loader-copy span {
  color: var(--muted);
  font-weight: 800;
}

.inventory-loader-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.inventory-loader-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f62fe, #16a34a);
  transition: width .16s ease;
}

@keyframes inventory-loader-spin {
  to { transform: rotate(360deg); }
}

.inventory-scroll {
  max-height: 74vh;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.inventory-grid {
  --inventory-zoom: 1;
  min-width: max-content;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: calc(12px * var(--inventory-zoom));
}

.inventory-row-num-col {
  width: calc(46px * var(--inventory-zoom));
}

.inventory-grid th,
.inventory-grid td {
  height: calc(var(--inventory-row-height, 34px) * var(--inventory-zoom));
  padding: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.inventory-grid tbody tr {
  content-visibility: auto;
  height: calc(var(--inventory-row-height, 34px) * var(--inventory-zoom));
  contain-intrinsic-size: calc(var(--inventory-row-height, 34px) * var(--inventory-zoom)) auto;
}

.inventory-grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  min-width: 104px;
  height: calc(48px * var(--inventory-zoom));
  padding: 0;
  background: #edf1f5;
  color: #22313f;
  text-transform: none;
  white-space: normal;
}

.inventory-col-head-inner {
  position: relative;
  min-height: calc(48px * var(--inventory-zoom));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: calc(7px * var(--inventory-zoom));
  padding: calc(7px * var(--inventory-zoom)) calc(8px * var(--inventory-zoom));
}

.inventory-row-head {
  position: sticky;
  left: 0;
  z-index: 4;
  width: calc(46px * var(--inventory-zoom));
  min-width: calc(46px * var(--inventory-zoom));
  background: #f5f7f9;
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.inventory-row-head[data-inventory-row-head] {
  cursor: default;
  user-select: none;
}

.inventory-col-resize {
  position: absolute;
  top: 0;
  right: calc(-4px * var(--inventory-zoom));
  z-index: 8;
  width: calc(8px * var(--inventory-zoom));
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.inventory-col-resize::after {
  content: "";
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: transparent;
  transform: translateX(-50%);
}

.inventory-col-resize:hover::after,
.inventory-col-resize:active::after,
body.is-table-col-resizing .inventory-col-resize::after {
  background: #0f62fe;
}

.inventory-row-resize {
  position: absolute;
  right: 0;
  bottom: calc(-4px * var(--inventory-zoom));
  left: 0;
  z-index: 8;
  height: calc(8px * var(--inventory-zoom));
  cursor: row-resize;
  touch-action: none;
}

.inventory-row-resize::after {
  content: "";
  position: absolute;
  right: 18%;
  bottom: 50%;
  left: 18%;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  transform: translateY(50%);
}

.inventory-row-resize:hover::after,
.inventory-row-resize:active::after,
body.is-table-row-resizing .inventory-row-resize::after {
  background: #0f62fe;
}

body.is-table-col-resizing,
body.is-table-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-table-row-resizing,
body.is-table-row-resizing * {
  cursor: row-resize !important;
  user-select: none !important;
}

.inventory-grid tr.is-selected-row .inventory-row-head,
.inventory-grid tr.is-selected-row td {
  background: #e7f0ff;
}

.inventory-grid thead .inventory-row-head {
  z-index: 5;
  background: #edf1f5;
}

.inventory-col-letter {
  display: inline-grid;
  min-width: calc(26px * var(--inventory-zoom));
  height: calc(24px * var(--inventory-zoom));
  place-items: center;
  border: 1px solid #c8d0d8;
  border-radius: 6px;
  background: #fff;
  color: #526273;
  font-size: calc(10px * var(--inventory-zoom));
  font-weight: 900;
}

.inventory-col-title {
  min-width: 0;
  color: #1f2937;
  font-size: calc(12px * var(--inventory-zoom));
  font-weight: 900;
  line-height: 1.18;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.inventory-col-empty {
  color: #8a96a3;
  font-weight: 800;
}

.inventory-filter-button {
  display: inline-grid;
  min-height: calc(28px * var(--inventory-zoom));
  width: calc(28px * var(--inventory-zoom));
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid #c8d0d8;
  border-radius: 7px;
  background: #f8fafc;
  color: #526273;
  font-size: calc(12px * var(--inventory-zoom));
  line-height: 1;
}

.inventory-filter-button:hover,
.inventory-filter-button:focus-visible {
  border-color: #0f62fe;
  background: #e8f0ff;
  color: #0f62fe;
  outline: none;
}

.inventory-filter-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.inventory-grid [data-inventory-cell] {
  width: 100%;
  min-height: calc((var(--inventory-row-height, 34px) - 1px) * var(--inventory-zoom));
  padding: calc(6px * var(--inventory-zoom)) calc(7px * var(--inventory-zoom));
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

.inventory-readonly-cell {
  width: 100%;
  min-height: calc((var(--inventory-row-height, 34px) - 1px) * var(--inventory-zoom));
  padding: calc(6px * var(--inventory-zoom)) calc(7px * var(--inventory-zoom));
  overflow: hidden;
  color: var(--ink);
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

.inventory-grid [data-inventory-cell]:focus {
  box-shadow: inset 0 0 0 2px #333;
  background: #fff;
}

.inventory-grid [data-inventory-cell].is-selected-cell,
.inventory-grid .inventory-readonly-cell.is-selected-cell {
  box-shadow: inset 0 0 0 2px #0f62fe;
}

.inventory-grid [data-inventory-cell].is-dirty {
  background: #fff9db;
}

.inventory-grid [data-inventory-cell].is-saving {
  background: var(--warning-soft);
}

.inventory-grid [data-inventory-cell].is-error {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 2px var(--danger);
}

.inventory-search {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.inventory-search label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.inventory-search input[type="search"] {
  width: 100%;
  min-height: 38px;
}

.inventory-search-toggle {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  white-space: nowrap;
}

.inventory-search [data-inventory-search-count] {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.inventory-grid tr.is-search-hidden {
  display: none;
}

.inventory-grid tr.is-column-filter-hidden {
  display: none;
}

.inventory-grid tr.is-search-match td,
.inventory-grid tr.is-search-match .inventory-row-head {
  background: #fff8d8;
}

.inventory-grid [data-inventory-cell].is-search-match,
.inventory-readonly-cell.is-search-match {
  background: #fff1a8;
  box-shadow: inset 0 0 0 1px #d1a400;
}

body.theme-dark .inventory-scroll,
body.theme-dark .inventory-grid,
body.theme-dark .inventory-grid [data-inventory-cell],
body.theme-dark .inventory-readonly-cell {
  background: #1b2026;
  color: var(--ink);
}

body.theme-dark .inventory-grid thead th,
body.theme-dark .inventory-grid .inventory-row-head {
  background: #202730;
  color: #d5dde6;
}

body.theme-dark .inventory-col-letter {
  border-color: #4b5563;
  background: #111827;
  color: #cbd5e1;
}

body.theme-dark .inventory-col-title {
  color: #eef2f7;
}

body.theme-dark .inventory-col-empty {
  color: #93a0ad;
}

body.theme-dark .inventory-filter-button {
  border-color: #4b5563;
  background: #111827;
  color: #cbd5e1;
}

body.theme-dark .inventory-filter-button:hover,
body.theme-dark .inventory-filter-button:focus-visible {
  border-color: #60a5fa;
  background: #172554;
  color: #bfdbfe;
}

body.theme-dark .inventory-grid [data-inventory-cell]:focus {
  background: #15191d;
  box-shadow: inset 0 0 0 2px #d5dde6;
}

body.theme-dark .inventory-grid [data-inventory-cell].is-selected-cell,
body.theme-dark .inventory-grid .inventory-readonly-cell.is-selected-cell {
  box-shadow: inset 0 0 0 2px #60a5fa;
}

body.theme-dark .inventory-save-button {
  border-color: #4b5563;
  background: #374151;
  color: #d1d5db;
}

body.theme-dark .inventory-save-button.is-dirty {
  border-color: #22c55e;
  background: #16a34a;
  color: #ffffff;
}

body.theme-dark .inventory-save-button.is-saving {
  border-color: #6b7280;
  background: #6b7280;
  color: #ffffff;
}

body.theme-dark .inventory-grid tr.is-search-match td,
body.theme-dark .inventory-grid tr.is-search-match .inventory-row-head {
  background: #40381b;
}

body.theme-dark .inventory-grid [data-inventory-cell].is-search-match,
body.theme-dark .inventory-readonly-cell.is-search-match {
  background: #53481f;
  box-shadow: inset 0 0 0 1px #d1a400;
}

body.theme-dark .inventory-grid tr.is-selected-row .inventory-row-head,
body.theme-dark .inventory-grid tr.is-selected-row td {
  background: #25364f;
}

.inventory-filter-menu {
  position: fixed;
  z-index: 100;
  width: min(320px, calc(100vw - 16px));
  max-height: min(520px, calc(100vh - 24px));
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.inventory-filter-menu[hidden] {
  display: none;
}

.inventory-filter-menu-head,
.inventory-filter-menu-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.inventory-filter-menu-head strong {
  color: var(--ink);
}

.inventory-filter-menu-head button,
.inventory-filter-menu-actions button {
  width: auto;
  min-height: 30px;
  padding: 5px 8px;
}

.inventory-filter-menu input[type="search"] {
  width: 100%;
  min-height: 34px;
}

.inventory-filter-values {
  display: grid;
  gap: 4px;
  max-height: 300px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.inventory-filter-values label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  color: var(--ink);
  font-size: 13px;
}

body.theme-dark .notification-toast {
  border-color: #64748b;
  background: #101820;
  color: #f8fafc;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .58), 0 0 0 1px rgba(255, 255, 255, .05);
}

body.theme-dark .notification-head strong {
  color: #ffffff;
  font-size: 15px;
  font-weight: 850;
}

body.theme-dark .notification-head time {
  color: #cbd5e1;
}

body.theme-dark .notification-toast p {
  color: #eef2f7;
  font-size: 14px;
  font-weight: 650;
}

body.theme-dark .notification-close {
  border-color: #94a3b8;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 850;
}

body.theme-dark .notification-close:hover {
  border-color: #ffffff;
  background: #ffffff;
  color: #020617;
}

.panel.virtual-workbook { padding: 0; }

/* Excel-grade workbook shell. */
.workbook-ribbon { border-bottom: 1px solid var(--line); background: var(--surface); }
.workbook-ribbon-tabs { display: flex; align-items: end; gap: 2px; min-height: 34px; padding: 3px 10px 0; border-bottom: 1px solid var(--line); }
.workbook-ribbon-tabs button { min-height: 30px; padding: 5px 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 3px 3px 0 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.workbook-ribbon-tabs button[aria-selected="true"] { border-bottom-color: #178447; color: var(--ink); background: color-mix(in srgb, #178447 8%, var(--surface)); }
.workbook-ribbon-panel { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
.workbook-ribbon-panel[hidden] { display: none; }
.workbook-toolbar { min-height: 48px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.workbook-tool-group { flex: 0 0 auto; }
.workbook-tool-group select { width: auto; min-height: 32px; margin: 0; padding: 4px 24px 4px 7px; border-color: var(--line-strong); border-radius: 4px; background-color: var(--surface); color: var(--ink); font-size: 11px; }
.workbook-tool-group button, .workbook-toolbar .icon-button { border-radius: 4px; }
.workbook-tool-group button.is-active, .workbook-toolbar button.is-active { border-color: #178447; background: color-mix(in srgb, #178447 14%, var(--surface)); color: #126f3b; }
.workbook-font-tools .format-toggle, .workbook-alignment-tools .icon-button, .workbook-undo-tools .icon-button { width: 34px; min-width: 34px; padding-inline: 0; }
.workbook-alignment-tools button[data-workbook-command="align-right"] { transform: scaleX(-1); }
.color-tool { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 7px; border: 1px solid var(--line-strong); border-radius: 4px; font-size: 11px; font-weight: 700; }
.color-tool input[type="color"] { width: 22px; height: 20px; margin: 0; padding: 0; border: 0; }
.workbook-presence { display: flex; align-items: center; margin-left: auto; padding-inline: 8px; }
.workbook-presence-avatar, .workbook-presence-more { width: 28px; height: 28px; display: grid; place-items: center; margin-left: -6px; border: 2px solid var(--surface); border-radius: 50%; background: #1769c2; color: #fff; font-size: 10px; font-weight: 900; }
.workbook-presence-avatar:nth-child(2n) { background: #178447; }
.workbook-presence-avatar:nth-child(3n) { background: #9a6200; }
.workbook-presence-more { background: #596575; }
.workbook-primary-actions .icon-button, .workbook-statusbar .icon-button { width: 34px; min-width: 34px; padding: 0; }

.inventory-empty-state { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inventory-import-modal { padding: 12px; }
.inventory-import-dialog { width: min(820px, 100%); max-height: min(90dvh, 900px); overflow-y: auto; border-radius: 8px; }
.inventory-import-head, .inventory-import-file, .inventory-import-actions, .inventory-import-history-list article {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.inventory-import-head { margin-bottom: 16px; }
.inventory-import-head h2 { margin: 2px 0 0; font-size: 20px; letter-spacing: 0; }
.inventory-import-file { padding: 11px 0; border-block: 1px solid var(--line); }
.inventory-import-file strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-import-file span { color: var(--muted); white-space: nowrap; }
.inventory-import-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border-bottom: 1px solid var(--line); }
.inventory-import-stats div { padding: 12px; border-right: 1px solid var(--line); }
.inventory-import-stats div:last-child { border-right: 0; }
.inventory-import-stats dt { color: var(--muted); font-size: 11px; }
.inventory-import-stats dd { margin: 3px 0 0; color: var(--ink); font-size: 18px; font-weight: 800; }
.inventory-import-sheet-list { max-height: 230px; margin-top: 14px; overflow: auto; border: 1px solid var(--line); }
.inventory-import-sheet-list table { width: 100%; margin: 0; }
.inventory-import-sheet-list th, .inventory-import-sheet-list td { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
.inventory-import-sheet-list td:first-child { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.inventory-import-warnings { margin-top: 12px; padding: 10px 12px; border-left: 3px solid #b77900; background: color-mix(in srgb, #f2b84b 14%, var(--surface)); }
.inventory-import-warnings ul { margin: 6px 0 0; padding-left: 18px; }
.inventory-import-warnings li + li { margin-top: 4px; }
.inventory-import-confirmation { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); }
.inventory-import-confirmation span { color: var(--muted); font-size: 12px; }
.inventory-import-actions { justify-content: flex-end; margin-top: 14px; }
.inventory-import-actions form { margin: 0; }
.inventory-import-dropzone { display: grid; min-height: 150px; place-items: center; align-content: center; gap: 7px; padding: 20px; border: 1px dashed var(--line-strong); background: color-mix(in srgb, var(--surface) 94%, var(--page)); cursor: pointer; text-align: center; }
.inventory-import-dropzone:hover, .inventory-import-dropzone.has-file { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.inventory-import-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.inventory-import-dropzone strong { color: var(--ink); font-size: 15px; }
.inventory-import-dropzone span { color: var(--muted); font-size: 12px; }
.inventory-import-history { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.inventory-import-history h3 { margin: 0 0 8px; font-size: 13px; }
.inventory-import-history-list { display: grid; }
.inventory-import-history-list article { min-width: 0; padding: 9px 0; border-top: 1px solid var(--line); }
.inventory-import-history-list article:first-child { border-top: 0; }
.inventory-import-history-list article > div { display: grid; min-width: 0; gap: 2px; }
.inventory-import-history-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-import-history-list span, .inventory-import-history-list small { color: var(--muted); font-size: 11px; }
.workbook-find-panel { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.workbook-find-panel[hidden] { display: none; }
.workbook-find-panel input { width: min(240px, 25vw); min-height: 32px; margin: 0; }
.workbook-find-panel output { min-width: 68px; color: var(--muted); font-size: 11px; text-align: center; }
.workbook-formula-bar { position: relative; min-height: 45px; }
.workbook-name-box { width: 92px; flex: 0 0 92px; min-height: 32px; margin: 0; padding: 5px 7px; border-radius: 2px; text-align: center; }
.workbook-formula-bar textarea { flex: 1; min-width: 0; min-height: 32px; max-height: 140px; margin: 0; padding: 7px 9px; resize: none; border: 1px solid var(--line-strong); border-radius: 2px; background: var(--surface); color: var(--ink); font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.workbook-formula-bar.is-expanded textarea { min-height: 92px; resize: vertical; }
.workbook-formula-cancel, .workbook-formula-accept { width: 28px; min-width: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; }
.workbook-formula-accept { color: #178447; }
.workbook-formula-cancel { color: #b42318; }
.workbook-formula-hints { position: absolute; top: calc(100% - 5px); left: 130px; z-index: 80; width: min(420px, calc(100vw - 170px)); display: grid; border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow-md); }
.workbook-formula-hints[hidden] { display: none; }
.workbook-formula-hints button { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.workbook-formula-hints button:hover { background: var(--page); }
.workbook-formula-hints span { color: var(--muted); font-size: 11px; }
.workbook-column-header.is-selected, .workbook-row-number.is-selected { background: #cfe4d8; color: #0f5a32; }
.workbook-cell { cursor: cell; user-select: none; }
.workbook-cell[contenteditable="true"] { cursor: text; user-select: text; white-space: pre-wrap; overflow: visible; background: var(--surface) !important; box-shadow: inset 0 0 0 2px #178447; }
.workbook-cell.is-selected { box-shadow: inset 0 0 0 1px #178447; }
.workbook-cell.is-active { box-shadow: inset 0 0 0 2px #178447; }
.workbook-cell.is-wrapped { white-space: pre-wrap; overflow-wrap: anywhere; }
.workbook-cell.has-comment::before { content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0; border-top: 9px solid #d52b1e; border-left: 9px solid transparent; }
.workbook-cell.is-protected { border-left: 3px solid #b7791f; }
.workbook-fill-handle { position: absolute; z-index: 60; width: 10px; height: 10px; border: 1px solid #fff; background: #178447; cursor: crosshair; }
.workbook-quick-filter { grid-column: 1 / -1; width: 100%; min-width: 0; min-height: 24px; margin: 0; padding: 3px 6px; border-radius: 2px; font-size: 10px; }
.workbook-sheetbar { display: flex; min-height: 34px; align-items: end; gap: 3px; padding: 4px 12px 0; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 93%, var(--page)); }
.workbook-sheet-tab { min-width: 110px; padding: 6px 14px; border: 1px solid var(--line); border-bottom: 2px solid transparent; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 750; text-align: center; }
.workbook-sheet-tab:hover { color: var(--ink); text-decoration: none; }
.workbook-sheet-tab.is-active { border-bottom-color: #178447; color: var(--ink); }
.workbook-statusbar { position: sticky; bottom: 0; z-index: 40; justify-content: flex-start; }
.workbook-status-spacer { flex: 1; }
.workbook-statusbar input[type="range"] { width: 130px; margin: 0; accent-color: #178447; }
.workbook-statusbar output { min-width: 38px; color: var(--ink); font-weight: 750; }
.workbook-mobile-bar { display: none; }
.workbook-view-list, .workbook-comment-list, .workbook-protection-list, .workbook-snapshot-list { display: grid; gap: 6px; margin-top: 12px; }
.workbook-view-list article, .workbook-protection-list article, .workbook-snapshot-list article { display: flex; align-items: center; gap: 6px; padding: 7px; border: 1px solid var(--line); }
.workbook-view-list article > button:first-child { flex: 1; display: grid; gap: 2px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.workbook-view-list small, .workbook-snapshot-list small { display: block; color: var(--muted); }
.workbook-comment-list article { padding: 9px; border-left: 3px solid #1769c2; background: var(--page); }
.workbook-comment-list p { margin: 5px 0; white-space: pre-wrap; }
.workbook-sort-level, .workbook-color-pair { display: grid; grid-template-columns: 24px minmax(0, 1fr) 130px; gap: 7px; margin-top: 7px; }
.workbook-sort-level > span { display: grid; place-items: center; color: var(--muted); font-weight: 850; }
.workbook-color-pair { grid-template-columns: 1fr 1fr; }
.workbook-sort-level select { min-width: 0; margin: 0; }
.workbook-popover .inline-check { flex-direction: row; align-items: center; }
.workbook-popover .inline-check input { margin: 0; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; }
body.workbook-fullscreen-open { overflow: hidden; }
.virtual-workbook.is-fullscreen { position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column; width: 100vw; height: 100dvh; border: 0; border-radius: 0; background: var(--surface); }
.virtual-workbook.is-fullscreen .workbook-viewport { flex: 1; height: auto; min-height: 0; }
.virtual-workbook.is-fullscreen .workbook-titlebar { min-height: 46px; padding-block: 6px; }

body.theme-dark .workbook-ribbon-tabs button[aria-selected="true"], body.theme-dark .workbook-tool-group button.is-active { color: #8ee2b2; }
body.theme-dark .workbook-column-header.is-selected, body.theme-dark .workbook-row-number.is-selected { background: #254f3a; color: #b8f2cf; }
body.theme-dark .workbook-cell.is-selected { box-shadow: inset 0 0 0 1px #62d394; }
body.theme-dark .workbook-cell.is-active { box-shadow: inset 0 0 0 2px #62d394; }
.excel-quick-search input { width: min(260px, 24vw); min-height: 34px; margin: 0; }
.excel-panel.is-excel-fullscreen { position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column; width: 100vw; height: 100dvh; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--surface); }
.excel-panel.is-excel-fullscreen .panel-head { flex: 0 0 auto; padding: 8px 12px; }
.excel-panel.is-excel-fullscreen form { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.excel-panel.is-excel-fullscreen .excel-scroll { flex: 1; max-height: none; }
.excel-table tbody tr[hidden] { display: none; }
.excel-table tbody tr.is-search-match td { box-shadow: inset 0 2px 0 #d79a00, inset 0 -2px 0 #d79a00; }
.excel-search-nav { display: inline-flex; align-items: center; gap: 3px; }
.excel-search-nav[hidden] { display: none; }
.excel-search-nav output { min-width: 58px; color: var(--muted); font-size: 11px; text-align: center; }
.excel-search-nav .icon-button { width: 30px; min-width: 30px; min-height: 30px; padding: 0; }
.supply-assign-panel { overflow: hidden; }
.supply-assign-panel > summary { cursor: pointer; list-style: none; }
.supply-assign-panel > summary::-webkit-details-marker { display: none; }
.supply-assign-panel > summary::after { content: "⌄"; margin-left: 8px; color: var(--muted); font-size: 18px; }
.supply-assign-panel[open] > summary::after { transform: rotate(180deg); }
.supply-assign-panel[open] .supply-assign-form { max-height: 260px; overflow: auto; padding-right: 4px; }

/* Keep the spreadsheet itself dominant in the first viewport. */
.page-head:has(~ .virtual-workbook) { display: none; }
.inventory-tabs { display: inline-flex; max-width: 100%; min-height: 28px; margin: 0 4px 4px 0; gap: 4px; overflow-x: auto; vertical-align: top; }
.inventory-tabs .button { min-height: 28px; padding: 3px 9px; font-size: 11px; }
.virtual-workbook:not(.is-fullscreen) .workbook-viewport { height: min(calc(100dvh - 205px), 780px); min-height: 460px; }
.workbook-titlebar { min-height: 36px; padding: 3px 8px; gap: 6px; }
.workbook-title strong { font-size: 13px; }
.workbook-title span { font-size: 10px; }
.workbook-primary-actions { gap: 5px; }
.workbook-primary-actions .button,
.workbook-primary-actions button { min-height: 30px; padding: 4px 8px; font-size: 11px; }
.workbook-primary-actions .icon-button { width: 30px; min-width: 30px; }
.workbook-presence-avatar, .workbook-presence-more { width: 24px; height: 24px; }
.workbook-ribbon-tabs { min-height: 28px; padding: 1px 6px 0; }
.workbook-ribbon-tabs button { min-height: 26px; padding: 3px 9px; font-size: 11px; }
.workbook-ribbon-toggle { width: 28px; min-width: 28px; margin-left: auto; padding-inline: 0 !important; }
.workbook-toolbar { min-height: 40px; padding: 3px 6px; scrollbar-color: var(--line-strong) transparent; }
.workbook-tool-group { min-height: 30px; padding-left: 5px; gap: 4px; }
.workbook-tool-group button,
.workbook-tool-group select,
.workbook-format-tools label,
.color-tool { min-height: 28px; padding-block: 3px; }
.workbook-toolbar::-webkit-scrollbar { height: 6px; }
.workbook-formula-bar { min-height: 36px; padding: 2px 7px; gap: 5px; }
.workbook-formula-bar textarea { min-height: 28px; padding-block: 4px; }
.workbook-formula-bar .icon-button { min-height: 28px; }
.workbook-formula-bar .workbook-name-box { width: 76px; min-width: 76px; min-height: 28px; flex: 0 0 76px; }
.workbook-statusbar { min-height: 32px; padding: 3px 8px; }
.workbook-sheetbar { min-height: 29px; padding-top: 2px; }
.workbook-sheet-tab { min-width: 92px; padding: 4px 10px; }

@media (min-width: 761px) {
  .virtual-workbook.is-ribbon-collapsed .workbook-toolbar { display: none; }
  .virtual-workbook.is-ribbon-collapsed .workbook-ribbon { border-bottom: 0; }
}

@media (max-width: 760px) {
  .request-sales-comment { display: block; padding: 9px 11px; }
  .request-sales-comment-author { display: block; margin-top: 6px; }
  .virtual-workbook { margin-inline: -8px; border-radius: 0; }
  .workbook-titlebar { display: flex; min-height: 38px; align-items: center; flex-direction: row; gap: 4px; padding: 3px 6px; }
  .workbook-title { display: flex; gap: 4px; }
  .workbook-title span, .workbook-presence { display: none; }
  .workbook-primary-actions { width: auto; margin-left: auto; }
  .workbook-primary-actions .button { display: none; }
  .workbook-primary-actions .workbook-import-button { display: inline-flex; }
  .workbook-primary-actions > * { flex: none; }
  .workbook-ribbon-tabs { overflow-x: auto; padding-inline: 5px; }
  .workbook-ribbon-tabs button:not(.workbook-ribbon-toggle) { min-width: 68px; }
  .workbook-ribbon-toggle { display: none; }
  .workbook-toolbar { display: none; padding: 6px; }
  .workbook-ribbon.is-mobile-open .workbook-toolbar { display: flex; }
  .workbook-ribbon-panel { min-width: max-content; }
  .workbook-find-panel { display: grid; grid-template-columns: 1fr 1fr auto; }
  .workbook-find-panel[hidden] { display: none; }
  .workbook-find-panel input { width: 100%; }
  .workbook-formula-bar { position: sticky; top: 0; z-index: 55; display: grid; grid-template-columns: 52px 20px 1fr 28px; min-height: 38px; gap: 3px; padding: 2px 4px; }
  .workbook-name-box { width: 52px; min-width: 0; flex-basis: auto; }
  .workbook-formula-cancel, .workbook-formula-accept { display: none; }
  .workbook-formula-bar textarea { min-height: 30px; padding-block: 3px; }
  .workbook-formula-hints { left: 7px; width: calc(100vw - 14px); }
  .workbook-viewport { height: calc(100dvh - 260px); min-height: 420px; padding-bottom: 56px; }
  .workbook-sheetbar { display: none; }
  .workbook-statusbar { display: none; }
  .workbook-mobile-bar { position: fixed; right: 0; bottom: 0; left: 0; z-index: 5100; display: grid; grid-template-columns: repeat(5, 1fr); padding: 5px max(5px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); border-top: 1px solid var(--line-strong); background: var(--surface); box-shadow: 0 -8px 24px rgb(15 23 42 / 14%); }
  .workbook-mobile-bar button { min-width: 0; min-height: 44px; padding: 4px 2px; border: 0; background: transparent; color: var(--ink); font-size: 10px; font-weight: 750; }
  .workbook-popover { position: fixed; inset: auto 6px calc(58px + env(safe-area-inset-bottom)) 6px; width: auto; max-height: 68dvh; border-radius: 6px; }
  .workbook-context-menu { width: min(300px, calc(100vw - 20px)); }
  .virtual-workbook.is-fullscreen .workbook-viewport { height: auto; }
  .virtual-workbook.is-fullscreen .workbook-mobile-bar { display: grid; }
  .excel-quick-search { order: 5; width: 100%; }
  .excel-quick-search input { width: 100%; }
  .excel-panel.is-excel-fullscreen .excel-tools { display: flex; }
  .supply-assign-panel { padding: 8px 10px; }
  .supply-assign-panel > summary { margin: 0; }
  .supply-assign-panel[open] .supply-assign-form { max-height: 54dvh; margin-top: 8px; }
  .excel-panel { width: 100%; min-width: 0; margin-inline: 0; padding: 8px; overflow: hidden; }
  .excel-panel .panel-head { gap: 6px; align-items: flex-start; }
  .excel-panel .panel-head h2 { font-size: 16px; }
  .excel-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .excel-tools .table-legend { display: none; }
  .excel-quick-search { grid-column: 1; order: initial; }
  .excel-search-nav { grid-column: 2; }
  .zoom-controls { grid-column: 1 / -1; width: 100%; padding: 2px; }
  .zoom-controls button { min-height: 28px; }
  .excel-formula-bar { grid-template-columns: 58px 28px minmax(0, 1fr); gap: 4px; margin-bottom: 5px; padding: 4px; }
  .excel-formula-bar .formula-name-box, .excel-formula-bar .formula-fx { min-height: 32px; }
  .excel-formula-bar input { grid-column: 3; min-width: 0; }
  .excel-formula-bar button { display: none; }
  .excel-scroll { width: 100%; max-width: 100%; margin-inline: 0; }
  .excel-selection-status { max-width: 100%; gap: 5px; overflow-x: auto; white-space: nowrap; }
  .excel-panel.is-excel-fullscreen { max-width: 100vw; overflow: hidden; }
  .excel-panel.is-excel-fullscreen .panel-head { padding: 4px 7px; }
  .excel-panel.is-excel-fullscreen .panel-head h2 { display: none; }
  .excel-panel.is-excel-fullscreen .excel-tools { width: 100%; grid-template-columns: minmax(0, 1fr) auto; }
  .excel-panel.is-excel-fullscreen .zoom-controls { display: none; }
  .excel-panel.is-excel-fullscreen .excel-formula-bar { flex: 0 0 auto; }
  .excel-panel.is-excel-fullscreen .excel-scroll { min-height: 0; }
  .page-head.row:has(+ .excel-panel) { gap: 6px; margin-bottom: 8px; }
  .page-head.row:has(+ .excel-panel) h1 { margin: 0; font-size: 22px; }
  .page-head.row:has(+ .excel-panel) p { margin: 2px 0; font-size: 12px; line-height: 1.25; }
  .page-head.row:has(+ .excel-panel) .request-head-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .page-head.row:has(+ .excel-panel) .request-pager { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .page-head.row:has(+ .excel-panel) .request-pager .button { min-height: 32px; padding: 5px 3px; font-size: 10px; }
  .page-head.row:has(+ .excel-panel) .request-head-actions .status { width: auto; min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .page-head.row:has(+ .excel-panel) .request-head-actions .inline-form { width: auto; }
  .page-head.row:has(+ .excel-panel) .request-head-actions button.danger { width: auto; min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .excel-panel:not(.is-excel-fullscreen) > .panel-head h2 { display: none; }
  .excel-panel:not(.is-excel-fullscreen) > .panel-head { min-height: 0; margin-bottom: 4px; padding: 0; }
  .excel-panel:not(.is-excel-fullscreen) .excel-tools { gap: 3px; }
  .excel-panel:not(.is-excel-fullscreen) .excel-quick-search input { min-height: 30px; }
  .excel-panel:not(.is-excel-fullscreen) [data-excel-fullscreen] { grid-column: 2; grid-row: 1; width: 34px; min-width: 34px; min-height: 30px; padding: 0; }
  .excel-panel:not(.is-excel-fullscreen) .zoom-controls { min-height: 30px; padding: 1px; }
  .excel-panel:not(.is-excel-fullscreen) .zoom-controls button { min-height: 27px; padding-block: 2px; }
  .excel-panel:not(.is-excel-fullscreen) .excel-formula-bar { height: 38px; min-height: 38px; margin-bottom: 3px; padding: 2px 3px; overflow: hidden; }
  .excel-panel:not(.is-excel-fullscreen) .excel-formula-bar .formula-name-box,
  .excel-panel:not(.is-excel-fullscreen) .excel-formula-bar .formula-fx { min-height: 30px; }
  .excel-panel:not(.is-excel-fullscreen) .excel-formula-bar input { min-height: 30px; }
}

@media (max-width: 620px) {
  .inventory-import-dialog { max-height: calc(100dvh - 16px); padding: 14px; }
  .inventory-import-stats { grid-template-columns: repeat(2, 1fr); }
  .inventory-import-stats div:nth-child(2) { border-right: 0; }
  .inventory-import-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .inventory-import-history-list article { align-items: flex-start; }
  .inventory-import-sheet-list { max-height: 190px; }
}

@media (max-width: 900px) {
  .inventory-search {
    grid-template-columns: 1fr;
  }

  .inventory-search-toggle,
  .inventory-search button,
  .inventory-search [data-inventory-search-count] {
    width: 100%;
  }

  .inventory-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Request drafts and the request workbook reuse the inventory workspace language. */
.request-drafts { display: grid; gap: 10px; margin-bottom: 14px; }
.request-drafts-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.request-drafts-head h2, .request-drafts-head p { margin: 0; }
.request-drafts-head h2 { font-size: 16px; }
.request-drafts-head p { color: var(--muted); font-size: 12px; }
.request-drafts-head > span {
  min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  background: #e8f3ec; color: #126f3b; font-weight: 850;
}
.request-draft-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.request-draft-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start;
  gap: 8px; min-width: 0; padding: 10px 10px 10px 12px; border: 1px solid var(--line);
  border-left: 4px solid #178447; border-radius: 7px; background: var(--surface);
}
.request-draft-card > a { min-width: 0; display: grid; gap: 3px; color: var(--ink); }
.request-draft-card strong, .request-draft-card span, .request-draft-card small {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.request-draft-card span { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.request-draft-card small { color: var(--muted); font-size: 11px; }
.request-draft-card form { margin: 0; }
.request-draft-card .icon-button { width: 30px; min-width: 30px; min-height: 30px; padding: 0; }
.request-create-fields { margin-bottom: 10px; padding-block: 12px; }
.request-workbook { min-width: 0; padding: 0; overflow: visible; }
.request-workbook .workbook-titlebar { border-radius: var(--radius) var(--radius) 0 0; }
.request-draft-state { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.request-draft-state[data-state="dirty"] { color: #8a5b00; }
.request-draft-state[data-state="saving"] { color: #1769c2; }
.request-draft-state[data-state="saved"] { color: #126f3b; }
.request-draft-state[data-state="error"] { color: var(--danger); }
.request-workbook-ribbon .workbook-toolbar { min-height: 48px; }
.request-workbook-ribbon .workbook-ribbon-panel { min-height: 34px; }
.request-workbook-ribbon .workbook-search-wrap { flex: 1 1 420px; }
.request-workbook-ribbon .excel-search-nav { display: inline-flex; align-items: center; gap: 4px; }
.request-workbook-ribbon .excel-search-nav[hidden] { display: none; }
.request-formula-bar.excel-formula-bar {
  display: flex; grid-template-columns: none; align-items: center; gap: 6px; min-height: 45px;
  height: auto; margin: 0; padding: 6px 10px; border-width: 0 0 1px; border-radius: 0; background: var(--surface);
}
.request-formula-bar .formula-name-box {
  flex: 0 0 92px; width: 92px; min-height: 32px; justify-content: center; padding: 5px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.request-formula-bar > .icon-button { width: 30px; min-width: 30px; min-height: 30px; padding: 0; }
.request-formula-bar [data-cell-formula-input] {
  flex: 1 1 320px; min-width: 120px; min-height: 32px; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.request-formula-bar.is-reference-mode,
.virtual-workbook.is-formula-reference-mode .workbook-formula-bar { box-shadow: inset 0 -2px 0 #178447; }
.excel-table.is-formula-reference-mode td[data-row][data-key],
.virtual-workbook.is-formula-reference-mode .workbook-cell { cursor: crosshair; }
.request-workbook .excel-scroll {
  min-height: 420px; max-height: min(68vh, 820px); margin: 0; border-width: 0 0 1px; border-radius: 0;
}
.request-workbook .excel-selection-status.workbook-statusbar {
  min-height: 38px; display: flex; align-items: center; gap: 14px; margin: 0; padding: 7px 12px;
  border-top: 0; background: var(--surface);
}
.request-workbook .excel-selection-status [data-excel-selection-address] { color: var(--ink); font-weight: 750; }
body.theme-dark .request-draft-card,
body.theme-dark .request-formula-bar.excel-formula-bar,
body.theme-dark .request-workbook .excel-selection-status.workbook-statusbar { background: var(--surface); color: var(--ink); }
body.theme-dark .request-drafts-head > span { background: #183a2b; color: #8ee0ac; }

/* Preserve imported Excel fills while keeping range selection visible in both themes. */
.workbook-cell.is-selected {
  background-image: linear-gradient(rgba(23, 132, 71, .13), rgba(23, 132, 71, .13));
  box-shadow: inset 0 0 0 1px rgba(23, 132, 71, .65);
}
body.theme-dark .workbook-cell.is-selected {
  background-image: linear-gradient(rgba(98, 211, 148, .16), rgba(98, 211, 148, .16));
  box-shadow: inset 0 0 0 1px rgba(98, 211, 148, .75);
}
.workbook-cell.is-active,
body.theme-dark .workbook-cell.is-active {
  box-shadow: inset 0 0 0 2px #178447;
}

@media (min-width: 1180px) {
  .request-create-fields.form-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, .9fr);
    align-items: start;
    gap: 8px 10px;
  }
  .request-create-fields > .organization-picker,
  .request-create-fields > label.wide { grid-column: auto; }
  .request-create-fields > label {
    align-content: start;
    grid-template-rows: auto 42px;
    min-width: 0;
  }
  .request-create-fields > label > input:not([type="hidden"]),
  .request-create-fields > label > select,
  .request-create-fields > label > textarea {
    width: 100%;
    height: 42px;
    min-height: 42px;
  }
  .request-create-fields input[type="file"] { padding-block: 6px; }
  .request-create-fields textarea[name="sales_area"] { height: 42px; min-height: 42px; resize: vertical; }
}

.excel-panel.request-workbook:not(.is-excel-fullscreen) .request-formula-bar.excel-formula-bar {
  height: auto;
  min-height: 45px;
  padding: 6px 10px;
}

@media (max-width: 760px) {
  .request-workbook .workbook-titlebar { align-items: flex-start; flex-wrap: wrap; }
  .request-draft-state { order: 3; width: 100%; margin-left: 0; white-space: normal; }
  .request-workbook .workbook-primary-actions { margin-left: auto; }
  .request-formula-bar.excel-formula-bar { flex-wrap: wrap; }
  .request-formula-bar [data-cell-formula-input] { order: 5; flex-basis: 100%; }
  .request-workbook .excel-scroll { min-height: 56vh; max-height: 68vh; }
}
