/* ============================================================
   ماتوتراك — Green Plant Light Dashboard UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 240px;

    /* Surfaces — bright daylight */
    --bg:          #f0fdf4;
    --bg-alt:      #ecfdf5;
    --card-bg:     #ffffff;
    --card-hover:  #f6fef8;
    --border:      #d1fae5;
    --border-light:#a7f3d0;

    /* Text — deep forest */
    --text:          #14532d;
    --text-secondary:#166534;
    --text-muted:    #4a7c59;

    /* Brand — vivid fresh green */
    --primary:      #22c55e;
    --primary-dark: #16a34a;
    --primary-dim:  rgba(34,197,94,.12);
    --primary-glow: rgba(34,197,94,.28);

    /* Status */
    --success:     #16a34a;   /* rich leaf green */
    --success-bg:  rgba(22,163,74,.10);
    --warning:     #d97706;   /* sunlight amber */
    --warning-bg:  rgba(217,119,6,.10);
    --danger:      #dc2626;
    --danger-bg:   rgba(220,38,38,.10);
    --info:        #0891b2;   /* sky / water blue */
    --info-bg:     rgba(8,145,178,.10);

    /* Sidebar — rich dark forest green */
    --sidebar-bg:     #14532d;
    --sidebar-text:   #86efac;
    --sidebar-active: #4ade80;

    /* UI chrome */
    --radius:    10px;
    --radius-sm:  6px;
    --shadow:    0 1px 4px rgba(20,83,45,.10), 0 1px 2px rgba(20,83,45,.06);
    --shadow-lg: 0 8px 28px rgba(20,83,45,.14), 0 3px 8px rgba(20,83,45,.08);
    --trans:     all .2s cubic-bezier(.4,0,.2,1);
}

body {
    font-family: 'Cairo', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Very subtle leaf-vein texture */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E");
    background-size: 300px 300px;
}

/* ── Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6ee7a0; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    z-index: 100;
    border-left: 1px solid var(--border);
}

.sidebar-logo {
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 11px;
}

/* Eye / tracking icon */
.sidebar-logo::before {
    content: '';
    display: flex;
    width: 34px;
    height: 34px;
    min-width: 34px;
    background: var(--primary);
    border-radius: 9px;
    /* Eye with crosshair — شايف */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cline x1='12' y1='8' x2='12' y2='10'/%3E%3Cline x1='12' y1='14' x2='12' y2='16'/%3E%3Cline x1='8' y1='12' x2='10' y2='12'/%3E%3Cline x1='14' y1='12' x2='16' y2='12'/%3E%3C/svg%3E");
    background-size: 20px;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 14px rgba(34,197,94,.4);
    flex-shrink: 0;
}

.sidebar-logo h1 {
    color: #fff;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.4px;
    line-height: 1;
}
.sidebar-logo span { color: var(--primary); }

.sidebar-nav { padding: 10px 0; flex: 1; overflow-y: auto; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin: 2px 10px;
    transition: var(--trans);
    font-size: 13.5px;
    font-weight: 500;
    position: relative;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.04);
    color: var(--text-secondary);
}

.sidebar-nav a.active {
    background: var(--primary-dim);
    color: var(--primary);
    font-weight: 700;
}

/* Active indicator bar on the right (RTL) */
.sidebar-nav a.active::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 6px; bottom: 6px;
    width: 3px;
    background: var(--primary);
    border-radius: 2px 0 0 2px;
}

.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-nav a.active svg { filter: drop-shadow(0 0 6px var(--primary-glow)); }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-logout {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 14px; width: 100%;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--danger); font-size: 13.5px; font-weight: 500;
    cursor: pointer; transition: var(--trans); font-family: inherit; text-align: right;
}
.sidebar-logout:hover { background: var(--danger-bg); }
.sidebar-logout svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-section {
    padding: 12px 18px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.15);
    margin-top: 6px;
}

