/* ── Reset & tokens ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22263a;
    --border: #2e3250;
    --accent: #5c6ef8;
    --accent-h: #4a5ce6;
    --danger: #e05252;
    --danger-h: #c84040;
    --text: #e4e6f1;
    --text-muted: #7980a5;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
    --font: 'Inter', system-ui, sans-serif;
}

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

.view {
    height: 100%;
}

.view.center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert {
    padding: .6rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(224, 82, 82, .15);
    border: 1px solid rgba(224, 82, 82, .4);
    color: #f08080;
}

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

/* ── Brand ───────────────────────────────────────────────────────────────── */
.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1.75rem;
    user-select: none;
}

.brand-icon {
    font-size: 1.4rem;
    filter: hue-rotate(200deg);
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .03em;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.btn:disabled {
    opacity: .5;
    cursor: default;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-h);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-h);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface2);
    color: var(--text);
}

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

.btn-sm {
    padding: .3rem .7rem;
    font-size: .8rem;
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: .2rem .4rem;
    border-radius: 4px;
    margin-left: auto;
}

.btn-close:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: .9rem;
    padding: .25rem .5rem;
    border-radius: 6px;
    transition: background .12s, color .12s;
}

.btn-icon:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-icon.danger:hover {
    background: rgba(224, 82, 82, .15);
    color: var(--danger);
}

/* ── Login card ──────────────────────────────────────────────────────────── */
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}

.login-card h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
label {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

label>input,
label>select,
label>textarea {
    display: block;
    width: 100%;
    margin-top: .35rem;
    padding: .55rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    transition: border-color .15s;
    outline: none;
}

label>input:focus,
label>select:focus,
label>textarea:focus {
    border-color: var(--accent);
}

label>select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%237980a5' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    background-size: 12px;
    padding-right: 2rem;
}

/* ── App layout ──────────────────────────────────────────────────────────── */
#view-app {
    display: flex;
}

.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
}

.sidebar-brand {
    margin-bottom: 2rem;
}

nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .6rem .8rem;
    border-radius: var(--radius);
    text-align: left;
    font-size: .9rem;
    transition: background .12s, color .12s;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(92, 110, 248, .15);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.05rem;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.sidebar-user {
    font-size: .78rem;
    color: var(--text-muted);
    word-break: break-all;
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.panel-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

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

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

thead th {
    text-align: left;
    padding: .65rem .9rem;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

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

tbody td {
    padding: .7rem .9rem;
    font-size: .9rem;
}

tbody td:last-child {
    text-align: right;
    white-space: nowrap;
}

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-admin {
    background: rgba(92, 110, 248, .2);
    color: #8fa8ff;
}

.badge-fleet {
    background: rgba(80, 200, 140, .2);
    color: #50c88c;
}

.badge-active {
    background: rgba(80, 200, 140, .2);
    color: #50c88c;
}

.badge-inactive,
.badge-maintenance {
    background: rgba(224, 82, 82, .18);
    color: #f08080;
}

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

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-box-sm {
    max-width: 340px;
}

.modal-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

#confirm-message {
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: .5rem;
}