:root {
    --bg: #f8f9fa;
    --surface: #fff;
    --border: #dee2e6;
    --text: #212529;
    --muted: #6c757d;
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --danger-hover: #bb2d3b;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Nav */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--text);
    color: #fff;
    padding: 0 1.5rem;
    height: 48px;
}
nav a { color: #ccc; text-decoration: none; padding: 0.5rem 0.75rem; font-size: 14px; }
nav a:hover, nav a.active { color: #fff; }
.nav-brand { font-weight: 700; color: #fff !important; font-size: 16px; margin-right: 1rem; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 0.25rem; }
.nav-user { color: var(--muted); font-size: 13px; margin-right: 0.5rem; }

/* Main */
main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Flash */
.flash-container { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    font-size: 14px;
}
.flash-success { background: #d1e7dd; color: #0f5132; }
.flash-danger { background: #f8d7da; color: #842029; }
.flash-warning { background: #fff3cd; color: #664d03; }
.flash-info { background: #cff4fc; color: #055160; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    line-height: 1.5;
}
.btn:hover { background: #e9ecef; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 0.2rem 0.5rem; font-size: 12px; }
.btn-full { width: 100%; }

/* Badge */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-danger { background: #f8d7da; color: #842029; }
.badge-warning { background: #fff3cd; color: #664d03; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; background: var(--surface); }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f1f3f5; font-weight: 600; position: sticky; top: 0; }
tbody tr:hover { background: #f8f9fa; }
.cell-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-mono { font-family: var(--mono); font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; }
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], select, textarea {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--font);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13,110,253,.15); }

.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.inline-form input { width: auto; }
.input-xs { width: 60px !important; }
.input-sm { width: 120px !important; }
.input-lg { width: 250px !important; }
.checkbox-label { display: flex; align-items: center; gap: 0.25rem; font-size: 13px; white-space: nowrap; }
.inline { display: inline; }

.search-bar, .filter-bar { display: flex; gap: 0.5rem; align-items: center; margin: 1rem 0; }
.search-bar input, .filter-bar input { width: 250px; }
.filter-bar select { width: 150px; }

/* Login */
.login-container { max-width: 360px; margin: 4rem auto; background: var(--surface); padding: 2rem; border-radius: 8px; border: 1px solid var(--border); }
.login-container h1 { text-align: center; margin-bottom: 1.5rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: #f8f9fa; }
.card-body { padding: 1rem; }
.card-body p { margin-bottom: 0.35rem; }

/* Sections */
.section { margin-bottom: 2rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }

/* Kill switch */
.kill-switch-row { display: flex; gap: 1rem; margin: 0.75rem 0; }

/* Stats */
.stats-row { display: flex; gap: 1rem; margin: 1rem 0; }
.stat-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 0.25rem; }

/* Detail card */
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
}
.detail-card p { margin-bottom: 0.35rem; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }

/* Misc */
.muted { color: var(--muted); }
.actions { white-space: nowrap; }
.actions form { display: inline-block; }
details { margin-top: 0.75rem; }
details summary { cursor: pointer; color: var(--primary); font-size: 13px; }
.cred-form { margin-top: 0.75rem; max-width: 400px; }
.cred-form .form-group { margin-bottom: 0.5rem; }
.cred-form input { width: 100%; }

/* File drop */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 2rem;
    text-align: center;
    margin: 1rem 0;
    cursor: pointer;
    transition: border-color 0.2s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: #f0f7ff; }
.file-drop input[type="file"] { display: none; }
.import-form pre { background: #f1f3f5; padding: 1rem; border-radius: 4px; font-size: 13px; overflow-x: auto; }

/* Edit rows */
.edit-row td { background: #f8f9fa; }

/* Responsive */
@media (max-width: 768px) {
    .stats-row { flex-direction: column; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form input { width: 100% !important; }
    table { font-size: 12px; }
    th, td { padding: 0.35rem 0.5rem; }
    .cell-truncate { max-width: 120px; }
}
