:root {
    --sidebar: #171b27;
    --sidebar-soft: #202636;
    --main-bg: #f4f6fa;
    --panel: #ffffff;
    --line: #e8edf5;
    --ink: #202938;
    --text: #4d586c;
    --muted: #9aa5b7;
    --blue: #3144c9;
    --blue-2: #5168e8;
    --cyan: #69d1ff;
    --green: #20c997;
    --red: #f0445e;
    --yellow: #f5b943;
    --shadow: 0 12px 30px rgba(31, 43, 71, .07);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--main-bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell {
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
    width: 100%;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--main-bg);
    box-shadow: none;
}

.sidebar {
    background: var(--sidebar);
    color: #d9dfeb;
    padding: 24px 18px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
    font-weight: 900;
}
.brand-mark {
    width: 19px;
    height: 19px;
    display: inline-block;
    border: 3px solid #5267ff;
    border-radius: 3px;
    transform: rotate(45deg);
}
.brand strong {
    color: #ffffff;
    font-size: 21px;
}
.brand strong::first-letter { color: #5267ff; }
.brand small { display: none; }
.nav {
    display: grid;
    gap: 6px;
}
.nav span {
    margin: 18px 0 7px;
    color: #7d8799;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}
.nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 13px;
    border-radius: 8px;
    color: #c0c8d6;
    font-size: 14px;
    font-weight: 800;
}
.nav a::before {
    content: "";
    width: 21px;
    height: 21px;
    margin-right: 12px;
    border: 0;
    border-radius: 6px;
    background-color: #273044;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 14px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.nav a.active,
.nav a:hover {
    color: #ffffff;
    background: var(--sidebar-soft);
}
.nav a.active::before {
    background-color: #5b82ff;
    box-shadow: 0 8px 16px rgba(91, 130, 255, .22);
}
.nav a[data-icon="dashboard"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1.5'/%3E%3C/svg%3E");
}
.nav a[data-icon="items"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M4 7h16M4 12h16M4 17h10'/%3E%3Cpath d='M7 4v16'/%3E%3C/svg%3E");
}
.nav a[data-icon="branches"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M3 21h18'/%3E%3Cpath d='M5 21V5a2 2 0 0 1 2-2h7v18'/%3E%3Cpath d='M14 8h3a2 2 0 0 1 2 2v11'/%3E%3Cpath d='M8 7h2M8 11h2M8 15h2'/%3E%3C/svg%3E");
}
.nav a[data-icon="supplier"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9.5' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E");
}
.nav a[data-icon="purchase"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z'/%3E%3Cpath d='M3 6h18M16 10a4 4 0 0 1-8 0'/%3E%3C/svg%3E");
}
.nav a[data-icon="store"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M3 21h18M5 21V8l7-5 7 5v13'/%3E%3Cpath d='M9 21v-7h6v7M9 10h6'/%3E%3C/svg%3E");
}
.nav a[data-icon="usage"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M8 2v5M16 2v5M3 10h18'/%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='m9 16 2 2 4-5'/%3E%3C/svg%3E");
}
.nav a[data-icon="transfer"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M7 7h14l-4-4M17 17H3l4 4'/%3E%3Cpath d='M21 7v4M3 17v-4'/%3E%3C/svg%3E");
}
.nav a[data-icon="reports"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M3 3v18h18'/%3E%3Cpath d='M7 15l4-4 3 3 5-7'/%3E%3C/svg%3E");
}
.help-card {
    margin-top: 24px;
    padding: 15px 16px;
    border-radius: 10px;
    background: #10141e;
    border: 1px solid rgba(255,255,255,.06);
}
.help-card strong,
.help-card small { display: block; }
.help-card strong { font-size: 11px; color: #ffffff; }
.help-card small { margin-top: 7px; color: #8994a7; font-size: 12px; line-height: 1.4; }

.main {
    min-width: 0;
    padding: 0 30px 30px;
}
.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.top-left {
    display: flex;
    align-items: center;
    gap: 18px;
}
.menu-button {
    width: 24px;
    height: 24px;
    border: 0;
    color: #6b7688;
    background: transparent;
    font-size: 0;
    cursor: pointer;
}
.menu-button::before {
    content: "";
    display: block;
    width: 14px;
    height: 2px;
    background: #6b7688;
    box-shadow: 0 5px 0 #6b7688, 0 10px 0 #6b7688;
}
.top-left h1 {
    margin: 0;
    color: #9aa4b5;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0;
}
.top-left h1::first-line { color: var(--ink); }
.top-left small {
    display: block;
    margin-top: 5px;
    color: #a7b0bf;
    font-size: 11px;
    font-weight: 700;
}
.top-actions {
    display: flex;
    align-items: center;
    gap: 11px;
}
.top-select,
.mini-select,
.date-pill,
.top-link {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--panel);
    color: #6d7687;
    font-size: 10px;
    font-weight: 800;
}
.top-select {
    width: 118px;
    padding: 0 8px;
}
.date-pill,
.top-link {
    padding: 0 9px;
}
.export-button {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 3px;
    color: #ffffff;
    background: var(--blue);
    font-size: 10px;
    font-weight: 900;
}
.user-pill {
    color: #606a7d;
    font-size: 12px;
    font-weight: 900;
}
.avatar-button {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(135deg, #152033, #5d75ff);
    cursor: pointer;
    font-size: 11px;
    font-weight: 900;
}
.page-title {
    margin: 0 0 20px;
}
.page-title small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}
.page-title h1 {
    margin: 3px 0 0;
    font-size: 20px;
}

.alert {
    margin-bottom: 18px;
    padding: 11px 14px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 800;
}
.alert.success { color: #0c7a52; background: #ddfbef; }
.alert.danger { color: #ad1535; background: #ffe5ec; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}
.stat-card,
.panel,
.module-head,
.status-card,
.micro-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 5px;
    box-shadow: var(--shadow);
}
.stat-card {
    min-height: 78px;
    padding: 16px 18px;
}
.stat-card span {
    display: block;
    color: #788397;
    font-size: 11px;
    font-weight: 900;
}
.stat-card strong {
    display: block;
    margin-top: 6px;
    color: #182231;
    font-size: 24px;
    line-height: 1.05;
}
.stat-card small {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 900;
}
.up { color: var(--green) !important; }
.down { color: var(--red) !important; }

.analytics-grid {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 14px;
}
.branch-monitor {
    margin-bottom: 18px;
}
.branch-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.branch-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
}
.branch-card > span {
    width: fit-content;
    padding: 4px 8px;
    border-radius: 4px;
    color: #2846c7;
    background: #eef3ff;
    font-size: 10px;
    font-weight: 900;
}
.branch-card > strong {
    color: var(--ink);
    font-size: 14px;
}
.branch-card div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}
.branch-card small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
}
.branch-card b {
    color: #273244;
    font-size: 12px;
}
.status-card {
    position: relative;
    min-height: 112px;
    overflow: hidden;
    padding: 20px;
    color: #ffffff;
    background: linear-gradient(135deg, #3140c4, #2a38b8);
    border: 0;
}
.status-card h2 {
    margin: 0 0 16px;
    font-size: 14px;
}
.status-card span {
    display: block;
    color: rgba(255,255,255,.64);
    font-size: 11px;
    font-weight: 800;
}
.status-card strong {
    display: block;
    margin-top: 2px;
    font-size: 24px;
}
.status-card svg {
    position: absolute;
    right: 0;
    bottom: 6px;
    width: 220px;
    height: 74px;
}
.status-card path {
    fill: none;
    stroke: #2bd0a2;
    stroke-width: 4;
}
.chart-panel {
    min-height: 170px;
    padding: 18px 20px 12px;
}
.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.panel-head h2,
.panel h2 {
    margin: 0;
    color: #303948;
    font-size: 14px;
}
.panel-head p {
    margin: 4px 0 0;
    color: #a0a8b6;
    font-size: 10px;
    font-weight: 700;
}
.panel-head a {
    color: var(--blue);
    font-size: 13px;
    font-weight: 900;
}
.legend {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #8f99aa;
    font-size: 10px;
    font-weight: 900;
    white-space: nowrap;
}
.blue-dot,
.cyan-dot,
.green-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.blue-dot { background: var(--blue); }
.cyan-dot { background: var(--cyan); }
.green-dot { background: var(--green); }
.line-chart {
    position: relative;
    height: 112px;
}
.grid-lines {
    position: absolute;
    inset: 8px 0 18px;
    background:
        linear-gradient(#eef2f7 1px, transparent 1px) 0 0 / 100% 33.33%,
        linear-gradient(90deg, #eef2f7 1px, transparent 1px) 0 0 / 16.66% 100%;
}
.line-chart svg {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 92px;
}
.area-blue-soft { fill: rgba(94, 197, 255, .16); }
.line-blue,
.line-cyan {
    fill: none;
    stroke-width: 4;
}
.line-blue { stroke: var(--blue); }
.line-cyan { stroke: var(--cyan); }
.axis {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    color: #9aa5b5;
    font-size: 9px;
    font-weight: 900;
}
.axis span:last-child { text-align: right; }

.micro-grid {
    width: 360px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
.micro-card {
    min-height: 74px;
    display: grid;
    grid-template-columns: 38px 1fr;
    align-items: center;
    column-gap: 10px;
    padding: 14px;
}
.micro-card span {
    width: 32px;
    height: 32px;
    border: 5px solid #dbeafe;
    border-top-color: var(--blue-2);
    border-radius: 50%;
}
.micro-card strong,
.micro-card b {
    display: block;
    font-size: 10px;
}
.micro-card strong { color: #707b90; }
.micro-card b { margin-top: 5px; color: #1e293b; font-size: 13px; }

.lower-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
}
.market-panel {
    min-height: 250px;
    padding: 20px;
}
.mini-select {
    padding: 0 9px;
}
.market-panel > strong {
    display: block;
    margin: 12px 0 16px;
    color: #1e293b;
    font-size: 21px;
}
.market-panel > strong small {
    font-size: 12px;
}
.bar-chart {
    height: 148px;
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    align-items: end;
    gap: 28px;
    padding: 0 22px 6px;
    border-bottom: 1px solid var(--line);
}
.bar-chart span {
    position: relative;
    display: block;
    height: var(--h);
    min-height: 35px;
    background: #54c3f6;
}
.bar-chart span i {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 28%;
    background: var(--blue);
}
.todo-panel {
    min-height: 250px;
    padding: 20px;
}
.todo-list {
    display: grid;
    gap: 0;
}
.todo-list label {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    color: #5f6b7d;
    font-size: 11px;
    font-weight: 800;
}
.todo-list input {
    width: 13px;
    height: 13px;
    margin-top: 1px;
    accent-color: var(--blue);
}
.todo-list small {
    display: block;
    margin-top: 5px;
    color: #9aa5b7;
    font-size: 10px;
}
.todo-list b {
    margin-left: 5px;
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--red);
    background: #ffe8ed;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}
.content-grid.wide-left {
    grid-template-columns: minmax(340px, .72fr) minmax(0, 1.28fr);
}
.panel {
    min-width: 0;
    padding: 20px;
}
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}
th,
td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    vertical-align: middle;
}
th {
    color: #9aa5b7;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}
td { color: #536174; font-weight: 700; }
.status {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 3px;
    color: #0f7a4e;
    background: #ddfbef;
    font-weight: 900;
    font-size: 11px;
}
.status.pending { color: #9b6500; background: #fff2cc; }
.status.rejected { color: #bd1237; background: #ffe5ec; }
.row-actions { display: flex; gap: 8px; }
.row-actions {
    align-items: center;
    white-space: nowrap;
}

.module-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 18px 20px;
}
.module-head span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}
.module-head h2 {
    margin: 4px 0 0;
    font-size: 18px;
}
.module-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.module-badges b {
    padding: 7px 9px;
    border-radius: 3px;
    color: #1f3e8a;
    background: #eef3ff;
    font-size: 10px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    align-content: start;
}
.form-grid h2 {
    grid-column: 1 / -1;
    margin-top: 0;
}
.form-grid label,
.form-stack label {
    display: grid;
    gap: 6px;
    color: #5f6b7d;
    font-size: 12px;
    font-weight: 900;
}
.form-grid input,
.form-grid select,
.form-grid textarea,
.form-stack input {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    color: var(--ink);
    border: 1px solid #dfe5ef;
    border-radius: 4px;
    background: #fbfcff;
}
.form-grid textarea {
    min-height: 88px;
    resize: vertical;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .primary-button { justify-self: start; }
.primary-button,
.small-button,
.icon-button {
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 900;
}
.primary-button {
    min-height: 40px;
    padding: 0 16px;
    color: #ffffff;
    background: var(--blue);
}
.small-button {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 7px 9px;
    color: #ffffff;
    background: var(--green);
    font-size: 11px;
}
.small-button.neutral {
    color: #334155;
    background: #eef3ff;
}
.small-button.ghost { background: var(--red); }

.flow-row {
    display: grid;
    grid-template-columns: 1fr 38px 1fr 38px 1fr;
    align-items: center;
    gap: 8px;
}
.flow-row div {
    min-height: 74px;
    display: grid;
    place-items: center;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fbfcff;
}
.flow-row span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 4px;
}
.flow-row b {
    height: 3px;
    background: var(--blue);
    position: relative;
}
.flow-row b::after {
    content: "";
    position: absolute;
    right: -2px;
    top: -5px;
    border-left: 10px solid var(--blue);
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
}
.mini-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}
.mini-list span {
    padding: 9px 10px;
    border-radius: 4px;
    color: #5b6678;
    background: #f8faff;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 800;
}

.login-bg {
    display: grid;
    place-items: center;
    background: var(--main-bg);
}
.login-wrap {
    width: min(960px, calc(100% - 32px));
}
.login-panel {
    max-width: 500px;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 16px 40px rgba(11, 18, 32, .22);
}
.login-brand { margin-bottom: 24px; }
.login-panel h1 {
    margin: 0 0 12px;
    font-size: 28px;
    line-height: 1.2;
}
.login-panel p {
    margin: 0 0 24px;
    color: var(--muted);
    line-height: 1.7;
}
.form-stack { display: grid; gap: 15px; }
.check-row {
    display: flex !important;
    align-items: center;
    grid-template-columns: none;
}
.check-row input {
    width: auto;
    min-height: auto;
    accent-color: var(--blue);
}
.demo-logins {
    display: grid;
    gap: 6px;
    margin-top: 18px;
    color: #7c8798;
    font-size: 12px;
    font-weight: 800;
}

@media (max-width: 1180px) {
    .shell {
        grid-template-columns: 1fr;
        border-width: 0;
        border-radius: 0;
        width: 100%;
        min-height: 100vh;
        margin: 0;
    }
    .sidebar {
        border-bottom: 1px solid rgba(255,255,255,.08);
    }
    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .nav span { grid-column: 1 / -1; }
    .analytics-grid,
    .branch-grid,
    .lower-grid,
    .content-grid,
    .content-grid.wide-left {
        grid-template-columns: 1fr;
    }
    .micro-grid { width: 100%; }
}

@media (max-width: 760px) {
    .main,
    .sidebar { padding: 18px; }
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .top-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .top-left h1 { font-size: 17px; }
    .stats-grid,
    .micro-grid,
    .nav {
        grid-template-columns: 1fr;
    }
    .form-grid { grid-template-columns: 1fr; }
    .bar-chart { gap: 12px; padding-inline: 8px; }
    .module-head { align-items: flex-start; flex-direction: column; }
    .flow-row { grid-template-columns: 1fr; }
    .flow-row b {
        height: 30px;
        width: 3px;
        margin: 0 auto;
    }
    .flow-row b::after {
        right: -5px;
        top: 21px;
        transform: rotate(90deg);
    }
}
