:root {
    --teal: #0f6e63;
    --teal-dark: #0b5249;
    --teal-light: #e3f1ef;
    --navy: #12303a;
    --bg: #f2f7f6;
    --card: #ffffff;
    --ink: #1c2b2b;
    --muted: #6a807c;
    --border: #dbe7e4;
    --danger: #c0392b;
    --danger-bg: #fdecea;
    --success: #1e7e57;
    --success-bg: #e6f4ec;
    --warn: #8a6d00;
    --warn-bg: #fff5cc;
    --warn-border: #ffe38a;
    --shadow: 0 1px 3px rgba(18, 48, 58, .08), 0 6px 20px rgba(18, 48, 58, .05);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: var(--teal);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---- Layout ---- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    background: var(--navy);
    color: #cfe0dd;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
    padding: 6px 8px 18px;
}

.brand .logo {
    font-size: 1.5rem;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #cfe0dd;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: .95rem;
    margin-bottom: 2px;
}

.nav a:hover {
    background: rgba(255, 255, 255, .07);
    text-decoration: none;
}

.nav a.active {
    background: var(--teal);
    color: #fff;
}

.sidebar .spacer {
    flex: 1;
}

.sidebar .signout {
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-top: 12px;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    font-size: 1.15rem;
    margin: 0;
}

.topbar .user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .9rem;
    color: var(--muted);
}

.topbar .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--teal-light);
    color: var(--teal-dark);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.content {
    padding: 26px;
    max-width: 1160px;
    width: 100%;
}

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 1.05rem;
}

.card .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card .card-head h2 {
    margin: 0;
}

/* ---- Stat tiles ---- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.tile .label {
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tile .value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy);
    margin-top: 4px;
}

.tile .value small {
    font-size: .9rem;
    font-weight: 500;
    color: var(--muted);
}

.tile.accent {
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    border: none;
    color: #fff;
}

.tile.accent .label,
.tile.accent .value {
    color: #fff;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

tbody tr:hover {
    background: var(--teal-light);
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.badge.confirmed {
    background: var(--success-bg);
    color: var(--success);
}

.badge.pending {
    background: var(--warn-bg);
    color: var(--warn);
}

.badge.expired,
.badge.cancelled,
.badge.failed {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ---- Forms ---- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 5px;
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 110, 99, .12);
}

.field {
    margin-bottom: 14px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    border: none;
    border-radius: 9px;
    background: var(--teal);
    color: #fff;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn:hover {
    background: var(--teal-dark);
    text-decoration: none;
}

.btn.secondary {
    background: #fff;
    color: var(--teal-dark);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--teal-light);
}

.btn.danger {
    background: var(--danger);
}

.btn.sm {
    padding: 6px 11px;
    font-size: .82rem;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #f3c6c0;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #bfe3cf;
}

.test-banner {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: .92rem;
}

.test-banner .code {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: .18em;
    color: var(--navy);
}

/* ---- Bar chart (pure CSS) ---- */
.bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 10px;
}

.bars .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 6px;
}

.bars .bar {
    width: 70%;
    max-width: 34px;
    background: linear-gradient(180deg, var(--teal), var(--teal-dark));
    border-radius: 6px 6px 0 0;
    min-height: 2px;
}

.bars .bar-label {
    font-size: .68rem;
    color: var(--muted);
    white-space: nowrap;
}

/* ---- Login ---- */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--teal-dark), var(--navy));
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
    padding: 34px 30px;
    width: 100%;
    max-width: 380px;
}

.login-card .brand {
    color: var(--navy);
    justify-content: center;
    font-size: 1.5rem;
    padding-bottom: 6px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 22px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    padding: 12px;
}

.login-hint {
    margin-top: 18px;
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
}

.muted {
    color: var(--muted);
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--teal-light);
    color: var(--teal-dark);
    font-size: .78rem;
    font-weight: 600;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filters .field {
    margin-bottom: 0;
    min-width: 140px;
}

.pager {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 14px;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left .2s;
        z-index: 40;
    }

    .sidebar.open {
        left: 0;
    }

    .content {
        padding: 16px;
    }

    .menu-toggle {
        display: inline-flex !important;
    }
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--navy);
}
