/* ===========================================
   BASE
=========================================== */

* {
    box-sizing: border-box;
}

:root {
    --bg1: #1e293b;
    --bg2: #0f172a;
    --panel: rgba(30, 41, 59, 0.55);
    --panel2: rgba(15, 23, 42, 0.55);
    --border: rgba(148, 163, 184, 0.18);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #84cc16;
    --accentText: #0f172a;
    --danger: #dc2626;
    --info: #38bdf8;
    --okBg: rgba(34, 197, 94, 0.14);
    --okBorder: rgba(34, 197, 94, 0.35);
    --okText: #bbf7d0;
    --offBg: rgba(148, 163, 184, 0.14);
    --offBorder: rgba(148, 163, 184, 0.24);
    --offText: #cbd5e1;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, var(--bg1), var(--bg2));
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    display: block;
}

/* ===========================================
   LAYOUT
=========================================== */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
}

.content {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
    min-width: 0;
}

.page-surface {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* ===========================================
   SIDEBAR
=========================================== */

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accentText);
}

.logo-title {
    font-weight: 600;
}

.logo-sub {
    font-size: 12px;
    color: var(--muted);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    padding: 10px 14px;
    border-radius: 12px;
    color: #cbd5e1;
    text-decoration: none;
    transition: .2s ease;
}

    .nav-item:hover {
        background: #334155;
    }

    .nav-item.active {
        background: rgba(132, 204, 22, 0.18);
        border: 1px solid rgba(132, 204, 22, 0.35);
        color: #eaffb8;
        font-weight: 600;
    }

.sidebar-footer {
    margin-top: auto;
}

.btn-logout {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    background: var(--danger);
    border: none;
    color: white;
    cursor: pointer;
}

/* ===========================================
   HELPERS
=========================================== */

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

.muted {
    color: var(--muted);
}

.inline {
    display: inline;
}

/* ===========================================
   PAGE HEADER
=========================================== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

    .page-header h1 {
        margin: 0;
        font-size: 28px;
        line-height: 1.1;
    }

/* ===========================================
   ALERTS
=========================================== */

.alert {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.55);
    color: var(--text);
    margin: 10px 0;
}

.alert-success {
    border-color: rgba(132, 204, 22, 0.35);
    background: rgba(132, 204, 22, 0.12);
}

.alert-info {
    border-color: rgba(56, 189, 248, 0.28);
    background: rgba(56, 189, 248, 0.10);
}

/* ===========================================
   BUTTONS
=========================================== */

.btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 8px 14px;
    min-height: 40px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

    .btn:hover {
        background: rgba(255, 255, 255, 0.10);
    }

    .btn:active {
        transform: translateY(1px);
    }

.btn-primary {
    background: var(--accent);
    border-color: rgba(132, 204, 22, 0.60);
    color: var(--accentText);
}

    .btn-primary:hover {
        background: #95db24;
    }

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(148, 163, 184, 0.22);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.22);
    color: #dbe7f3;
}

    .btn-ghost:hover {
        background: rgba(255, 255, 255, 0.06);
    }

.btn-danger {
    background: var(--danger);
    border-color: rgba(220, 38, 38, 0.75);
    color: #fff;
}

    .btn-danger:hover {
        background: #ef4444;
    }

.btn-sm {
    padding: 6px 10px;
    min-height: 34px;
    font-size: 13px;
}

.ico {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

/* ===========================================
   FORMS / TOOLBAR
=========================================== */

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 12px 0 16px 0;
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.28);
}

.input,
.select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(2, 6, 23, 0.45);
    color: var(--text);
    outline: none;
}

    .input::placeholder,
    textarea::placeholder {
        color: #8ca0b8;
    }

    .input:focus,
    .select:focus,
    textarea:focus {
        border-color: rgba(132, 204, 22, 0.50);
        box-shadow: 0 0 0 3px rgba(132, 204, 22, 0.12);
    }

.toolbar .input {
    flex: 1 1 280px;
    min-width: 220px;
}

.toolbar .select {
    flex: 0 0 180px;
    min-width: 160px;
}

/* ===========================================
   TABLES
=========================================== */

.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: var(--panel2);
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

    .table-custom th {
        text-align: left;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: var(--muted);
        background: rgba(255, 255, 255, 0.02);
        white-space: nowrap;
    }

        .table-custom th a {
            text-decoration: none;
        }

            .table-custom th a:hover {
                color: #f1f5f9;
            }

    .table-custom th,
    .table-custom td {
        padding: 14px 16px;
        border-bottom: 1px solid rgba(148, 163, 184, 0.12);
        vertical-align: middle;
    }

    .table-custom tbody tr:hover {
        background: rgba(255, 255, 255, 0.03);
    }

/* ===========================================
   BADGES
=========================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-ok {
    background: var(--okBg);
    border-color: var(--okBorder);
    color: var(--okText);
}

.badge-off {
    background: var(--offBg);
    border-color: var(--offBorder);
    color: var(--offText);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
    display: inline-block;
}

/* ===========================================
   ACTIONS
=========================================== */

.actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    white-space: nowrap;
}

/* ===========================================
   DASHBOARD
=========================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 820px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   MOBILE NAV
=========================================== */

.nav-toggle {
    position: absolute;
    left: -9999px;
}

.topbar {
    display: none;
}

.overlay {
    display: none;
}

.desktop-only {
    display: block;
}

/* ===========================================
   MOBILE BREAKPOINT
=========================================== */

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        background: rgba(15, 23, 42, 0.95);
        border-bottom: 1px solid #334155;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .burger {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.14);
        background: rgba(255, 255, 255, 0.06);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-110%);
        transition: transform .2s ease;
        z-index: 60;
    }

    .nav-toggle:checked ~ .layout .sidebar {
        transform: translateX(0);
    }

    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 55;
    }

    .nav-toggle:checked ~ .layout .overlay {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .page-surface {
        padding: 16px;
        border-radius: 16px;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

        .page-header .btn {
            width: 100%;
        }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

        .toolbar .input,
        .toolbar .select,
        .toolbar .btn,
        .toolbar a.btn {
            width: 100%;
            flex: none;
        }

    .table-wrap {
        overflow-x: auto;
    }

    .table-custom {
        min-width: 680px;
    }
}

/* ===========================================
   SIGN PAGE
=========================================== */

.sign-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px;
}

.sign-card {
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    padding: 12px;
    background: rgba(0, 0, 0, .10);
}

.sign-row {
    display: grid;
    gap: 10px;
}

.sign-btn {
    width: 100%;
}

#sig {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 12px;
    background: rgba(0, 0, 0, .15);
}

@media (max-width: 639px) {
    #sig {
        height: 260px;
    }
}

@media (min-width: 640px) {
    .sign-row {
        grid-template-columns: 1fr auto;
    }

    #sig {
        height: 220px;
    }
}
