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

:root {
    --bg:           #1a1a2e;
    --surface:      #16213e;
    --card:         #0f3460;
    --accent:       #e94560;
    --accent-h:     #c73652;
    --text:         #eaeaea;
    --text-muted:   #8890a6;
    --border:       rgba(255, 255, 255, 0.08);
    --success:      #22c55e;
    --error:        #ef4444;
    --radius:       12px;
    --shadow:       0 4px 24px rgba(0, 0, 0, 0.4);
    --transition:   0.2s ease;
}

body {
    background:  var(--bg);
    color:       var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    min-height:  100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ── Navbar ────────────────────────────────────────────── */
.navbar {
    background:      var(--surface);
    border-bottom:   1px solid var(--border);
    padding:         0 2rem;
    height:          64px;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    position:        sticky;
    top:             0;
    z-index:         100;
}

.navbar-brand {
    font-size:   1.25rem;
    font-weight: 700;
    display:     flex;
    align-items: center;
    gap:         0.5rem;
}

.brand-icon { color: var(--accent); font-size: 1.4rem; line-height: 1; }

.navbar-actions { display: flex; align-items: center; gap: 1rem; }

.nav-user { color: var(--text-muted); font-size: 0.875rem; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    gap:             0.45rem;
    padding:         0.5rem 1.25rem;
    border-radius:   8px;
    font-size:       0.875rem;
    font-weight:     500;
    font-family:     inherit;
    cursor:          pointer;
    border:          none;
    transition:      background var(--transition), color var(--transition),
                     border-color var(--transition), transform var(--transition);
    white-space:     nowrap;
}

.btn:active { transform: scale(0.97); }

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

.btn-block { width: 100%; padding: 0.75rem; font-size: 0.95rem; }

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

.btn-ghost               { background: transparent; color: var(--text-muted); }
.btn-ghost:hover         { color: var(--text); }

.btn:disabled            { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ── Layout ────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin:    0 auto;
    padding:   2rem;
}

.page-header { margin-bottom: 2rem; }

.page-header h1 {
    font-size:    1.75rem;
    font-weight:  700;
    margin-bottom: 0.25rem;
}

.subtitle { color: var(--text-muted); font-size: 0.875rem; }

/* ── Panel Grid ────────────────────────────────────────── */
.panels-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap:                   1.5rem;
}

/* ── Panel Card ────────────────────────────────────────── */
.panel-card {
    background:  var(--surface);
    border:      1px solid var(--border);
    border-radius: var(--radius);
    padding:     1.5rem;
    transition:  border-color var(--transition), box-shadow var(--transition);
}

.panel-card:hover {
    border-color: rgba(233, 69, 96, 0.3);
    box-shadow:   var(--shadow);
}

.panel-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    margin-bottom:   1.25rem;
}

.panel-title { font-size: 1rem; font-weight: 600; }

.panel-badge {
    font-size:     0.7rem;
    font-weight:   600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background:    rgba(233, 69, 96, 0.12);
    color:         var(--accent);
    padding:       0.2rem 0.6rem;
    border-radius: 99px;
    border:        1px solid rgba(233, 69, 96, 0.25);
}

/* ── Form Fields ───────────────────────────────────────── */
.panel-form { display: flex; flex-direction: column; gap: 0.75rem; }

.field-group { display: flex; flex-direction: column; gap: 0.3rem; }