/* ── Main ──────────────────────────────────────────────────── */
.main {
    margin-right: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    background: rgba(240,253,244,.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 13px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.4px;
    background: linear-gradient(135deg, var(--text) 60%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.last-updated {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

/* Live pulse dot */
.last-updated::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: live-pulse 2.5s ease-in-out infinite;
    box-shadow: 0 0 6px var(--success);
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .4; transform: scale(.7); }
}

.content { padding: 24px; flex: 1; }

/* ── Stat cards ────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: var(--trans);
    cursor: default;
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-card-link { cursor: pointer; }

/* Glow accent bar on right (RTL) */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--border);
    transition: var(--trans);
}

.stat-card:has(.stat-icon.blue)::before   { background: var(--info);    box-shadow: 0 0 10px rgba(8,145,178,.4); }
.stat-card:has(.stat-icon.green)::before  { background: var(--success);  box-shadow: 0 0 10px rgba(22,163,74,.4); }
.stat-card:has(.stat-icon.red)::before    { background: var(--danger);   box-shadow: 0 0 12px var(--danger); }
.stat-card:has(.stat-icon.amber)::before  { background: var(--warning);  box-shadow: 0 0 12px var(--warning); }
.stat-card:has(.stat-icon.purple)::before { background: #7c3aed; box-shadow: 0 0 10px rgba(124,58,237,.4); }

/* Subtle background glow */
.stat-card:has(.stat-icon.blue)   { background: linear-gradient(135deg, var(--card-bg), rgba(8,145,178,.06)); }
.stat-card:has(.stat-icon.green)  { background: linear-gradient(135deg, var(--card-bg), rgba(22,163,74,.07)); }
.stat-card:has(.stat-icon.red)    { background: linear-gradient(135deg, var(--card-bg), rgba(220,38,38,.05)); }
.stat-card:has(.stat-icon.amber)  { background: linear-gradient(135deg, var(--card-bg), rgba(217,119,6,.06)); }
.stat-card:has(.stat-icon.purple) { background: linear-gradient(135deg, var(--card-bg), rgba(124,58,237,.05)); }

.stat-card .label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.stat-card .value {
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1.5px;
}

.stat-card .value.green  { color: var(--success); text-shadow: none; }
.stat-card .value.blue   { color: var(--info);    text-shadow: none; }
.stat-card .value.red    { color: var(--danger);  text-shadow: none; }
.stat-card .value.amber  { color: var(--warning); text-shadow: none; }
.stat-card .value.purple { color: #7c3aed;        text-shadow: none; }

.stat-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    opacity: .85;
}
.stat-icon.green  { stroke: var(--success); }
.stat-icon.blue   { stroke: var(--info); }
.stat-icon.red    { stroke: var(--danger); }
.stat-icon.amber  { stroke: var(--warning); }
.stat-icon.purple { stroke: #7c3aed; }

/* ── Pivot selection (maps.html) ────────────────────────────── */
.pivot-select-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pivot-select-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    transition: var(--trans);
    cursor: pointer;
}

.pivot-select-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.psc-icon {
    width: 44px;
    height: 44px;
    background: rgba(34,197,94,.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.psc-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--primary);
}

.psc-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.psc-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.psc-status { font-size: 12px; width: fit-content; }

.psc-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
}

.psc-arrow svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -.2px;
}

.card-body { padding: 0; }

/* ── Filters ───────────────────────────────────────────────── */
.filters {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: rgba(255,255,255,.01);
}

.filter-group { display: flex; flex-direction: column; gap: 5px; }

.filter-group label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.filter-group select,
.filter-group input {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    height: 36px;
    font-family: inherit;
    transition: var(--trans);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

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

thead th {
    padding: 10px 16px;
    text-align: start;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: #f6fef8;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f0fdf4; }

tbody td {
    padding: 12px 16px;
    font-size: 13px;
    vertical-align: middle;
    color: var(--text);
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 48px;
    font-size: 13px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    border: 1px solid;
}

.badge-red   { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(242,101,101,.25); }
.badge-amber { background: var(--warning-bg); color: var(--warning); border-color: rgba(251,146,60,.25); }
.badge-blue  { background: var(--info-bg);    color: var(--info);    border-color: rgba(8,145,178,.25); }
.badge-green { background: var(--success-bg); color: var(--success); border-color: rgba(22,163,74,.25); }
.badge-gray  { background: rgba(77,106,135,.12); color: var(--text-muted); border-color: rgba(77,106,135,.25); }
.badge-pulse { animation: pulse 2s infinite; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.45; } }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--trans);
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    letter-spacing: .01em;
    position: relative;
}

