  :root {
    --menu: #4d5fa3;
    --menu-hover: #3d4e8c;
    --menu-active: #2f3d78;
    --sub: #e8ebf6;
    --navy: #2f3d78;
    --blue: #4d5fa3;
    --bg: #eef0f7;
    --card: #ffffff;
    --line: #dfe3f0;
    --text: #1f2740;
    --muted: #667091;
    --ok: #12805c;   --ok-bg: #e3f5ee;
    --warn: #a86a00; --warn-bg: #fdf0d6;
    --bad: #c53030;  --bad-bg: #fde8e8;
    --info: #4d5fa3; --info-bg: #e8ebf6;
    --sb-w: 270px;
    --sb-min: 64px;
    --font: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); font-size: 16px; -webkit-font-smoothing: antialiased; }
  button { font-family: inherit; }
  svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

  .app { display: flex; height: 100%; }

  /* ================= SIDEBAR (original style) ================= */
  .sidebar { width: var(--sb-w); flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 8px 6px; overflow-y: auto; overflow-x: hidden; transition: width .2s; }
  .sidebar::-webkit-scrollbar { width: 8px; }
  .sidebar::-webkit-scrollbar-thumb { background: #9096ad; border-radius: 4px; }
  .user-box { display: flex; align-items: center; justify-content: space-between; background: var(--menu); color: #fff; border-radius: 4px; padding: 10px 12px; margin-bottom: 8px; }
  .user-box .name { font-size: 17px; font-weight: 600; }
  .user-box .time { font-size: 12px; margin-top: 2px; }
  .toggle-btn { background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; transition: transform .2s; }
  .menu-search { position: relative; margin-bottom: 8px; }
  .menu-search input { width: 100%; padding: 9px 10px 9px 34px; font-size: 16px; font-family: inherit; border: 1px solid #c5cae0; border-radius: 18px; outline: none; }
  .menu-search input:focus { border-color: var(--menu); }
  .menu-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); }
  .menu, .submenu { list-style: none; margin: 0; padding: 0; }
  .menu > li { margin-bottom: 3px; }
  .menu-btn { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--menu); color: #fff; border: 0; border-radius: 4px; padding: 9px 10px; font-size: 16px; text-align: left; cursor: pointer; font-family: inherit; }
  .menu-btn:hover { background: var(--menu-hover); }
  .menu-btn.open, .menu-btn.active { background: var(--menu-active); }
  .menu-btn .label { flex: 1; line-height: 1.25; }
  .menu-btn .caret { font-size: 11px; transition: transform .2s; }
  .menu-btn.open .caret { transform: rotate(90deg); }
  .submenu { display: none; background: var(--sub); padding: 4px 0; border-radius: 0 0 4px 4px; }
  .submenu.show { display: block; }
  .submenu a { display: block; padding: 8px 14px 8px 32px; font-size: 15px; color: var(--menu-active); text-decoration: none; }
  .submenu a:hover, .submenu a.active { background: #d4d9ee; }
  .submenu a.active { font-weight: 700; }
  .sidebar.collapsed { width: var(--sb-min); }
  .sidebar.collapsed .label, .sidebar.collapsed .caret, .sidebar.collapsed .time, .sidebar.collapsed .name,
  .sidebar.collapsed .menu-search, .sidebar.collapsed .submenu { display: none !important; }
  .sidebar.collapsed .user-box { justify-content: center; padding: 10px 4px; }
  .sidebar.collapsed .toggle-btn { transform: rotate(180deg); }
  .sidebar.collapsed .menu-btn { justify-content: center; }

  /* ================= MAIN ================= */
  .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .topbar { height: 68px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; flex-shrink: 0; }
  .tb-left h1 { margin: 0; font-size: 22px; font-weight: 600; }
  .tb-left .sub { font-size: 14px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
  .tb-right { display: flex; align-items: center; gap: 14px; }

  .icon-btn { position: relative; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); display: grid; place-items: center; cursor: pointer; }
  .icon-btn:hover { background: #f3f5f9; }
  .badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; border: 2px solid #fff; }

  .user-btn { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 4px 4px; cursor: pointer; color: var(--text); }
  .user-btn:hover { background: #f3f5f9; }
  .avatar { width: 34px; height: 34px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 15px; }
  .user-btn .u-name { font-size: 15px; font-weight: 600; line-height: 1.1; text-align: left; }
  .user-btn .u-role { font-size: 12.5px; color: var(--muted); }

  .dd { position: relative; }
  .dd-panel { display: none; position: absolute; right: 0; top: 52px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgba(14,28,54,.16); z-index: 50; overflow: hidden; }
  .dd-panel.show { display: block; }
  .alert-panel { width: 400px; max-width: 92vw; }
  .dd-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; }
  .dd-head button { background: none; border: 0; color: var(--blue); font-size: 14px; cursor: pointer; }
  .alert-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
  .alert-list li { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .alert-list li:last-child { border-bottom: 0; }
  .alert-list li.unread { background: #f5f8ff; }
  .alert-list .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
  .alert-list small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
  .menu-panel { width: 200px; padding: 6px; }
  .menu-panel a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--text); text-decoration: none; font-size: 15px; border-radius: 8px; }
  .menu-panel a:hover { background: #f3f5f9; }

  .content { flex: 1; overflow-y: auto; padding: 24px 28px 32px; }

  /* KPI strip */
  .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 20px; }
  .kpi { background: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
  .kpi .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
  .kpi .ico svg { width: 22px; height: 22px; }
  .kpi .k-val { font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .kpi .k-lab { font-size: 14.5px; color: var(--muted); margin-top: 2px; }
  .t-blue { background: var(--info-bg); color: var(--info); } .t-red { background: var(--bad-bg); color: var(--bad); }
  .t-amber { background: var(--warn-bg); color: var(--warn); } .t-green { background: var(--ok-bg); color: var(--ok); }

  /* panels */
  .grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
  .panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
  .p-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
  .p-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
  .p-head a { font-size: 14px; color: var(--blue); text-decoration: none; }
  .p-body { padding: 18px 20px; }
  .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
  .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }

  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 15px; }
  th { text-align: left; font-weight: 600; font-size: 14px; color: var(--muted); background: #f8f9fc; padding: 11px 20px; white-space: nowrap; border-bottom: 1px solid var(--line); }
  td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  tbody tr:last-child td { border-bottom: 0; }
  tbody tr:hover td { background: #fafbfd; }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .reg { font-weight: 600; }
  .sub-t { color: var(--muted); font-size: 13.5px; }

  .pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 20px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
  .pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
  .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }

  .bar { height: 8px; background: #e9edf5; border-radius: 4px; overflow: hidden; min-width: 90px; }
  .bar i { display: block; height: 100%; border-radius: 4px; }

  .donut-wrap { display: flex; align-items: center; justify-content: center; gap: 28px; flex-wrap: wrap; }
  .legend div { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 15px; }
  .legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
  .legend b { margin-left: auto; padding-left: 18px; font-variant-numeric: tabular-nums; }

  .chart svg { width: 100%; height: auto; display: block; }

  .feed { list-style: none; margin: 0; padding: 0; }
  .feed li { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
  .feed li:first-child { padding-top: 0; } .feed li:last-child { border-bottom: 0; padding-bottom: 0; }
  .feed .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
  .feed small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 3px; }

  .stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--line); }
  .stat { background: #fff; padding: 18px 20px; }
  .stat b { display: block; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .stat span { font-size: 14.5px; color: var(--muted); }

  @media (max-width: 1150px) { .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; } }
  @media (max-width: 850px) {
    .sidebar { position: fixed; z-index: 40; height: 100%; }
    .main { margin-left: var(--sb-min); }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .user-btn .u-txt { display: none; }
  }


  /* ================= EXTRA: shell + shared page components ================= */
  body.booting .app { visibility: hidden; }
  a.menu-btn { text-decoration: none; }
  .submenu a.soon { color: #8a94ad; cursor: default; }
  .menu-panel button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; color: var(--text); background: none; border: 0; font-size: 15px; border-radius: 8px; cursor: pointer; text-align: left; }
  .menu-panel button:hover { background: #f3f5f9; }
  .alert-list li.empty { color: var(--muted); justify-content: center; }

  .btn { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--blue); color: #fff; font-size: 15px; font-weight: 500; cursor: pointer; }
  .btn:hover { background: var(--menu-hover); }
  .btn:disabled { opacity: .7; cursor: default; }
  .btn.ghost { background: #fff; color: var(--blue); border: 1px solid var(--line); }
  .btn.ghost:hover { background: #f3f5f9; }

  .filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .filters input, .filters select { height: 40px; padding: 0 12px; font-size: 15px; font-family: inherit; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fff; }
  .filters input:focus, .filters select:focus { border-color: var(--blue); }

  #flash:empty { display: none; }
  .flash { display: block; padding: 12px 16px; border-radius: 10px; font-size: 15px; margin-bottom: 16px; border: 1px solid transparent; }
  .flash.ok  { background: var(--ok-bg);  color: var(--ok);  border-color: #bfe6d6; }
  .flash.err { background: var(--bad-bg); color: var(--bad); border-color: #f4c3c3; }
  .flash.modal-err { display: none; margin: 0 0 14px; }

  .empty { text-align: center; color: var(--muted); padding: 28px 20px; }
  .actions { display: flex; gap: 6px; justify-content: flex-end; }
  .act { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; }
  .act:hover { background: #f3f5f9; color: var(--text); }
  .act.del:hover { color: var(--bad); border-color: #f4c3c3; background: var(--bad-bg); }

  .pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 14.5px; color: var(--muted); }
  .pager .pg-btns { display: flex; gap: 8px; }
  .pager button { height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; font-family: inherit; }
  .pager button:disabled { opacity: .5; cursor: default; }

  .modal { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(31,39,64,.45); align-items: center; justify-content: center; padding: 20px; }
  .modal.show { display: flex; }
  .modal-box { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 14px; }
  .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
  .modal-head h3 { margin: 0; font-size: 18px; }
  .modal-x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
  .modal-body { padding: 20px; }

  .form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .field { display: flex; flex-direction: column; gap: 6px; }
  .field label { font-size: 14.5px; font-weight: 500; }
  .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=date], .field select, .field textarea { height: 42px; padding: 0 12px; font-size: 15px; font-family: inherit; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fff; }
  .field textarea { height: auto; padding: 10px 12px; }
  .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
  .field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
  .field-err { color: var(--bad); font-size: 13.5px; }
  .hint { color: var(--muted); font-size: 13px; }
  .check-wrap, .check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
  .form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
  @media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