.field-label {
    font-size:      0.7rem;
    font-weight:    600;
    color:          var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.field-input,
.form-input {
    background:    var(--card);
    border:        1px solid var(--border);
    border-radius: 8px;
    color:         var(--text);
    padding:       0.6rem 0.75rem;
    font-size:     0.9rem;
    font-family:   inherit;
    width:         100%;
    transition:    border-color var(--transition);
    appearance:    none;
}

.field-input:focus,
.form-input:focus {
    outline:      none;
    border-color: var(--accent);
}

.form-select {
    background-image:    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238890a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat:   no-repeat;
    background-position: right 0.75rem center;
    padding-right:       2.25rem;
    cursor:              pointer;
}

.panel-form .btn { margin-top: 0.5rem; }

/* ── Spinner ───────────────────────────────────────────── */
.spinner {
    width:         18px;
    height:        18px;
    border:        2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation:     spin 0.6s linear infinite;
    display:       inline-block;
    flex-shrink:   0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading State ─────────────────────────────────────── */
.loading-state {
    grid-column: 1 / -1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    gap:             1rem;
    padding:         4rem;
    color:           var(--text-muted);
}

.loading-state .spinner { width: 32px; height: 32px; border-width: 3px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
    position:      fixed;
    bottom:        2rem;
    right:         2rem;
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    padding:       0.875rem 1.25rem;
    color:         var(--text);
    font-size:     0.875rem;
    max-width:     320px;
    box-shadow:    var(--shadow);
    transform:     translateY(100px);
    opacity:       0;
    transition:    transform 0.3s ease, opacity 0.3s ease;
    z-index:       1000;
    pointer-events: none;
}

.toast.show  { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error);   }

/* ── Login / Setup Page ────────────────────────────────── */
.login-page {
    min-height:      100vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         1rem;
    background:      var(--bg);
}

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

.login-logo {
    text-align:    center;
    margin-bottom: 2rem;
}

.login-icon {
    width:           56px;
    height:          56px;
    background:      var(--accent);
    border-radius:   14px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-size:       1.75rem;
    margin:          0 auto 0.75rem;
    line-height:     1;
}

.brand-name { display: block; font-size: 1.4rem; font-weight: 700; }
.brand-sub  { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.2rem; }

.login-form  { display: flex; flex-direction: column; gap: 1rem; }

.form-group  { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label  { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────────── */
.alert {
    padding:       0.75rem 1rem;
    border-radius: 8px;
    font-size:     0.875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border:     1px solid rgba(239, 68, 68, 0.3);
    color:      #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border:     1px solid rgba(34, 197, 94, 0.3);
    color:      #86efac;
}

.alert-link { font-weight: 600; margin-left: 0.5rem; }

/* ── Admin / Tabs ──────────────────────────────────────── */
.tabs {
    display:       flex;
    gap:           0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.tab-btn {
    padding:       0.75rem 1.5rem;
    background:    transparent;
    border:        none;
    color:         var(--text-muted);
    font-size:     0.9rem;
    font-weight:   500;
    font-family:   inherit;
    cursor:        pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition:    color var(--transition), border-color var(--transition);
}

.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content        { display: none; }
.tab-content.active { display: block; }

.admin-card {
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    padding:       1.5rem;
    max-width:     520px;
}

.admin-card h3 {
    font-size:    1rem;
    font-weight:  600;
    margin-bottom: 1.25rem;
}

.admin-form { display: flex; flex-direction: column; gap: 0.875rem; }

.form-grid-2 {
    display:               grid;
    grid-template-columns: 1fr 1fr;
    gap:                   0.75rem;
}

/* ── Users Table ───────────────────────────────────────── */
.users-table {
    width:           100%;
    border-collapse: collapse;
    font-size:       0.875rem;
}

.users-table th {
    text-align:    left;
    padding:       0.65rem 1rem;
    color:         var(--text-muted);
    font-weight:   500;
    border-bottom: 1px solid var(--border);
}

.users-table td {
    padding:       0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.users-table tr:last-child td { border-bottom: none; }

.badge {
    display:       inline-block;
    padding:       0.2rem 0.5rem;
    border-radius: 4px;
    font-size:     0.7rem;
    font-weight:   600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-admin { background: rgba(233, 69, 96, 0.15); color: var(--accent); }
.badge-user  { background: rgba(255, 255, 255, 0.07); color: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
    .container     { padding: 1rem; }
    .panels-grid   { grid-template-columns: 1fr; }
    .navbar        { padding: 0 1rem; }
    .navbar-actions { gap: 0.5rem; }
    .form-grid-2   { grid-template-columns: 1fr; }
    .login-card    { padding: 1.5rem; }
    .admin-card    { max-width: 100%; }
    .toast         { right: 1rem; left: 1rem; max-width: none; }
}
