:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface-2: #243044;
    --border: #2d3a4f;
    --text: #e8edf4;
    --muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1419 0%, #1a2744 100%);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 2rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand .logo { font-size: 3rem; }
.auth-brand h1 { font-size: 1.5rem; margin: 0.5rem 0; }
.auth-brand p { color: var(--muted); }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Layout app */
body:not(.auth-page) {
    display: grid;
    grid-template-columns: 240px 1fr;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.nav-links { list-style: none; flex: 1; }

.nav-links a {
    display: block;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 0.25rem;
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--surface-2);
    color: var(--text);
}

.main-content {
    padding: 2rem;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
.page-header p { color: var(--muted); }

.page-header .btn { margin-top: 0.5rem; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tabs-inline {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.tabs-inline a {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    text-decoration: none;
}

.tabs-inline a.active {
    background: var(--primary);
    color: white;
}

/* Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    text-decoration: none;
}

.card-highlight { border-color: var(--primary); }
.card-disabled { opacity: 0.5; pointer-events: none; }

.card-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.card h2 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.card p { color: var(--muted); font-size: 0.9rem; }

.card-status { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Forms */
.form label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.form input,
.form select,
.form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
}

.form textarea { resize: vertical; font-family: inherit; }

.form-inline-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    align-items: end;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* Panels */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.panel-desc {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.domain-panel h3,
.zone-panel h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Table */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th { color: var(--muted); font-weight: 600; }

.actions-cell { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Alerts & badges */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: rgba(34, 197, 94, 0.15); border: 1px solid var(--success); color: #86efac; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-ko, .badge-error { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid var(--primary);
    color: #93c5fd;
}

.result-summary {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.result-summary .badge {
    font-size: 0.9rem;
    padding: 0.35rem 0.85rem;
}

.result-panel {
    border-left: 3px solid var(--border);
}

.result-panel.result-ok { border-left-color: var(--success); }
.result-panel.result-error { border-left-color: var(--danger); }

.result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.result-head h3 { margin: 0; }

.result-log {
    margin: 0.75rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.result-log li { margin-bottom: 0.3rem; }

.result-error-msg {
    margin-top: 0.5rem;
    color: #fca5a5;
    font-size: 0.9rem;
}

.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-pill {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    text-decoration: none;
}

.hosting-toggle {
    cursor: pointer;
    user-select: none;
}

.hosting-label {
    font-size: 0.85rem;
    color: var(--muted);
}

.row-hosted .hosting-label { color: var(--success); }
.row-unused .hosting-label { color: var(--muted); }

.data-table tr.row-unused td:first-child + td {
    border-left: 3px solid transparent;
}

.data-table tr.row-hosted td:first-child + td {
    border-left: 3px solid var(--success);
}

.info-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--muted);
}

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }

.auth-footer-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.master-panel {
    border-color: var(--primary);
    background: var(--surface-2);
}

.bulk-individual {
    margin-top: 1.5rem;
}

.bulk-individual > summary {
    cursor: pointer;
    color: var(--muted);
    padding: 0.5rem 0;
    font-size: 0.95rem;
}

.bulk-individual > summary:hover {
    color: var(--text);
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-inline input {
    width: auto;
    margin: 0;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

.inline-form { display: inline; }

.add-record { margin-top: 1rem; }
.add-record summary { cursor: pointer; color: var(--primary); margin-bottom: 0.5rem; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.logout-form { margin-top: auto; padding-top: 1rem; }

code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

@media (max-width: 768px) {
    body:not(.auth-page) { grid-template-columns: 1fr; }
    .sidebar { min-height: auto; }
    .main-content { padding: 1rem; }
}
