:root[data-theme="dark"] {
    --bg: #0b0e14;
    --panel: #151a24;
    --panel-2: #1b2230;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e6e9ef;
    --text-dim: #9aa4b2;
    --accent: #00d4ff;
    --accent-dim: rgba(0, 212, 255, 0.15);
    --danger: #ff5470;
    --danger-dim: rgba(255, 84, 112, 0.15);
    --success: #33d17a;
}

:root[data-theme="light"] {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --panel-2: #eef1f6;
    --border: rgba(0, 0, 0, 0.08);
    --text: #1a2130;
    --text-dim: #5b6472;
    --accent: #0090b8;
    --accent-dim: rgba(0, 144, 184, 0.12);
    --danger: #c9294a;
    --danger-dim: rgba(201, 41, 74, 0.1);
    --success: #1f9d55;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
    direction: rtl;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 360px;
    text-align: center;
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.08);
}

.login-logo {
    max-width: 180px;
    margin-bottom: 16px;
}

.login-box h1 {
    font-size: 20px;
    margin: 0 0 4px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin: 0 0 20px;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: right;
}

.login-box label {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 8px;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.brand-logo {
    height: 32px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.username {
    color: var(--text-dim);
    font-size: 14px;
}

#themeToggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.logout-link {
    color: var(--danger);
    text-decoration: none;
    font-size: 14px;
}

/* Main nav */
.mainnav {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    max-width: 1000px;
    margin: 0 auto;
}

.navtab {
    background: transparent;
    color: var(--text-dim);
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.navtab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

/* Main content */
#app {
    padding: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.registered { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.unavailable { background: var(--text-dim); }
.status-dot.missing { background: var(--danger); }
.status-dot.suspended { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.quota-banner {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 600;
}

.quota-banner.warn {
    background: rgba(255, 180, 0, 0.15);
    color: #c98a00;
    border: 1px solid rgba(255, 180, 0, 0.4);
}

.quota-banner.critical {
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.quota-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
}

.breadcrumb {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar h2 {
    margin: 0;
    font-size: 18px;
}

button, .btn {
    background: var(--accent);
    color: #061018;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

button.danger {
    background: var(--danger);
    color: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

th, td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--text-dim);
    font-weight: 600;
    background: var(--panel-2);
}

tbody tr:hover {
    background: var(--panel-2);
    cursor: pointer;
}

tbody tr:last-child td {
    border-bottom: none;
}

.row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.row-actions button {
    padding: 5px 10px;
    font-size: 12px;
}

.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 380px;
    max-width: 90vw;
}

.modal-box h3 {
    margin-top: 0;
}

.modal-box form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-box label {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

input, textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
}

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

/* Alerts / toast */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}

.alert-error {
    background: var(--danger-dim);
    color: var(--danger);
}

.alert-success {
    background: rgba(51, 209, 122, 0.12);
    color: var(--success);
}

#toastRoot {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
}

.toast {
    background: var(--panel);
    border: 1px solid var(--accent);
    box-shadow: 0 0 12px var(--accent-dim);
    border-radius: 10px;
    padding: 14px 16px;
    max-width: 320px;
    font-size: 14px;
}

.toast .toast-secret {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
    margin: 6px 0;
}