.btn:disabled { opacity: .38; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(34,197,94,.3);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(34,197,94,.4);
}
.btn-primary:active { transform: none; }

.btn-success { background: var(--success); color: #000; }
.btn-success:hover:not(:disabled) { background: #1bb889; }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #d94f4f; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--border-light);
    color: var(--text);
}

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
    padding: 7px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--trans);
    font-size: 13px;
    line-height: 1;
}
.btn-icon:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-light);
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,.01);
}
.pagination-info { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.pagination-btns { display: flex; gap: 6px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    animation: modal-in .22s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(.94) translateY(-12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,.02);
}
.modal-header h3 { font-size: 15px; font-weight: 800; }

.modal-body  { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(255,255,255,.01);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--trans);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

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

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.toast {
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toast-in .25s ease;
    max-width: 320px;
    border: 1px solid;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
}

.toast-success {
    background: rgba(22,163,74,.10);
    color: var(--success);
    border-color: rgba(22,163,74,.3);
}
.toast-success::before { content: '✓'; font-weight: 900; font-size: 14px; }

.toast-error {
    background: rgba(242,101,101,.15);
    color: var(--danger);
    border-color: rgba(242,101,101,.3);
}
.toast-error::before { content: '✕'; font-weight: 900; font-size: 14px; }

@keyframes toast-in {
    from { transform: translateX(-16px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ── Misc ──────────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-right    { text-align: right; }
.mt-16         { margin-top: 16px; }
.gap-8         { gap: 8px; }
.flex          { display: flex; align-items: center; }
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Drawer ────────────────────────────────────────────────── */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 600;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.drawer-overlay.open { display: block; }

.drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(960px, 92vw);
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    z-index: 700;
    display: flex;
    flex-direction: column;
    transition: left .28s cubic-bezier(.4,0,.2,1);
}
.drawer.open { left: 0; }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(255,255,255,.02);
}
.drawer-header h3 { margin: 0; font-size: 15px; font-weight: 700; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

.pagination-bar { display: flex; align-items: center; gap: 12px; }

/* ── Bottom nav (mobile only — hidden on desktop) ──────────── */
.bottom-nav { display: none; }

/* ════════════════════════════════════════════════════════════
   MOBILE  ≤ 768px — Android-style layout
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Kill sidebar */
    .sidebar { display: none; }
    .main    { margin-right: 0; }

    /* Breathing room above bottom nav */
    .content { padding: 14px; padding-bottom: 82px; }

    /* Topbar */
    .topbar { padding: 12px 16px; }
    .topbar h2 { font-size: 17px; }
    .topbar-actions { gap: 6px; }

    /* Stat grid — 2 × N */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 14px 14px 16px; }
    .stat-card .value { font-size: 28px; }
    .stat-card .label { font-size: 10px; }

    /* Table cells */
    thead th { padding: 9px 10px; font-size: 10px; }
    tbody td  { padding: 10px 10px; font-size: 12.5px; }
    .empty-row td { padding: 32px; }

    /* Modal */
    .modal { margin: 0 14px; max-width: calc(100% - 28px); }

    /* Form row → single column */
    .form-row { grid-template-columns: 1fr; gap: 0; }

    /* Filters */
    .filters { flex-direction: column; align-items: stretch; padding: 12px 14px; gap: 8px; }
    .filter-group select,
    .filter-group input { width: 100%; }

    /* Pagination */
    .pagination { flex-direction: column; gap: 10px; align-items: flex-start; padding: 12px 14px; }

    /* Toast — above bottom nav */
    .toast-container { bottom: 76px; left: 12px; right: 12px; }
    .toast { max-width: 100%; }

    /* Card header */
    .card-header { padding: 12px 14px; }

    /* Drawer fills width on mobile */
    .drawer { width: 100vw; }

    /* ── Android Bottom Navigation Bar ── */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 66px;
        background: var(--card-bg);
        border-top: 1px solid var(--border);
        z-index: 200;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .bottom-nav::-webkit-scrollbar { display: none; }

    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        min-width: 58px;
        gap: 4px;
        color: var(--sidebar-text);
        text-decoration: none;
        font-size: 10px;
        font-weight: 700;
        padding: 6px 4px;
        transition: var(--trans);
        white-space: nowrap;
        position: relative;
        letter-spacing: .01em;
    }

    /* Active pill indicator at top */
    .bottom-nav a::before {
        content: '';
        position: absolute;
        top: 0;
        left: 24%;
        right: 24%;
        height: 2.5px;
        background: var(--primary);
        border-radius: 0 0 4px 4px;
        opacity: 0;
        transform: scaleX(0);
        transition: opacity .2s, transform .25s cubic-bezier(.34,1.56,.64,1);
    }

    .bottom-nav a svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        transition: var(--trans);
    }

    .bottom-nav a.active {
        color: var(--primary);
    }
    .bottom-nav a.active svg {
        filter: drop-shadow(0 0 6px var(--primary-glow));
        transform: translateY(-1px);
    }
    .bottom-nav a.active::before {
        opacity: 1;
        transform: scaleX(1);
    }

    .bottom-nav a:hover:not(.active) { color: var(--text-secondary); }

    .bottom-nav button.bottom-nav-logout {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        flex: 1; min-width: 58px; gap: 4px;
        background: none; border: none;
        color: var(--danger); font-size: 10px; font-weight: 700;
        padding: 6px 4px; cursor: pointer; font-family: inherit;
        white-space: nowrap; letter-spacing: .01em; transition: var(--trans);
    }
    .bottom-nav button.bottom-nav-logout svg { width: 22px; height: 22px; flex-shrink: 0; }
    .bottom-nav button.bottom-nav-logout:hover { opacity: .75; }
}

