:root {
    --green-950: #12351d;
    --green-900: #1c5928;
    --green-800: #2d8438;
    --green-700: #43ad3d;
    --green-100: #dcf2d7;
    --green-50: #f1faee;
    --lime-500: #55df18;
    --amber-500: #e3b51b;
    --amber-100: #fff3c9;
    --red-700: #a72f2f;
    --red-100: #fde5e2;
    --ink: #18231a;
    --muted: #68746a;
    --line: #dfe8dc;
    --surface: #ffffff;
    --canvas: #f6f8f3;
    --shadow: 0 18px 45px rgba(31, 77, 35, .09);
    --shadow-sm: 0 7px 22px rgba(31, 77, 35, .07);
    --radius: 18px;
    --brand-logo-image: url('../img/logo.webp');
  }

  * { box-sizing: border-box; }
  html {
    min-height: 100%;
    background: var(--canvas);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  html { max-width: 100%; overflow-x: hidden; }
  body { max-width: 100%; }
  body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  body.sidebar-open { overflow: hidden; }
  button, input, select, textarea { font: inherit; }
  button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .hidden { display: none !important; }
  .muted { color: var(--muted); }
  code { padding: 2px 6px; border-radius: 6px; background: #edf1ed; font-size: .88em; }
  .eyebrow {
    margin: 0 0 7px;
    color: var(--green-700);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .13em;
  }
  .eyebrow.light { color: #d9f1d0; }

  .login-view {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  }
  .login-art {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 100vh;
    min-height: 100dvh;
    padding: clamp(40px, 7vw, 92px);
    overflow: hidden;
    color: #fff;
    background:
      radial-gradient(circle at 17% 18%, rgba(227, 181, 27, .26), transparent 29%),
      radial-gradient(circle at 84% 20%, rgba(85, 223, 24, .22), transparent 27%),
      linear-gradient(145deg, #15391e 0%, #23682d 58%, #977317 145%);
  }
  .login-art::before, .login-art::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
  }
  .login-art::before { width: 520px; height: 520px; right: -190px; top: -160px; }
  .login-art::after { width: 330px; height: 330px; left: -150px; bottom: 18%; }
  .login-art-content { position: relative; z-index: 1; max-width: 690px; }
  .brand-logo-image { background-color: #fff; background-image: var(--brand-logo-image); background-repeat: no-repeat; }
  .hero-brand-logo {
    width: min(270px, 70vw); height: 126px; margin-bottom: 32px;
    border: 1px solid rgba(255,255,255,.5); border-radius: 24px;
    background-position: center 51%; background-size: 202% auto;
    box-shadow: 0 16px 35px rgba(13,54,20,.16);
  }
  .login-art h1 { margin: 0; max-width: 650px; font-size: clamp(32px, 5vw, 68px); line-height: 1.02; letter-spacing: -.045em; }
  .login-art p:not(.eyebrow) { max-width: 590px; margin: 24px 0 0; color: rgba(255,255,255,.76); font-size: 18px; line-height: 1.65; }
  .feature-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
  .feature-pills span { padding: 9px 13px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.07); font-size: 13px; }
  .login-panel { display: grid; place-items: center; padding: 44px; background: #fbfcfa; }
  .login-card { width: min(100%, 420px); }
  .login-card h2 { margin: 0; font-size: clamp(28px, 7vw, 36px); letter-spacing: -.035em; }
  .login-card > .muted { margin: 10px 0 31px; }
  .brand-mobile { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; color: var(--green-900); font-size: 16px; font-weight: 900; letter-spacing: .025em; }
  .login-help { margin: 24px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

  .field, .compact-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
  .field { margin-bottom: 16px; }
  .field > span:first-child, .compact-field > span:first-child { color: #465248; font-size: 12px; font-weight: 750; }
  input, select, textarea {
    width: 100%; max-width: 100%; min-height: 45px; padding: 11px 13px;
    color: var(--ink); background: #fff;
    border: 1px solid #d8e0d9; border-radius: 11px; outline: none;
    font-size: 16px;
    transition: border-color .18s, box-shadow .18s, background .18s;
  }
  textarea { resize: vertical; }
  input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(39, 122, 78, .13); }
  input:disabled, select:disabled, textarea:disabled { color: #879188; background: #f0f3f0; cursor: not-allowed; }
  .password-wrap { position: relative; display: block; }
  .password-wrap input { padding-right: 62px; }
  .password-toggle { position: absolute; right: 7px; top: 7px; height: 31px; padding: 0 9px; border: 0; border-radius: 7px; color: var(--green-800); background: var(--green-50); font-size: 11px; font-weight: 800; cursor: pointer; }
  .form-error { min-height: 18px; margin: 12px 0 0; color: var(--red-700); font-size: 13px; text-align: center; }

  .btn {
    min-height: 43px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px;
    font-weight: 750; cursor: pointer; transition: transform .12s, box-shadow .18s, background .18s;
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active { transform: translateY(0); }
  .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
  .btn-primary { color: #fff; background: linear-gradient(135deg, var(--green-700), var(--green-800)); box-shadow: 0 7px 17px rgba(45,132,56,.2); }
  .btn-primary:hover { background: var(--green-900); }
  .btn-secondary { color: var(--green-900); border-color: #d4ded5; background: #fff; }
  .btn-secondary:hover { background: var(--green-50); }
  .btn-warning { color: #5a3c00; background: #ffd976; }
  .btn-light { color: var(--green-950); background: #fff; box-shadow: var(--shadow-sm); }
  .btn-danger { color: #fff; background: var(--red-700); }
  .btn-small { min-height: 31px; padding: 5px 9px; border-radius: 8px; font-size: 11px; }
  .btn-block { width: 100%; }

  .app-shell { min-height: 100vh; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: 262px; display: flex; flex-direction: column;
    padding: 23px 17px 17px; color: #fff;
    background:
      radial-gradient(circle at 18% 4%, rgba(85,223,24,.14), transparent 24%),
      linear-gradient(180deg, #194a22 0%, #102f18 100%);
    box-shadow: 10px 0 30px rgba(16, 47, 33, .08);
  }
  .sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 1px 9px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
  .brand-logo {
    width: 43px; height: 43px; flex: 0 0 43px; display: inline-block;
    border: 1px solid rgba(255,255,255,.46); border-radius: 13px;
    background-position: center 40%; background-size: 330% auto;
    box-shadow: 0 5px 14px rgba(11,45,17,.12);
  }
  .sidebar-brand strong { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
  .sidebar-brand small { display: block; margin-top: 2px; color: rgba(255,255,255,.55); font-size: 11px; }
  .main-nav { flex: 1; overflow-y: auto; padding: 22px 0; scrollbar-width: thin; }
  .nav-label { margin: 16px 12px 8px; color: rgba(255,255,255,.4); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
  .nav-button {
    width: 100%; display: flex; align-items: center; gap: 11px; min-height: 44px; margin: 3px 0; padding: 10px 12px;
    border: 0; border-radius: 11px; color: rgba(255,255,255,.69); background: transparent; text-align: left; font-size: 13px; font-weight: 700; cursor: pointer;
  }
  .nav-button:hover { color: #fff; background: rgba(255,255,255,.07); }
  .nav-button.active { color: #205c29; background: linear-gradient(90deg, #f3faef, #fff8df); }
  .nav-icon { width: 25px; text-align: center; font-size: 16px; }
  .sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 8px 2px; border-top: 1px solid rgba(255,255,255,.1); }
  .avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 12px; color: #173a28; background: #dcebd8; font-size: 12px; font-weight: 900; }
  .sidebar-user-copy { min-width: 0; flex: 1; }
  .sidebar-user-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .sidebar-user-copy small { display: block; margin-top: 2px; color: rgba(255,255,255,.48); font-size: 9px; }
  .icon-button, .menu-button { border: 0; border-radius: 9px; cursor: pointer; }
  .icon-button { width: 34px; height: 34px; color: rgba(255,255,255,.7); background: rgba(255,255,255,.07); }
  .icon-button:hover { color: #fff; background: rgba(255,255,255,.12); }
  #logout-button {
    width: auto; min-width: 52px; height: 34px; padding: 0 10px;
    font-size: 11px; font-weight: 800; letter-spacing: .02em;
  }
  .menu-icon, .menu-icon::before, .menu-icon::after {
    display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor;
  }
  .menu-icon { position: relative; margin: 0 auto; }
  .menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
  .menu-icon::before { top: -6px; }
  .menu-icon::after { top: 6px; }

  .app-content { min-height: 100vh; margin-left: 262px; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    min-height: 82px; display: flex; justify-content: space-between; align-items: center; gap: 20px;
    padding: 14px clamp(20px, 3vw, 42px); border-bottom: 1px solid rgba(223,230,224,.84);
    background: rgba(245,247,244,.9); backdrop-filter: blur(12px);
  }
  .topbar-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
  .topbar h1 { margin: 0; font-size: 23px; line-height: 1.1; letter-spacing: -.025em; }
  .topbar .eyebrow { margin-bottom: 4px; font-size: 9px; }
  .topbar-right { display: flex; align-items: center; gap: 12px; }
  .today-label { color: var(--muted); font-size: 12px; }
  .role-chip { display: inline-flex; align-items: center; min-height: 27px; padding: 5px 9px; border-radius: 999px; color: var(--green-900); background: var(--green-100); font-size: 10px; font-weight: 850; letter-spacing: .04em; }
  .menu-button {
    display: none; flex: 0 0 auto; width: 44px; height: 44px;
    color: var(--green-900); background: #fff; box-shadow: var(--shadow-sm);
  }
  .main-area { max-width: 1600px; margin: 0 auto; padding: 25px clamp(18px, 3vw, 42px) 55px; }
  .page { display: none; animation: pageIn .22s ease-out; }
  .page.active { display: block; }
  @keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

  .alert { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 20px; padding: 15px 17px; border-radius: 14px; font-size: 13px; }
  .alert-warning { color: #684600; border: 1px solid #f2d27e; background: #fff5d7; }
  .toolbar-card, .card { border: 1px solid rgba(216,225,217,.9); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
  .toolbar-card { display: flex; justify-content: space-between; align-items: end; gap: 22px; margin-bottom: 19px; padding: 16px 18px; }
  .toolbar-title { min-width: 0; max-width: 280px; }
  .toolbar-title strong { display: block; font-size: 13px; }
  .toolbar-title span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
  .filter-grid { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(125px, 1fr)) auto; gap: 10px; align-items: end; }
  .compact-field { gap: 4px; }
  .compact-field input, .compact-field select { min-height: 44px; padding: 8px 10px; border-radius: 9px; font-size: 16px; }
  .btn-filter { min-height: 39px; white-space: nowrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stock-summary { margin-bottom: 18px; }

  .kpi-card { position: relative; min-height: 128px; padding: 17px; overflow: hidden; border: 1px solid rgba(216,225,217,.86); border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm); }
  .kpi-card::after { content: ""; position: absolute; right: -31px; bottom: -38px; width: 90px; height: 90px; border-radius: 50%; background: var(--green-50); }
  .kpi-card.warning::after { background: var(--amber-100); }
  .kpi-card.danger::after { background: var(--red-100); }
  .kpi-top { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
  .kpi-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--green-800); background: var(--green-50); }
  .kpi-value { position: relative; z-index: 1; margin-top: 14px; font-size: clamp(20px, 5vw, 31px); font-weight: 850; letter-spacing: -.035em; overflow-wrap: anywhere; }
  .kpi-note { position: relative; z-index: 1; margin-top: 4px; color: var(--muted); font-size: 10px; }

  .chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 17px; }
  .card { padding: 19px; }
  .chart-card { min-width: 0; }
  .card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 15px; }
  .card-heading h3, .info-card h3 { margin: 0; font-size: 15px; letter-spacing: -.015em; }
  .card-heading p, .info-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
  .chart-box { position: relative; height: 280px; }
  .chart-box canvas { max-width: 100%; }
  .table-card { margin-top: 16px; padding-bottom: 12px; }
  .table-wrap {
    width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain; border: 1px solid #e3e9e4; border-radius: 12px;
  }
  table { width: 100%; border-collapse: collapse; font-size: 11px; }
  th, td { padding: 11px 12px; border-bottom: 1px solid #e8ece8; text-align: left; white-space: nowrap; vertical-align: middle; }
  th { position: sticky; top: 0; z-index: 1; color: #4c5b50; background: #f1f5f1; font-size: 9px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
  tbody tr:last-child td { border-bottom: 0; }
  tbody tr:hover td { background: #fafcf9; }
  td.numeric, th.numeric { text-align: right; }
  .empty-cell { padding: 32px; color: var(--muted); text-align: center; }
  .status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; }
  .status.good { color: #17613b; background: #daf0df; }
  .status.warn { color: #735000; background: #fff0c5; }
  .status.bad { color: #922d2d; background: #fde3e0; }
  .status.neutral { color: #556158; background: #edf1ed; }
  .action-group { display: flex; gap: 6px; }

  .split-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr); gap: 17px; align-items: start; }
  .form-card { padding: 21px; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
  .form-grid .field { margin-bottom: 14px; }
  .span-2 { grid-column: 1 / -1; }
  .one-column { grid-template-columns: 1fr; }
  .info-card { position: sticky; top: 106px; padding: 22px; background: linear-gradient(150deg, #fff, #f2f7f1); }
  .info-card > p:not(.eyebrow) { font-size: 12px; line-height: 1.65; }
  .accent-card { color: #fff; border: 0; background: linear-gradient(145deg, #33913b, #174c22); }
  .accent-card p { color: rgba(255,255,255,.7); }
  .danger-card { background: linear-gradient(145deg, #fff, #fff5ef); }
  .formula-list { margin-top: 18px; }
  .formula-list > div { padding: 13px 0; border-bottom: 1px solid #dfe7df; }
  .formula-list > div:last-child { border-bottom: 0; }
  .formula-list span, .formula-list strong { display: block; }
  .formula-list span { color: var(--muted); font-size: 10px; }
  .formula-list strong { margin-top: 3px; font-size: 12px; }
  .calculation-preview { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 2px 0 15px; padding: 13px 14px; border-radius: 11px; background: var(--green-50); }
  .calculation-preview span { color: var(--muted); font-size: 11px; }
  .calculation-preview strong { color: var(--green-900); font-size: 13px; text-align: right; }
  .check-field { display: flex; align-items: center; gap: 9px; min-height: 45px; margin-bottom: 14px; color: #465248; font-size: 12px; font-weight: 700; }
  .check-field input { width: 17px; min-height: 17px; accent-color: var(--green-800); }

  .report-hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 17px; color: #fff; border: 0; background: linear-gradient(120deg, #194d22, #43a73e 72%, #a68118 145%); }
  .report-hero h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
  .report-hero p:not(.eyebrow) { margin: 8px 0 0; max-width: 670px; color: rgba(255,255,255,.69); font-size: 12px; line-height: 1.6; }
  .reports-filter { width: 100%; }
  .profile-grid { max-width: 900px; display: grid; grid-template-columns: 310px 1fr; gap: 18px; }
  .profile-card { text-align: center; }
  .profile-avatar { width: 84px; height: 84px; display: grid; place-items: center; margin: 7px auto 15px; border-radius: 24px; color: #fff; background: linear-gradient(145deg, var(--green-700), var(--green-950)); font-size: 22px; font-weight: 900; }
  .profile-card h2 { margin: 0 0 9px; font-size: 21px; }
  .profile-card dl { margin: 24px 0 0; text-align: left; }
  .profile-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
  .profile-card dt { color: var(--muted); font-size: 11px; }
  .profile-card dd { margin: 0; font-size: 11px; font-weight: 750; text-align: right; }

  .loading-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; background: rgba(245,247,244,.78); backdrop-filter: blur(4px); }
  .loading-overlay p { margin: 13px 0 0; color: var(--green-900); font-size: 12px; font-weight: 750; }
  .spinner { width: 39px; height: 39px; border: 4px solid #d6e4d7; border-top-color: var(--green-700); border-radius: 50%; animation: spin .8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .toast-container {
    position: fixed; z-index: 250; display: grid; gap: 9px;
    width: min(360px, calc(100vw - 40px));
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
  }
  .toast { padding: 13px 15px; border-radius: 12px; color: #fff; background: #183d2a; box-shadow: var(--shadow); font-size: 12px; line-height: 1.45; animation: toastIn .2s ease-out; }
  .toast.error { background: #912d2d; }
  .toast.warning { color: #4d3500; background: #ffdd81; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
  .dialog-backdrop { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 18px; background: rgba(12,34,23,.55); backdrop-filter: blur(4px); }
  .dialog-card { width: min(100%, 460px); padding: 23px; border-radius: 17px; background: #fff; box-shadow: 0 30px 80px rgba(9,35,22,.25); }
  .dialog-card h3 { margin: 0 0 12px; font-size: 18px; }
  .dialog-card p { color: var(--muted); font-size: 12px; line-height: 1.6; }
  .dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
  .secret-box { padding: 15px; border: 1px dashed var(--green-700); border-radius: 11px; color: var(--green-950); background: var(--green-50); font-size: 17px; font-weight: 900; letter-spacing: .04em; text-align: center; user-select: all; }
  .sidebar-backdrop { display: none; }

  @media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .toolbar-card { align-items: stretch; flex-direction: column; }
    .toolbar-title { max-width: none; }
    .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .btn-filter { grid-column: 1 / -1; }
  }

  @media (max-width: 920px) {
    .login-view { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .login-panel {
      min-height: 100vh;
      min-height: 100dvh;
      padding: max(28px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    }
    .sidebar {
      width: min(320px, 88vw);
      transform: translateX(-105%);
      transition: transform .23s ease;
      padding-top: max(23px, env(safe-area-inset-top));
      padding-bottom: max(17px, env(safe-area-inset-bottom));
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(9,33,21,.45); }
    .sidebar-backdrop.open { display: block; }
    .app-content { margin-left: 0; }
    .menu-button { display: grid; place-items: center; }
    .topbar {
      gap: 10px;
      padding-top: max(12px, env(safe-area-inset-top));
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    .topbar-left > div { min-width: 0; }
    .topbar h1 { max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
    .today-label { display: none; }
    .chart-grid, .split-layout { grid-template-columns: 1fr; }
    .info-card { position: static; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dialog-backdrop {
      align-items: end;
      padding: 0;
    }
    .dialog-card {
      width: 100%;
      max-width: none;
      border-radius: 18px 18px 0 0;
      padding-bottom: max(23px, env(safe-area-inset-bottom));
    }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions .btn { width: 100%; min-height: 44px; }
    .calculation-preview { flex-direction: column; align-items: flex-start; }
    .calculation-preview strong { text-align: left; }
  }

  @media (max-width: 640px) {
    .login-panel { padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
    .topbar { min-height: 64px; padding-bottom: 10px; }
    .topbar-right { gap: 6px; flex-shrink: 0; }
    .main-area { padding: 14px 12px max(36px, env(safe-area-inset-bottom)); }
    .toolbar-card, .card { border-radius: 15px; }
    .toolbar-card { padding: 14px; }
    .kpi-grid { gap: 10px; }
    .kpi-card { min-height: 108px; padding: 14px; }
    .kpi-value { font-size: 20px; white-space: normal; }
    .kpi-note { white-space: normal; }
    .card { padding: 15px; }
    .chart-box { height: 220px; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .report-hero { align-items: flex-start; flex-direction: column; }
    .report-hero .btn { width: 100%; }
    .profile-grid { grid-template-columns: 1fr; }
    .alert { align-items: flex-start; flex-direction: column; }
    .alert .btn { width: 100%; }
    .btn, .btn-filter { min-height: 44px; }
    .btn-small { min-height: 36px; font-size: 12px; }
    th, td { padding: 10px; }
    .toast-container {
      left: 12px;
      right: 12px;
      bottom: max(12px, env(safe-area-inset-bottom));
      width: auto;
    }
    .action-group { flex-wrap: wrap; }
    table { min-width: 640px; }
  }

  @media (max-width: 400px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-grid .compact-field { grid-column: auto !important; }
    .top-role, #top-role { display: none; }
    .hero-brand-logo { width: min(220px, 78vw); height: 104px; }
  }

  @media (hover: none) {
    .btn:hover { transform: none; }
    tbody tr:hover td { background: transparent; }
  }

  @media print {
    .sidebar, .topbar, .toolbar-card, .btn, .alert { display: none !important; }
    .app-content { margin: 0; }
    .main-area { max-width: none; padding: 0; }
    .card, .kpi-card { break-inside: avoid; box-shadow: none; }
  }
