@import url('poppins.css');

/* DESIGN TOKENS */
:root {
    /* Brand */
    --primary: #0f4c81;
    --primary-light: #1a6bbf;
    --primary-dark: #0a3560;
    --teal: #00b4a0;
    --teal-light: #00d4bd;
    --teal-dark: #009d8c;

    /* Neutrals */
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-2: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --muted: #64748b;

    /* Semantic */
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #d97706;
    --purple: #7c3aed;
    --orange: #ea580c;

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .13), 0 4px 12px rgba(15, 23, 42, .07);
    --shadow-xl: 0 20px 60px rgba(15, 23, 42, .18), 0 8px 20px rgba(15, 23, 42, .1);

    /* Radius */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;

    /* Sidebar */
    --sidebar-w: 252px;
    --sidebar-bg: linear-gradient(180deg, #0a3560 0%, #0f4c81 60%, #0e4474 100%);

    /* Zone colors */
    --zone1: #16a34a;
    --zone2: #2563eb;
    --zone3: #ca8a04;
    --zone4: #dc2626;
    --zone5: #db2777;
    --zone6: #ea580c;
    --zone7: #6b7280;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    overflow-x: hidden;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
    display: none !important;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-red {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-yellow {
    background: #fef9c3;
    color: #a16207;
}

.badge-gray {
    background: #f1f5f9;
    color: #64748b;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s cubic-bezier(.4, 0, .2, 1);
    letter-spacing: .1px;
    white-space: nowrap;
}

.btn:active {
    transform: scale(.97);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: var(--r-sm);
}

.btn-blue {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 76, 129, .3);
}

.btn-blue:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 14px rgba(15, 76, 129, .4);
    transform: translateY(-1px);
}

.btn-teal {
    background: var(--teal);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 180, 160, .3);
}

.btn-teal:hover {
    background: var(--teal-light);
    box-shadow: 0 4px 14px rgba(0, 180, 160, .4);
    transform: translateY(-1px);
}

.btn-red {
    background: var(--red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, .25);
}

.btn-red:hover {
    background: #b91c1c;
    box-shadow: 0 4px 14px rgba(220, 38, 38, .35);
    transform: translateY(-1px);
}

.btn-green {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 163, 74, .25);
}

.btn-green:hover {
    background: #15803d;
    box-shadow: 0 4px 14px rgba(22, 163, 74, .35);
    transform: translateY(-1px);
}

.btn-yellow {
    background: var(--yellow);
    color: #fff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, .25);
}

.btn-yellow:hover {
    background: #b45309;
    transform: translateY(-1px);
}

.btn-gray {
    background: var(--surface-2);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-gray:hover {
    background: var(--border);
    border-color: var(--border-2);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 13px;
    color: var(--text);
    background: var(--surface-2);
    outline: none;
    transition: border .18s, box-shadow .18s, background .18s;
}

.form-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(15, 76, 129, .1);
}

.form-input::placeholder {
    color: var(--text-3);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.form-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .9px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 5px;
    margin: 16px 0 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 11px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    margin-bottom: 14px;
    border-left: 4px solid;
}

.alert-red {
    background: #fef2f2;
    color: #991b1b;
    border-color: #f87171;
}

.alert-green {
    background: #f0fdf4;
    color: #166534;
    border-color: #4ade80;
}

.alert-yellow {
    background: #fffbeb;
    color: #92400e;
    border-color: #fbbf24;
}

.alert-blue {
    background: #eff6ff;
    color: #1e3a8a;
    border-color: #60a5fa;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a3560 0%, #0f4c81 45%, #00b4a0 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(0, 180, 160, .25) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(15, 76, 129, .35) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(20px);
    border-radius: var(--r-xl);
    padding: 42px 38px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, .6);
    position: relative;
    z-index: 1;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-logo img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.login-logo-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
}

.login-logo-sub {
    font-size: 10px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.login-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 24px;
}

.login-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: var(--muted);
}

.login-link {
    color: var(--primary);
    font-weight: 600;
}

.login-link:hover {
    text-decoration: underline;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 4px 0 24px rgba(10, 21, 40, .18);
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 4px;
}

.sidebar-logo {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, .2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.sidebar-logo-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.sidebar-logo-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, .45);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.sidebar-user {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .08);
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, .4);
    margin-top: 2px;
}

.nav-section {
    padding: 12px 18px 3px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255, 255, 255, .25);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255, 255, 255, .58);
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .17s ease;
    text-decoration: none;
    margin: 1px 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    border-left-color: rgba(0, 180, 160, .5);
}

.nav-item.active {
    background: rgba(0, 180, 160, .14);
    color: #fff;
    border-left-color: var(--teal);
    font-weight: 600;
}

.nav-dropdown {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 18px;
    color: rgba(255, 255, 255, .75);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}

.nav-dropdown-btn:hover {
    background: rgba(255, 255, 255, .04);
}

.nav-dropdown-icon {
    font-size: 10px;
    transition: transform .22s ease;
}

