:root {
    --sidebar-w: 240px;
    --sidebar-bg: #1f2937;
    --sidebar-text: #e5e7eb;
    --sidebar-muted: #9ca3af;
    --sidebar-active: #2563eb;
    --content-bg: #f3f4f6;
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", Tahoma, sans-serif;
    background: var(--content-bg);
    margin: 0;
}

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    padding: 0 1.25rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 1rem;
}
.sidebar .brand i { margin-right: 8px; color: #60a5fa; }
.sidebar .nav { padding: 0 .5rem; flex: 1; }
.sidebar .nav-link {
    color: var(--sidebar-muted);
    padding: .65rem 1rem;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: .95rem;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
}
.sidebar .nav-link i { margin-right: 10px; width: 18px; display: inline-block; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .text-muted { color: var(--sidebar-muted) !important; }

.content {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 100%;
    overflow-x: hidden;
}

/* ---------- Cards / stats ---------- */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid #e5e7eb;
    height: 100%;
}
.stat-card .label { color: #6b7280; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }
.stat-card .delta { font-size: .85rem; margin-top: .25rem; }
.stat-card.primary { border-left: 4px solid #2563eb; }
.stat-card.success { border-left: 4px solid #16a34a; }
.stat-card.warning { border-left: 4px solid #d97706; }
.stat-card.danger  { border-left: 4px solid #dc2626; }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }

.table-card {
    background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.table-card .table { margin: 0; }
.table-card .table thead { background: #f9fafb; }
.table-card .table thead th {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
    color: #6b7280; font-weight: 600; border-bottom: 1px solid #e5e7eb;
}
.table-card .table tbody td { vertical-align: middle; font-size: .92rem; }

.section-card {
    background: #fff; border-radius: 10px; border: 1px solid #e5e7eb;
    padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.05); margin-bottom: 1.25rem;
}
.section-card h5 { margin-bottom: 1rem; font-weight: 600; }

/* ---------- Login ---------- */
.login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #7c3aed 100%);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: #fff; border-radius: 12px; padding: 2rem; width: 100%; max-width: 380px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; padding: .75rem; }
    .sidebar .brand { padding: 0 .5rem .75rem; }
    .sidebar .nav { flex-direction: row !important; overflow-x: auto; flex-wrap: nowrap; }
    .sidebar .nav-link { white-space: nowrap; }
    .sidebar-footer { padding: .75rem; }
    .content { padding: 1rem; }
}

.text-money { font-variant-numeric: tabular-nums; }
.text-mono   { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

a.btn { text-decoration: none; }
.table .actions { white-space: nowrap; }
.table .actions a { margin-right: .25rem; }
