@layer reset, base, components, responsive;
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, p, dl, dd { margin: 0; }
  button, input, select, textarea { font: inherit; }
  a { color: inherit; text-decoration: none; }
  [hidden] { display: none !important; }
}
@layer base {
  :root {
    color-scheme: light;
    --ink: #14223a;
    --muted: #51647f;
    --border: #dbe4f1;
    --canvas: #f4f7fc;
    --green: #1554bb;
    --dark: #0b1b34;
    --radius: 16px;
    font: 15px/1.5 "Geist", "Inter", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
  }
  h1 { font-size: clamp(1.85rem, 3.4vw, 2.55rem); line-height: 1.16; letter-spacing: -.048em; }
  h2 { font-size: 1.14rem; letter-spacing: -.022em; }
  p { color: var(--muted); }
  small, .muted { color: var(--muted); }
  [disabled] { opacity: .65; cursor: not-allowed; }
  :focus-visible { outline: 3px solid #31a68a; outline-offset: 3px; }
}
@layer components {
  .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
  .sidebar { display: flex; flex-direction: column; background: var(--dark); color: #f0faf5; min-height: 100vh; padding: 24px 17px 17px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .brand { display: flex; gap: 12px; align-items: center; font-size: 1.22rem; font-weight: 750; letter-spacing: -.025em; padding: 0 8px; }
  .brand-mark, .avatar, .tile { display: grid; place-items: center; flex: none; }
  .brand-mark { width: 39px; height: 39px; border-radius: 11px; color: #12332a; background: #76d9ff; font-weight: 850; font-size: 1.4rem; }
  .brand-sub { display: block; color: #a7bdd9; font-size: .72rem; font-weight: 550; letter-spacing: .02em; }
  .sidebar nav { margin: 24px 0; }
  .nav-section { font-size: .68rem; color: #a7bdd9; letter-spacing: .13em; text-transform: uppercase; font-weight: 700; margin: 15px 9px 6px; }
  .nav-link { display: flex; gap: 10px; align-items: center; min-height: 37px; border-radius: 8px; padding: 5px 9px; color: #dbe8fa; font-weight: 550; }
  .nav-link > span { width: 22px; text-align: center; color: #a8c5e6; font-size: 1.13rem; }
  .nav-link:hover, .nav-link.selected { background: #1b3965; color: white; }
  .nav-link.selected > span { color: #76d9ff; }
  .identity { display: flex; align-items: center; gap: 10px; margin-top: auto; border-top: 1px solid #365047; padding: 14px 5px 0; }
  .avatar { width: 34px; height: 34px; border-radius: 50%; color: #76d9ff; background: #26473e; font-weight: 750; }
  .identity-text { overflow-wrap: anywhere; font-weight: 600; }
  .identity small { display: block; color: #a7bdd9; font-weight: 400; }
  .workspace { min-width: 0; }
  .topbar { display: flex; padding: 0 clamp(16px, 3vw, 42px); min-height: 65px; align-items: center; justify-content: space-between; background: white; border-bottom: 1px solid var(--border); gap: 15px; }
  .top-start { display: flex; align-items: center; gap: 12px; }
  .breadcrumb { color: var(--muted); font-size: .88rem; font-weight: 630; }
  .breadcrumb span { margin: 0 6px; color: #82948c; }
  .topbar .mobile-toggle { display: none; }
  .main { max-width: 1570px; margin-inline: auto; padding: 29px clamp(16px, 3vw, 42px) 48px; }
  .page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 21px; }
  .page-head p { margin-top: 7px; }
  .date-line { color: var(--green); font-weight: 720; font-size: .78rem; letter-spacing: .02em; margin-bottom: 5px; }
  .button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 8px 14px; border: 1px solid transparent; border-radius: 9px; font-size: .88rem; font-weight: 680; white-space: nowrap; cursor: pointer; background: white; color: var(--ink); }
  .primary { background: var(--green); color: white; }
  .primary:hover { background: #123f8b; }
  .secondary { border-color: var(--border); }
  .secondary:hover, .quiet:hover { background: #edf6f1; }
  .quiet { color: var(--muted); }
  .danger { color: #942c30; border-color: #efcfd0; }
  .danger:hover { background: #fff2f2; }
  .wide { width: 100%; }
  .card { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 2px 6px #12382b07; min-width: 0; }
  .metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
  .metric { padding: 16px; }
  .metric p { font-weight: 650; font-size: .87rem; margin-top: 7px; }
  .metric strong { display: block; font-size: clamp(1.1rem, 2vw, 1.77rem); line-height: 1.24; letter-spacing: -.035em; overflow-wrap: anywhere; margin: 3px 0; }
  .metric small { display: block; font-size: .76rem; }
  .metric.compact { min-width: 155px; padding: 9px 13px; }
  .tile { width: 34px; height: 34px; border-radius: 9px; font-size: 1rem; font-weight: 750; }
  .mint { background: #def4e9; color: #176044; }
  .lavender { background: #efeafd; color: #5a3a9d; }
  .sky { background: #e5f1fb; color: #285b87; }
  .amber { background: #fff1d7; color: #805210; }
  .pill { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: .74rem; white-space: nowrap; font-weight: 720; align-items: center; }
  .dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: stretch; }
  .card-heading { padding: 17px 18px; display: flex; align-items: start; justify-content: space-between; gap: 10px; }
  .card-heading p { font-size: .83rem; margin-top: 2px; }
  .text-link { color: var(--green); font-size: .86rem; font-weight: 720; }
  .text-link:hover, .back:hover { text-decoration: underline; }
  .chart { display: flex; gap: clamp(7px, 1.8vw, 24px); height: 185px; align-items: stretch; padding: 1px 20px 12px; }
  .chart-point { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .75rem; text-align: center; }
  .bar-track { flex: 1; position: relative; border-bottom: 1px solid var(--border); background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), #edf2ef calc(25% - 1px) 25%); }
  .chart-bar { position: absolute; bottom: 0; left: 14%; width: 72%; background: linear-gradient(#43c7f9, #1857cd); height: max(3px, var(--height)); border-radius: 7px 7px 2px 2px; }
  .stock-card { padding-bottom: 14px; }
  .stock-card .wide { width: calc(100% - 36px); margin: 10px 18px 0; }
  .stock-row { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-top: 1px solid #edf2ef; }
  .stock-row > div { min-width: 0; flex: 1; overflow-wrap: anywhere; }
  .stock-row strong { font-size: .86rem; }
  .stock-row small, .block { display: block; }
  .empty { text-align: center; padding: 24px; color: var(--muted); }
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: .87rem; }
  th, td { padding: 10px 15px; text-align: left; border-top: 1px solid #e6eee9; white-space: nowrap; }
  th { font-size: .75rem; color: var(--muted); background: #f8fbf9; }
  td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
  .cell-actions { display: flex; gap: 11px; }
  .tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 15px; }
  .tabs a { padding: 7px 11px; border-radius: 7px; color: var(--muted); font-size: .83rem; font-weight: 680; }
  .tabs a:hover, .tabs .current { background: #dfefe7; color: var(--green); }
  .filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 11px; padding: 13px 15px; }
  .filters input[type="search"] { min-width: 220px; }
  .check { display: flex; align-items: center; align-self: center; gap: 6px; }
  .check input { width: auto; min-height: auto; }
  .back { display: inline-block; color: var(--green); font-weight: 650; margin-bottom: 12px; }
  .editor { padding: clamp(15px, 3vw, 25px); max-width: 1020px; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 15px; align-items: start; }
  label { display: grid; gap: 5px; font-weight: 650; color: var(--ink); font-size: .85rem; min-width: 0; }
  input, select, textarea { width: 100%; min-width: 0; min-height: 39px; border: 1px solid #cddbd4; border-radius: 8px; padding: 8px 10px; color: var(--ink); background: white; font-weight: 450; }
  input[readonly] { background: #f4f7f5; }
  textarea { resize: vertical; }
  .form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
  .lines { border: 1px solid var(--border); border-radius: 9px; margin: 15px 0; min-width: 0; padding: 10px 12px 12px; }
  .lines legend { font-weight: 720; padding: 0 5px; }
  .line-row { display: grid; align-items: end; grid-template-columns: minmax(0, 2fr) minmax(75px, .65fr) minmax(100px, .9fr) auto; gap: 7px; margin-bottom: 10px; }
  [data-document$="returns"] .line-row { grid-template-columns: minmax(0, 2fr) minmax(75px, .65fr) auto; }
  .form-total { display: flex; flex-direction: column; justify-content: center; padding: 5px 10px; border-radius: 8px; background: #e5f4eb; color: var(--green); }
  .form-total output { font-size: 1.2rem; font-weight: 750; }
  .fulfillment { margin-top: 16px; }
  .fulfillment .filters { padding-inline: 0; }
  .invoice { padding: clamp(15px, 4vw, 35px); border-top: 5px solid var(--invoice-color, var(--green)); }
  .invoice-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
  .invoice-head h2 { margin-top: 4px; font-size: 1.65rem; }
  .invoice-details { display: flex; flex-wrap: wrap; gap: 15px 25px; margin: 20px 0; }
  .invoice-details dt, .invoice-totals dt { color: var(--muted); font-size: .84rem; }
  dd { font-weight: 700; }
  .invoice-totals { display: grid; max-width: 300px; margin: 16px 0 0 auto; gap: 6px; }
  .invoice-totals div { display: flex; justify-content: space-between; gap: 10px; }
  .preserve { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 12px; }
  .pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px; color: var(--muted); font-size: .83rem; }
  .alert { padding: 10px 14px; margin-bottom: 14px; border-radius: 8px; }
  .alert ul { margin: 4px 0 0; }
  .alert.success { color: #17523e; background: #dff4e9; }
  .alert.error { color: #8c2a31; background: #fff0f0; }
  .login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
  .login-side { background: radial-gradient(ellipse at 90% 90%, #24594b, var(--dark) 63%); color: white; padding: clamp(25px, 6vw, 83px); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
  .login-side { background: #071524; align-items: stretch; }
  .login-side .brand { padding: 0; margin-bottom: 22px; justify-content: center; }
  .division-art { display: block; width: min(100%, 490px); height: auto; margin: 0 auto; border-radius: 18px; }
  .pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 16px; }
  .stage-card { padding: 12px 15px; display: grid; gap: 3px; color: var(--muted); }
  .stage-card strong { color: var(--ink); font-size: 1.42rem; }
  .stage-selected { border-color: #3c83e7; background: #eaf4ff; }
  .stage-card:last-child { border-left: 3px solid #df9b22; }
  .editor > h2 { margin-bottom: 13px; }
  .editor label + label { margin-top: 8px; }
  .editor .form-grid label + label { margin-top: 0; }
  .activity-detail, .timeline-event { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .timeline-event small { display: block; }
  .timeline-event p { margin-top: 4px; }
  .workstation { margin-bottom: 16px; padding-bottom: 14px; }
  .workstation-controls { display: flex; align-items: center; flex-wrap: wrap; padding: 0 18px; gap: 10px; }
  .workstation-setup { display: grid; gap: 8px; padding: 10px 18px 0; }
  .workstation-setup code { overflow-wrap: anywhere; }
  .lead-contact { margin-bottom: 13px; }
  .lead-contact div { margin-bottom: 8px; }
  .lead-contact dt { color: var(--muted); }
  .lead-contact dd { overflow-wrap: anywhere; white-space: pre-wrap; }
  .login-side h1 { font-size: clamp(2rem, 5vw, 4.1rem); }
  .login-side p { color: #cddfd6; margin-top: 16px; }
  .login-main { display: grid; place-items: center; padding: 24px; }
  .login-form { width: min(100%, 410px); display: grid; gap: 14px; padding: clamp(16px, 4vw, 30px); background: white; border: 1px solid var(--border); border-radius: var(--radius); }
  .login-password { display: grid; gap: 5px; }
  .login-password-field { position: relative; }
  .login-password-field input { display: block; }
  .login-password-field input:has(+ .password-toggle:not([hidden])) { padding-inline-end: 48px; }
  .password-toggle { position: absolute; inset-block: 2px; inset-inline-end: 2px; width: 42px; min-height: 0; padding: 0; background: transparent; }
  .password-toggle:hover { background: var(--border); }
  .password-toggle-slash { display: none; }
  .login-password-field input[type="text"] + .password-toggle .password-toggle-slash { display: inline; }
}
@layer responsive {
  @media (max-width: 1050px) {
    .shell { grid-template-columns: 190px minmax(0, 1fr); }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 800px) {
    .shell { display: block; }
    .sidebar { display: none; position: fixed; width: min(260px, 82vw); height: 100dvh; z-index: 5; box-shadow: 8px 0 40px #10272240; }
    .sidebar.open { display: flex; }
    .topbar .mobile-toggle { display: inline-flex; }
    .dashboard-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 540px) {
    .page-head { align-items: start; flex-direction: column; }
    .metrics { gap: 8px; }
    .metric { padding: 10px; }
    .form-grid { grid-template-columns: 1fr; }
    .line-row, [data-document$="returns"] .line-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
    .line-row label:first-child { grid-column: 1 / -1; }
    .login-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .login-side { padding: 20px; }
    .login-side .brand { margin: 0; }
    .division-art { display: none; }
  }
  @media print {
    .sidebar, .topbar, .back, .no-print, .pagination { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    :root { background: white; }
    .card { box-shadow: none; }
    th, td { white-space: normal; }
  }
}