.nav-dropdown.expanded .nav-dropdown-icon {
    transform: rotate(180deg);
}

.nav-dropdown-content {
    display: none;
    flex-direction: column;
    background: rgba(0, 0, 0, .12);
}

.nav-dropdown.expanded .nav-dropdown-content {
    display: flex;
}

.nav-dropdown-content .nav-item {
    padding-left: 28px;
    font-size: 12.5px;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    margin-top: auto;
    background: rgba(0, 0, 0, .1);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .6);
    font-size: 13px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    transition: color .15s;
}

.logout-btn:hover {
    color: #fff;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ============================================================
   HAMBURGER
   ============================================================ */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-2);
    border-radius: 2px;
    transition: all .3s;
}

.hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    min-width: 0;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 6px rgba(15, 23, 42, .06);
}

.topbar-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.topbar-logo.dark {
    background: #000;
}

.topbar-center {
    flex: 1;
    text-align: center;
}

.topbar-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -.2px;
}

.topbar-subtitle {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1px;
}

.topbar-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.topbar-page {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
}

.topbar-date {
    font-size: 11px;
    color: var(--text-3);
    font-family: monospace;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(15, 76, 129, .3);
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page {
    padding: 24px;
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.page-header {
    margin-bottom: 22px;
}

.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
}

.page-header p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, .7);
    transition: box-shadow .2s;
    width: 100%;
    min-width: 0;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to right, var(--surface-2), var(--surface));
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.card-body {
    padding: 20px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 20px 20px 18px;
    box-shadow: var(--shadow-md);
    border-top: 3px solid var(--primary);
    border: 1px solid rgba(226, 232, 240, .6);
    border-top-width: 3px;
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(15, 76, 129, .06) 0%, transparent 70%);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.green {
    border-top-color: var(--teal);
}

.stat-card.green::after {
    background: radial-gradient(circle, rgba(0, 180, 160, .06) 0%, transparent 70%);
}

.stat-card.red {
    border-top-color: var(--red);
}

.stat-card.red::after {
    background: radial-gradient(circle, rgba(220, 38, 38, .06) 0%, transparent 70%);
}

.stat-card.yellow {
    border-top-color: var(--yellow);
}

.stat-card.yellow::after {
    background: radial-gradient(circle, rgba(217, 119, 6, .06) 0%, transparent 70%);
}

.stat-card.purple {
    border-top-color: var(--purple);
}

.stat-card.purple::after {
    background: radial-gradient(circle, rgba(124, 58, 237, .06) 0%, transparent 70%);
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    font-family: monospace;
    color: var(--text);
    letter-spacing: -1px;
    line-height: 1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 5px;
}

/* ============================================================
   CHART GRIDS & CONTAINERS
   ============================================================ */
.charts-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.charts-2b {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.charts-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    min-height: 240px;
}

.chart-wrap.lg {
    height: 340px;
    min-height: 280px;
}

.chart-wrap.sm {
    height: 240px;
    min-height: 200px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table-scroll-hint {
    display: none;
    font-size: 11px;
    color: #64748b;
    padding: 7px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-input {
    flex: 1 1 140px;
    min-width: 120px;
}

.filter-bar .btn {
    white-space: nowrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--surface-2);
    padding: 10px 14px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text);
    transition: background .12s;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: linear-gradient(to right, rgba(15, 76, 129, .03), transparent);
}

.table-empty {
    text-align: center;
    padding: 50px;
    color: var(--text-3);
    font-size: 14px;
}

.table-footer {
    padding: 12px 18px;
    font-size: 12px;
    color: var(--text-3);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(10, 21, 40, .5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fade-in .18s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-box {
    background: var(--surface);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    padding: 28px;
    animation: slide-up .22s cubic-bezier(.34, 1.56, .64, 1);
    border: 1px solid rgba(226, 232, 240, .6);
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(24px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-box.wide {
    max-width: 720px;
}

/* Custom scrollbar inside modal */
.modal-box::-webkit-scrollbar {
    width: 5px;
}

.modal-box::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 4px;
}

.modal-box::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 4px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 14px;
    line-height: 28px;
    text-align: center;
    transition: all .15s;
    color: var(--muted);
}

.modal-close:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--red);
}

/* ============================================================
   OXYGEN TANKS
   ============================================================ */
.tank-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.tank-card {
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: 3px solid var(--green);
    transition: transform .18s, box-shadow .18s;
}

.tank-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tank-card.out {
    border-top-color: var(--red);
}

.tank-card-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.tank-card-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    margin-top: 3px;
}

.tank-card.out .tank-card-status {
    color: var(--red);
}

.tank-card-who {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #1e293b;
    color: #f8fafc;
    padding: 14px 16px 14px 14px;
    border-radius: var(--r-lg);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .28), 0 2px 8px rgba(0, 0, 0, .18);
    max-width: 340px;
    min-width: 260px;
    pointer-events: all;
    position: relative;
    overflow: hidden;
    transform: translateX(110%);
    opacity: 0;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1), opacity .25s ease;
    border: 1px solid rgba(255, 255, 255, .06);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(110%);
    opacity: 0;
}

