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

:root {
    --bg:        #f4f6f9;
    --sidebar:   #1e293b;
    --sidebar-hover: #334155;
    --accent:    #3b82f6;
    --accent-hover: #2563eb;
    --danger:    #ef4444;
    --success:   #22c55e;
    --warning:   #f59e0b;
    --text:      #1e293b;
    --text-muted:#64748b;
    --border:    #e2e8f0;
    --card:      #ffffff;
    --radius:    8px;
}

html { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100%;
    display: flex;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────── */
.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--sidebar);
    color: #fff;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar h1 {
    font-size: 18px;
    font-weight: 700;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 10px;
}

.sidebar h1 a { color: #fff; }
.sidebar h1 a:hover { text-decoration: none; }

.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,.7);
    font-size: 14px;
    transition: background .15s;
}
.sidebar nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.sidebar nav a.active {
    background: var(--accent);
    color: #fff;
}
.sidebar .nav-section {
    padding: 16px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.4);
}

.main {
    flex: 1;
    padding: 24px 32px;
    min-width: 0;
}

/* ── Top bar ──────────────────────────────────────────── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.topbar h2 { font-size: 22px; font-weight: 600; }
.topbar .user { color: var(--text-muted); font-size: 13px; }
.topbar .user a { margin-left: 12px; }

/* ── Cards ────────────────────────────────────────────── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.card .value {
    font-size: 28px;
    font-weight: 700;
}

/* ── Tables ───────────────────────────────────────────── */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Status badges ────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fce4ec; color: #c62828; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-muted   { background: #f1f5f9; color: #64748b; }

/* ── Forms ────────────────────────────────────────────── */
.form-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 600px;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}
.form-group .help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
input:not([type=checkbox]):not([type=radio]),
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea { resize: vertical; min-height: 80px; }
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.checkbox-group input[type=checkbox] { width: auto; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-info    { background: #dbeafe; color: #1e40af; }
.btn-info:hover { background: #bfdbfe; }
.btn-muted   { background: #e2e8f0; color: var(--text); }
.btn-muted:hover { background: #cbd5e1; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 6px; }
.btn + .btn { margin-left: 6px; }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}
.alert-error { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Login ────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar);
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: var(--radius);
    width: 360px;
}
.login-box h1 {
    font-size: 22px;
    margin-bottom: 24px;
    text-align: center;
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-muted);
}
.pagination a { margin: 0 4px; }

/* ── Expandable row ───────────────────────────────────── */
.expand-row { cursor: pointer; }
.expand-row + tr { display: none; }
.expand-row.expanded + tr { display: table-row; }
.expand-row td:first-child::before {
    content: '▶ ';
    font-size: 10px;
    color: var(--text-muted);
}
.expand-row.expanded td:first-child::before {
    content: '▼ ';
}
.payload-cell {
    background: #f8fafc;
    padding: 14px;
}
.payload-cell pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 12px;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Filters ──────────────────────────────────────────── */
.filters {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filters .form-group { margin-bottom: 0; }
.filters input, .filters select { width: auto; min-width: 160px; }

/* ── Misc ─────────────────────────────────────────────── */
.pull-right { float: right; }
.text-muted { color: var(--text-muted); }
.text-truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 12px;
}
