:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f5f8fc;
  --blue: #2365cf;
  --blue-dark: #174fae;
  --text-soft: #6c7890;
  --line: #e3eaf4;
  --green: #087443;
  --red: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; padding: 27px 16px 20px; color: #dce9ff; background: #10254b; }
.brand { display: inline-flex; align-items: center; gap: 10px; padding: 0 12px; color: #fff; font-size: 19px; letter-spacing: -.04em; text-decoration: none; }
.brand strong { font-weight: 800; }
.brand small { display: block; margin-top: 2px; color: #9fb8e4; font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #1f5fcc; background: #fff; font-size: 17px; font-weight: 800; }
.main-nav { display: grid; gap: 5px; margin-top: 58px; }
.nav-item, .sidebar-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; border: 0; border-radius: 9px; color: #a9bddf; background: transparent; font-size: 13px; font-weight: 700; text-align: left; text-decoration: none; }
.nav-item span, .sidebar-link span { width: 17px; color: #83a8df; font-size: 17px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: #1d4d99; }
.nav-item.active span { color: #a9d1ff; }
.sidebar-footer { display: grid; gap: 5px; margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-link { color: #9fb8e4; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.content { min-width: 0; padding: 36px clamp(20px, 4vw, 62px) 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { display: block; margin-bottom: 8px; color: #3274dd; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 3vw, 38px); letter-spacing: -.055em; }
h2 { margin-bottom: 0; font-size: 23px; letter-spacing: -.04em; }
h3 { margin-bottom: 4px; font-size: 17px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.company-picker { display: block; min-width: 210px; color: var(--text-soft); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
select, input, textarea { width: 100%; padding: 10px 11px; border: 1px solid #d5deeb; border-radius: 8px; color: #172033; background: #fff; outline: 0; }
.company-picker select { margin-top: 5px; padding: 9px 10px; font-size: 13px; font-weight: 600; text-transform: none; }
select:focus, input:focus, textarea:focus { border-color: #3175df; box-shadow: 0 0 0 3px rgba(49,117,223,.13); }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: max-content; color: #273653; font-size: 12px; }
.user-chip strong, .user-chip small { display: block; }
.user-chip small { margin-top: 3px; color: var(--text-soft); font-size: 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #1c5fc4; background: #dceaff; font-size: 12px; font-weight: 800; }
.muted { color: var(--text-soft); line-height: 1.5; }
.muted-count { color: var(--text-soft); font-size: 11px; }
.global-message { min-height: 20px; margin: -13px 0 12px; color: var(--green); font-size: 13px; }
.global-message.error { color: var(--red); }
.loading-card, .empty-state { padding: 42px 20px; border: 1px solid var(--line); border-radius: 14px; color: var(--text-soft); background: #fff; text-align: center; }
.spinner { display: inline-block; width: 17px; height: 17px; margin-right: 8px; vertical-align: -3px; border: 2px solid #d9e6fb; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading p { margin: 0; color: var(--text-soft); font-size: 13px; }
.heading-actions { display: flex; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border: 0; border-radius: 8px; font-size: 12px; font-weight: 800; text-decoration: none; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #315b9c; background: #eaf2ff; }
.button.ghost { color: #53627b; background: #f1f4f8; }
.button.danger { color: var(--red); background: #fff0ef; }
.button.small { padding: 7px 9px; font-size: 11px; }
.button:disabled { opacity: .6; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { padding: 18px 19px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.metric-card small { display: block; margin-bottom: 12px; color: var(--text-soft); font-size: 11px; font-weight: 700; }
.metric-card strong { display: block; font-size: 25px; letter-spacing: -.04em; }
.metric-card em { display: block; margin-top: 5px; color: #8995a8; font-size: 11px; font-style: normal; }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; }
.panel { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-heading small { color: var(--text-soft); font-size: 11px; }
.mini-list { display: grid; gap: 8px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf1f6; font-size: 12px; }
.mini-row:last-child { border-bottom: 0; }
.mini-row strong, .mini-row small { display: block; }
.mini-row small { margin-top: 3px; color: var(--text-soft); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.table-toolbar input { max-width: 300px; padding: 9px 11px; font-size: 12px; }
.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th { padding: 12px 14px; color: #7a879b; background: #f8fafd; font-size: 10px; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
td { padding: 14px; border-top: 1px solid #edf1f6; color: #34425c; font-size: 12px; vertical-align: middle; }
td strong { color: #202e48; }
td small { display: block; margin-top: 3px; color: var(--text-soft); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 4px 8px; border-radius: 999px; color: #315b9c; background: #eaf2ff; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.success { color: #176342; background: #dff7eb; }
.badge.warning { color: #8c4a0a; background: #fff0d6; }
.badge.danger { color: #a62b22; background: #fff0ef; }
.badge.neutral { color: #5f6d83; background: #eef1f5; }
.low-stock { color: #a62b22; font-weight: 800; }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 20, 43, .55); }
.modal-card { position: relative; width: min(100%, 720px); max-height: calc(100vh - 40px); overflow: auto; padding: 25px; border-radius: 15px; background: #fff; box-shadow: 0 24px 80px rgba(7,24,59,.25); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-header .eyebrow { margin-bottom: 5px; }
.close-button { width: 30px; height: 30px; border: 0; border-radius: 50%; color: #64728a; background: #f0f3f7; font-size: 22px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: block; color: #43516a; font-size: 11px; font-weight: 800; }
.field input, .field select, .field textarea { display: block; margin-top: 6px; font-size: 13px; font-weight: 400; }
.field textarea { min-height: 80px; resize: vertical; }
.check-field { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; color: #43516a; font-size: 12px; font-weight: 700; }
.check-field input { width: 16px; height: 16px; accent-color: var(--blue); }
.form-error { min-height: 20px; margin-top: 14px; color: var(--red); font-size: 12px; line-height: 1.4; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #edf1f6; }
.item-editor { display: grid; gap: 8px; margin-top: 16px; }
.item-editor-heading, .item-row { display: grid; grid-template-columns: 1.6fr .65fr .85fr .8fr auto; align-items: end; gap: 8px; }
.item-editor-heading { color: #7a879b; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.item-row .field { font-size: 0; }
.item-row .field input, .item-row .field select { margin-top: 0; font-size: 12px; }
.remove-item { width: 31px; height: 35px; border: 0; border-radius: 7px; color: var(--red); background: #fff0ef; font-size: 17px; }
.document-items { display: grid; gap: 8px; margin: 15px 0; }
.document-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf1f6; color: #47556d; font-size: 12px; }
.document-item:last-child { border-bottom: 0; }
.document-total { display: flex; justify-content: space-between; margin-top: 16px; color: #1f2d47; font-size: 16px; font-weight: 800; }
.detail-notes { margin: 18px 0 0; }
.detail-history-title { margin-top: 24px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; padding: 12px 15px; border-radius: 9px; color: #fff; background: #172e56; box-shadow: 0 12px 32px rgba(14,33,69,.2); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #9b2b22; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1050px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .app-shell { display: block; } .sidebar { position: sticky; top: 0; z-index: 5; padding: 14px; } .main-nav { display: flex; overflow-x: auto; margin-top: 15px; } .nav-item { min-width: max-content; } .sidebar-footer { display: none; } .content { padding: 25px 15px 45px; } .topbar, .topbar-actions, .page-heading { align-items: stretch; flex-direction: column; } .topbar-actions { gap: 10px; } .company-picker { width: 100%; } .user-chip { align-self: flex-start; } .form-grid { grid-template-columns: 1fr; } .form-grid .full { grid-column: auto; } .item-editor { overflow-x: auto; } .item-editor-heading, .item-row { min-width: 600px; } }