.toast-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(255, 255, 255, .1);
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 2px;
}

.toast-msg {
    font-size: 12px;
    color: rgba(255, 255, 255, .65);
    line-height: 1.5;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .4);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    align-self: flex-start;
    transition: color .15s;
}

.toast-close:hover {
    color: #fff;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
    animation: toast-shrink linear forwards;
}

@keyframes toast-shrink {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.toast.success .toast-icon {
    background: rgba(22, 163, 74, .25);
}

.toast.success .toast-progress {
    background: #22c55e;
}

.toast.error {
    border-left: 3px solid #ef4444;
}

.toast.error .toast-icon {
    background: rgba(220, 38, 38, .3);
}

.toast.error .toast-progress {
    background: #ef4444;
}

.toast.warning {
    border-left: 3px solid #f59e0b;
}

.toast.warning .toast-icon {
    background: rgba(217, 119, 6, .25);
}

.toast.warning .toast-progress {
    background: #f59e0b;
}

.toast.info {
    border-left: 3px solid #3b82f6;
}

.toast.info .toast-icon {
    background: rgba(15, 76, 129, .35);
}

.toast.info .toast-progress {
    background: #3b82f6;
}

.toast.network {
    border-left: 3px solid #ef4444;
    background: #1c1917;
}

.toast.network .toast-icon {
    background: rgba(220, 38, 38, .25);
}

.toast.network .toast-progress {
    background: #ef4444;
}

/* ============================================================
   OXYGEN STATUS BAR
   ============================================================ */
.oxy-status-bar {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    border: 1px solid rgba(226, 232, 240, .6);
}

.oxy-status-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

/* ============================================================
   ZONE BADGES
   ============================================================ */
.zone-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}

.zone-badge.zone-1 {
    background: var(--zone1);
}

.zone-badge.zone-2 {
    background: var(--zone2);
}

.zone-badge.zone-3 {
    background: var(--zone3);
}

.zone-badge.zone-4 {
    background: var(--zone4);
}

.zone-badge.zone-5 {
    background: var(--zone5);
}

.zone-badge.zone-6 {
    background: var(--zone6);
}

.zone-badge.zone-7 {
    background: var(--zone7);
}

/* ============================================================
   HEALTH BADGES (hbadge)
   ============================================================ */
.hbadge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .3px;
}

.hbadge.hb-normal {
    background: #dcfce7;
    color: #15803d;
}

.hbadge.hb-elevated {
    background: #fef9c3;
    color: #a16207;
}

.hbadge.hb-warn {
    background: #ffedd5;
    color: #c2410c;
}

.hbadge.hb-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.hbadge.hb-crisis {
    background: #7e22ce;
    color: #fff;
}

.hbadge.hb-low {
    background: #dbeafe;
    color: #1d4ed8;
}

.hbadge.hb-info {
    background: #e2e8f0;
    color: #475569;
}

.hbadge.hb-green {
    background: #dcfce7;
    color: #15803d;
}

.hbadge.hb-gray {
    background: #f1f5f9;
    color: #64748b;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {

    .sidebar,
    .topbar,
    .btn,
    .modal-bg,
    .hamburger {
        display: none !important;
    }

    .main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    body {
        background: #fff !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #e2e8f0;
    }

    .page {
        padding: 0;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media(max-width:1200px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media(max-width:768px) {
    .hamburger {
        display: flex;

    }

    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        width: 100%;

    }

    .topbar {
        padding: 0 14px;
        height: 60px;

    }

    .topbar-logo {
        width: 36px;
        height: 36px;
    }

    .topbar-name {
        font-size: 13px;
    }

    .topbar-subtitle,
    .topbar-divider,
    .topbar-right {
        display: none;
    }

    .page {
        padding: 14px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .charts-2,
    .charts-2b,
    .charts-3 {
        grid-template-columns: 1fr;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .modal-bg {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        max-width: 100%;
        animation: slide-up-mobile .25s cubic-bezier(.34, 1.56, .64, 1);
    }

    @keyframes slide-up-mobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .toast-container {
        bottom: 14px;
        left: 14px;
        right: 14px;
        align-items: stretch;
    }

    .toast {
        max-width: none;
        min-width: 0;
    }

    .table-scroll-hint {
        display: block;
    }

    .page-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header-flex .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-bar {
        gap: 8px;
    }

    .filter-bar .form-input {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }

    .table-footer {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        text-align: center;
    }

    .table-footer>div:last-child {
        justify-content: center;
        width: 100%;
    }
}

@media(max-width:480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 26px;
    }

    .filter-bar .form-input {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100% !important;
    }

    .filter-bar .filter-btns {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .filter-bar .filter-btns .btn,
    .filter-bar .filter-btns a.btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    .modal-box {
        padding: 20px 16px;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}