:root {
    --bg: #0f1220;
    --surface: #171b2e;
    --surface-2: #1f2440;
    --border: #2a2f4d;
    --text: #e7e9f5;
    --text-muted: #9aa0c3;
    --primary: #6d5bff;
    --primary-hover: #5847e0;
    --danger: #ff5c72;
    --success: #35d399;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* -- Topbar ------------------------------------------------------ */
.topbar {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
}
.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.nav-user {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: 0.25rem;
}
.inline-form { display: inline; }

/* -- Layout -------------------------------------------------------- */
.main { padding: 2rem 1.25rem 3rem; }
.footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* -- Cards --------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
}
.card-narrow {
    max-width: 520px;
    margin: 0 auto;
}
.card.center { text-align: center; }

/* -- Forms ----------------------------------------------------------*/
.field { margin-bottom: 1.1rem; }
.field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.field-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.field-row .field { flex: 1 1 160px; }

input[type="text"],
input[type="password"],
input[type="number"],
input.input,
select.input,
select,
textarea,
textarea.input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.help-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.field-error, .form-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}
.form-error {
    background: rgba(255, 92, 114, 0.1);
    border: 1px solid rgba(255, 92, 114, 0.35);
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* -- Buttons ----------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--primary); }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(255, 92, 114, 0.12); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* -- Table ----------------------------------------------------------*/
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    white-space: nowrap;
}
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.table tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: rgba(53, 211, 153, 0.15); color: var(--success); }
.badge-inactive { background: rgba(255, 92, 114, 0.15); color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* -- Misc ------------------------------------------------------------*/
.muted { color: var(--text-muted); font-size: 0.92rem; }
.warning-note { color: #ffb454; font-size: 0.85rem; margin-top: 1rem; }
.messages { margin-bottom: 1.25rem; }
.message {
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.message-success { background: rgba(53, 211, 153, 0.12); color: var(--success); }
.message-error { background: rgba(255, 92, 114, 0.12); color: var(--danger); }

.result-panel { margin-top: 1.5rem; }
.share-link-row { display: flex; gap: 0.5rem; }
.share-link-row .input { flex: 1; }

@media (max-width: 640px) {
    .topbar-inner { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
    .card { padding: 1.25rem; }
}