/* ═══════════════════════════════════════════════════════════════
   LANGUAGE TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════ */
#lang-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 300;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    transition: var(--trans);
    letter-spacing: .04em;
    font-family: inherit;
}
#lang-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}
@media (max-width: 768px) {
    #lang-toggle { bottom: 76px; left: 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   LTR LAYOUT OVERRIDES  (English mode — dir="ltr")
   Only overrides what needs to flip; all other rules stay intact.
   ═══════════════════════════════════════════════════════════════ */

/* Font */
[dir=ltr] body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; }

/* Sidebar: move from right → left */
[dir=ltr] .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border);
}

/* Active indicator bar: flip to left side */
[dir=ltr] .sidebar-nav a.active::after {
    right: auto;
    left: -10px;
    border-radius: 2px 0 0 2px;
}

/* Main content area: flip margin */
[dir=ltr] .main { margin-right: 0; margin-left: var(--sidebar-w); }

/* Stat card accent bar: flip to left */
[dir=ltr] .stat-card::before {
    right: auto;
    left: 0;
    border-radius: var(--radius) 0 0 var(--radius);
}

/* Table headers: align left */
[dir=ltr] thead th { text-align: left; }

/* Toast: flip from left → right */
[dir=ltr] .toast-container { left: auto; right: 24px; }

/* Lang toggle: flip from left → right */
[dir=ltr] #lang-toggle { left: auto; right: 20px; }

/* Mobile LTR overrides */
@media (max-width: 768px) {
    [dir=ltr] .main { margin-left: 0; }
    [dir=ltr] .toast-container { left: auto; right: 12px; }
    [dir=ltr] #lang-toggle { left: auto; right: 12px; }
}
