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

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --surface2:  #22263a;
    --border:    #2e3250;
    --accent:    #f6821f;
    --accent2:   #faad3d;
    --text:      #e8eaf0;
    --muted:     #8890a8;
    --green:     #22c55e;
    --red:       #ef4444;
    --yellow:    #eab308;
    --radius:    8px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.6;
}

/* ── Nav ────────────────────────────────────────── */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.nav-brand svg { width:22px; height:22px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-weight: 500;
    transition: color .15s, background .15s;
}
.nav-link:hover, .nav-link.active { color: var(--text); background: var(--surface2); }
.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
    margin-left: auto;
}
.nav-user strong { color: var(--text); }
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── Main layout ────────────────────────────────── */
.main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── Card ───────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }

/* ── Login ──────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}
.login-box { width: 100%; max-width: 380px; }
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo svg { width: 44px; height: 44px; color: var(--accent); }
.login-logo h1 { font-size: 20px; font-weight: 700; margin-top: 10px; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }
select.form-control option { background: var(--surface2); }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s, background .15s;
    white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; }
.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-full    { width: 100%; justify-content: center; }

/* ── Alert ──────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border-left: 3px solid;
}
.alert-error   { background: rgba(239,68,68,.1);  border-color: var(--red);   color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1);  border-color: var(--green); color: #86efac; }
.alert-info    { background: rgba(246,130,31,.1); border-color: var(--accent);color: var(--accent2); }

/* ── Search bar ─────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}
.search-bar .form-control { font-size: 15px; padding: 11px 14px; }
.search-bar .btn { padding: 11px 20px; }

/* ── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-active  { background: rgba(34,197,94,.15); color: var(--green); }
.badge-pending { background: rgba(234,179,8,.15);  color: var(--yellow); }
.badge-inactive{ background: rgba(239,68,68,.15);  color: var(--red); }
.badge-on      { background: rgba(246,130,31,.15); color: var(--accent2); }
.badge-off     { background: rgba(136,144,168,.1); color: var(--muted); }

/* ── Dev mode toggle ────────────────────────────── */
.toggle-form { display: inline; }
.toggle-form button {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

/* ── Page header ────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p  { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Modal overlay for add/edit ─────────────────── */
.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }

/* ── Textarea ───────────────────────────────────── */
textarea.form-control {
    resize: vertical;
    min-height: 90px;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* ── Stat cards ─────────────────────────────────── */
.stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}
.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}
.stat-label {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

/* ── Bulk bar ────────────────────────────────────── */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ── Sort/filter toolbar ─────────────────────────── */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.muted-count { color: var(--muted); font-weight: 400; font-size: 13px; }

/* ── Pagination bar ─────────────────────────────── */
.pager {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Settings page ──────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

/* ── Permissions grid (roles.php) ───────────────── */
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.perm-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: var(--surface2);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    border: 1px solid var(--border);
    transition: border-color .15s;
}
.perm-check:hover { border-color: var(--accent); }
.perm-check input { margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }
.perm-check code  { display: block; color: var(--accent); font-size: 11px; }
.perm-label       { color: var(--muted); display: block; margin-top: 2px; }

/* ── Pagination ─────────────────────────────────── */
.pagination { display:flex; gap:8px; justify-content:center; margin-top:20px; }

/* ── Misc ───────────────────────────────────────── */
.domain-name { font-weight: 600; color: var(--text); }
.domain-id   { font-size: 11px; color: var(--muted); font-family: monospace; }
.action-cell { display: flex; gap: 8px; align-items: center; }
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}
.empty-state p { margin-top: 8px; font-size: 13px; }
