:root {
    --bg: #151B2C;
    --surface: #1D2740;
    --surface-2: #283354;
    --ink: #F1F4FB;
    --ink-soft: #9BA6C4;
    --primary: #121729;
    --primary-soft: #202A46;
    --accent: #3EEBD4;
    --accent-dim: #22A895;
    --line: #303C5C;

    --role-student: #3EEBD4;
    --role-lecturer: #FFC078;
    --role-canteen: #FF9FB6;
    --role-koop: #C3B2FF;

    --radius: 14px;
    --font-display: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); }

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

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--primary);
    color: #D2DAEC;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

.sidebar .brand {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 36px;
}

/* ---------- Institution logo ---------- */
.sidebar .brand .brand-logo {
    flex: 0 0 100%;
    width: 100%;
    max-width: 160px;
    height: auto;
    display: block;
    background: #FFFFFF;
    border-radius: 8px;
    padding: 8px 10px;
    box-sizing: border-box;
    margin-bottom: 2px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.auth-logo {
    display: block;
    width: 190px;
    max-width: 100%;
    height: auto;
    background: #FFFFFF;
    border-radius: 10px;
    padding: 10px 12px;
    box-sizing: border-box;
    margin: 0 0 18px 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.sidebar .brand .chip {
    width: 30px;
    height: 22px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(62,235,212,0.45);
}
.sidebar .brand .chip::before {
    content: "";
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(0,0,0,0.35);
    border-radius: 2px;
}

.sidebar .brand-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14.5px;
    line-height: 1.25;
    letter-spacing: 0.2px;
    color: #FAFBFF;
}
.sidebar .brand-text span {
    display: block;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: #6E7BA0;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: #A6B0CC;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    transition: background .15s ease, color .15s ease, padding-left .15s ease;
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: #FAFBFF; padding-left: 16px; }
.nav-item.active { background: var(--accent); color: #05261F; font-weight: 600; border-left-color: #05261F; }

.sidebar-foot {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: #6E7BA0;
}
.sidebar-foot .who {
    font-family: var(--font-mono);
    color: #D2DAEC;
    display: block;
    margin-bottom: 8px;
}

.main {
    flex: 1;
    padding: 36px 44px;
    max-width: 980px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #FAFBFF;
}
.page-sub {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0 0 28px 0;
}

/* ---------- Auth (login) page ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image: radial-gradient(circle at 15% 20%, rgba(62,235,212,0.14), transparent 42%),
                       radial-gradient(circle at 85% 80%, rgba(195,178,255,0.14), transparent 42%);
}
.auth-card {
    width: 360px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 34px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.auth-chip {
    width: 42px;
    height: 30px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    position: relative;
    margin-bottom: 18px;
    box-shadow: 0 0 22px rgba(62,235,212,0.4);
}
.auth-chip::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(0,0,0,0.35);
    border-radius: 3px;
}
.auth-card h1 {
    font-family: var(--font-display);
    font-size: 20px;
    margin: 0 0 2px 0;
    color: #FAFBFF;
}
.auth-card p.sub {
    color: var(--ink-soft);
    font-size: 13px;
    margin: 0 0 22px 0;
}

.back-home {
    display: inline-block;
    margin-top: 18px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
}
.back-home:hover { color: var(--accent); }

/* ---------- Form elements ---------- */
label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
input[type=text], input[type=email], input[type=password], input[type=number], select {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--surface-2);
    color: var(--ink);
    margin-bottom: 18px;
    transition: border-color .15s;
}
input::placeholder { color: #6E7BA0; }
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(62,235,212,0.16);
}
input:hover:not(:focus), select:hover:not(:focus) {
    border-color: #3D4B72;
}

button, .btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: 9px;
    padding: 11px 20px;
    cursor: pointer;
    background: var(--accent);
    color: #05261F;
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
button:hover, .btn:hover { box-shadow: 0 6px 22px rgba(62,235,212,0.4); filter: brightness(1.06); }
button:active, .btn:active { transform: translateY(1px); filter: brightness(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }

.alert {
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-error { background: rgba(255,159,182,0.14); color: #FF9FB6; border-color: rgba(255,159,182,0.32); }
.alert-ok { background: rgba(62,235,212,0.13); color: #3EEBD4; border-color: rgba(62,235,212,0.32); }

/* ---------- Role card tiles (signature element) ---------- */
.role-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 30px;
}
.role-tile {
    position: relative;
    background: var(--surface);
    border-radius: 12px;
    padding: 16px 16px 14px;
    color: #F1F4FB;
    cursor: pointer;
    border: 2px solid var(--line);
    overflow: hidden;
    aspect-ratio: 1.55/1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.role-tile:hover {
    transform: translateY(-3px);
    border-color: #3D4B72;
}
.role-tile::after {
    content: "";
    position: absolute;
    top: -60%; left: -20%;
    width: 60%; height: 220%;
    background: rgba(255,255,255,0.04);
    transform: rotate(20deg);
}
.role-tile .stripe {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
}
.role-tile[data-role=student] .stripe { background: var(--role-student); }
.role-tile[data-role=lecturer] .stripe { background: var(--role-lecturer); }
.role-tile[data-role=canteen] .stripe { background: var(--role-canteen); }
.role-tile[data-role=koop] .stripe { background: var(--role-koop); }

.role-tile .role-chip {
    width: 26px; height: 19px;
    border-radius: 4px;
    background: rgba(255,255,255,0.9);
    position: relative;
}
.role-tile .role-chip::before {
    content: "";
    position: absolute; inset: 3px;
    border: 1px solid rgba(10,14,24,0.45);
    border-radius: 2px;
}
.role-tile .role-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    color: #FAFBFF;
}
.role-tile .role-desc {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: #7E89A8;
    letter-spacing: 0.03em;
}
.role-tile.selected {
    border-color: var(--accent);
    box-shadow: 0 8px 28px rgba(62,235,212,0.22);
}
.role-tile.selected::after { display: none; }

.form-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px 28px;
    display: none;
}
.form-panel.visible { display: block; }
.form-panel .panel-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 18px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #FAFBFF;
}
.form-panel .panel-title .dot {
    width: 9px; height: 9px;
    border-radius: 50%;
}

/* ---------- Tables (dashboard) ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    transition: border-color .15s ease;
}
.panel:hover { border-color: #3A466B; }
.panel h3 {
    font-family: var(--font-display);
    font-size: 15px;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    color: #FAFBFF;
}
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1.5px solid var(--line);
}
td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    color: #E1E6F2;
    transition: background .12s ease;
}
td.mono, .uid { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:not(:first-child):hover td { background: rgba(255,255,255,0.03); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-active { background: rgba(62,235,212,0.14); color: #3EEBD4; }
.badge-inactive { background: rgba(155,166,196,0.18); color: #9BA6C4; }
.badge-role-student { background: rgba(62,235,212,0.14); color: #3EEBD4; }
.badge-role-lecturer { background: rgba(255,192,120,0.17); color: #FFC078; }
.badge-role-canteen { background: rgba(255,159,182,0.17); color: #FF9FB6; }
.badge-role-koop { background: rgba(195,178,255,0.17); color: #C3B2FF; }

/* ---------- Row action links (E-Wallet / Attendance) ---------- */
.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.row-actions a {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 7px;
    text-decoration: none;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--accent);
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
}
.row-actions a:hover { background: var(--accent); color: #05261F; }
.row-actions a.attendance-link { color: var(--role-lecturer); }
.row-actions a.attendance-link:hover { background: var(--role-lecturer); color: #2A1704; }

/* ---------- Detail pages (cardholder wallet / attendance) ---------- */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}
.balance-figure {
    font-family: var(--font-display);
    font-size: 34px;
    font-weight: 700;
    color: var(--accent);
    margin: 4px 0 0 0;
}
.mini-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.mini-form > div { margin-bottom: 0; }
.mini-form input[type=number] { margin-bottom: 0; width: 160px; }
.mini-form select { margin-bottom: 0; width: 160px; }
.text-deduct { background: #E15C50 !important; }

.empty-row td {
    color: var(--ink-soft);
    font-style: italic;
    text-align: center;
    padding: 22px;
}

/* ---------- Overview stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 26px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease;
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: #3A466B;
}
.stat-card .stripe {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
}
.stat-card[data-role=student] .stripe { background: var(--role-student); }
.stat-card[data-role=lecturer] .stripe { background: var(--role-lecturer); }
.stat-card[data-role=canteen] .stripe { background: var(--role-canteen); }
.stat-card[data-role=koop] .stripe { background: var(--role-koop); }

.stat-card .stat-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    margin-bottom: 10px;
}
.stat-card .stat-count {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 8px;
    color: #FAFBFF;
}
.stat-card .stat-sub {
    font-size: 12.5px;
    color: var(--ink-soft);
}
.stat-card .stat-sub .amt {
    font-family: var(--font-mono);
    color: #E1E6F2;
    font-weight: 500;
}

.summary-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: var(--primary);
    color: #F1F4FB;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 24px;
    margin-bottom: 26px;
}
.summary-bar .item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.summary-bar .item .k {
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6E7BA0;
}
.summary-bar .item .v {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: #FAFBFF;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.filter-tab {
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surface);
    border: 1.5px solid var(--line);
    color: var(--ink-soft);
    cursor: pointer;
}
.filter-tab.active {
    background: var(--accent);
    color: #05261F;
    border-color: var(--accent);
}

.chart-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    margin-bottom: 26px;
}
.chart-grid .panel { margin-bottom: 0; }

/* ---------- Finishing details ---------- */
::selection {
    background: rgba(62,235,212,0.32);
    color: #FAFBFF;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3D4B72; }

.auth-card, .panel, .form-panel, .stat-card, .role-tile, .summary-bar {
    animation: fadeInUp .25s ease both;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}