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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e4e7f1;
  --text-dim: #8b90a5;
  --accent: #6c8aff;
  --accent-hover: #5a7aff;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 8px;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

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

.header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.75rem 2rem; display: flex; align-items: center; gap: 1rem; }
.header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.header .role-badge { font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; text-transform: uppercase; }
.header .role-badge.superadmin { background: rgba(248,113,113,0.15); color: var(--red); }
.header .role-badge.domainadmin { background: rgba(108,138,255,0.15); color: var(--accent); }
.header .role-badge.user { background: rgba(52,211,153,0.15); color: var(--green); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.header-right .user-label { font-size: 0.8rem; color: var(--text-dim); font-family: var(--mono); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem; }

/* Login */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-card .subtitle { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 1.5rem; }
.login-card .form-group { margin-bottom: 1rem; }
.login-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--red); padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; display: none; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card h2 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-dim); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
input, select, textarea { width: 100%; padding: 0.45rem 0.65rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: inherit; font-size: 0.85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 0.4rem 0.85rem; border: none; border-radius: 6px; font-family: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Nav tabs */
.nav-tabs { display: flex; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 2rem; }
.nav-tab { padding: 0.6rem 1.25rem; cursor: pointer; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); border-bottom: 2px solid transparent; transition: color 0.15s; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-page { display: none; }
.nav-page.active { display: block; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th { text-align: left; padding: 0.5rem; color: var(--text-dim); font-weight: 500; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--surface2); }
.mono { font-family: var(--mono); font-size: 0.78rem; }

/* Status badges */
.status-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 8px; font-weight: 600; }
.status-badge.active { background: rgba(52,211,153,0.15); color: var(--green); }
.status-badge.suspended { background: rgba(248,113,113,0.15); color: var(--red); }
.status-badge.pending { background: rgba(251,191,36,0.15); color: var(--yellow); }

/* Domain list */
.domain-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 0.5rem; cursor: pointer; transition: border-color 0.15s; }
.domain-item:hover { border-color: var(--accent); }
.domain-header { display: flex; justify-content: space-between; align-items: center; }
.domain-name { font-weight: 600; font-size: 0.95rem; }
.domain-meta { display: flex; gap: 0.5rem; align-items: center; }
.source-badge { font-size: 0.6rem; padding: 1px 6px; border-radius: 8px; font-weight: 600; text-transform: uppercase; }
.source-badge.ldap { background: rgba(108,138,255,0.15); color: var(--accent); }
.source-badge.legacy { background: rgba(251,191,36,0.15); color: var(--yellow); }
.source-badge.local { background: rgba(139,144,165,0.15); color: var(--text-dim); }
.user-count { font-size: 0.75rem; color: var(--text-dim); margin-top: 3px; }

/* DNS records */
.dns-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.dns-table th { text-align: left; padding: 0.4rem; color: var(--text-dim); font-weight: 500; font-size: 0.7rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.dns-table td { padding: 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.record-value { font-family: var(--mono); font-size: 0.75rem; word-break: break-all; background: var(--bg); padding: 3px 6px; border-radius: 4px; display: block; }
.record-type { font-weight: 600; color: var(--accent); white-space: nowrap; }
.copy-btn { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 1px 6px; border-radius: 4px; cursor: pointer; font-size: 0.7rem; }
.copy-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* Validation */
.validation-result { margin-top: 0.4rem; padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.8rem; }
.validation-result.pass { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); }
.validation-result.fail { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); }

/* Detail panels */
.detail-panel { display: none; }
.detail-panel.active { display: block; }
.back-link { color: var(--accent); cursor: pointer; font-size: 0.8rem; margin-bottom: 0.75rem; display: inline-block; }
.back-link:hover { text-decoration: underline; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }
.tab { padding: 0.5rem 1rem; cursor: pointer; font-size: 0.8rem; color: var(--text-dim); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.modal.danger { border-color: var(--red); }
.modal.danger h2 { color: var(--red); }
.modal.key-display { max-width: 700px; border: 2px solid var(--red); }

/* Key display */
.key-warning { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--red); padding: 0.75rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.85rem; font-weight: 600; }
.key-display { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; font-family: var(--mono); font-size: 0.75rem; word-break: break-all; white-space: pre-wrap; max-height: 300px; overflow-y: auto; margin-bottom: 1rem; }

/* Confirmation input */
.confirm-input { margin-top: 0.75rem; }
.confirm-input label { color: var(--red); }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.8rem; opacity: 0; transform: translateY(10px); transition: opacity 0.3s, transform 0.3s; z-index: 300; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Log filters */
.log-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; align-items: end; }
.log-filters .filter-group { display: flex; flex-direction: column; }
.log-filters label { margin-bottom: 2px; }
.log-filters input, .log-filters select { width: auto; min-width: 120px; }

/* Password strength */
.pw-strength { height: 3px; border-radius: 2px; margin-top: 4px; transition: all 0.2s; }
.pw-strength.weak { background: var(--red); width: 33%; }
.pw-strength.medium { background: var(--yellow); width: 66%; }
.pw-strength.strong { background: var(--green); width: 100%; }

.empty-state { text-align: center; padding: 2rem; color: var(--text-dim); }
.hidden { display: none !important; }

@media (max-width: 768px) {
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
  .header, .nav-tabs { padding-left: 1rem; padding-right: 1rem; }
  .log-filters { flex-direction: column; }
}

/* ── Utility classes (CSP: replaces inline style attributes) ── */

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 0.75rem; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 0.75rem; }
.ml-sm { margin-left: 6px; }
.ml-md { margin-left: 8px; }
.my-xs { margin: 4px 0; }

/* Layout */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Text colours */
.text-dim { color: var(--text-dim); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }

/* Component helpers */
.profile-line { font-size: 0.85rem; }
.hint-text { font-size: 0.8rem; color: var(--text-dim); }
.error-text { color: var(--red); font-size: 0.8rem; }
.meta-text { font-size: 0.75rem; color: var(--text-dim); }
.confirm-text { font-size: 0.85rem; margin-bottom: 1rem; }
.mono-detail { font-family: var(--mono); font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.mono-input { font-family: var(--mono); font-size: 0.8rem; }
.text-xs { font-size: 0.75rem; }
.text-xxs { font-size: 0.7rem; }
.card-success { border-color: var(--green); }
.warning-box { margin-top: 0.75rem; padding: 0.5rem; background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); border-radius: 6px; font-size: 0.8rem; color: var(--yellow); }
.checkbox-label { display: inline; text-transform: none; }
.radio-group { display: flex; gap: 0.5rem; align-items: center; margin-top: 4px; }
.radio-group label { text-transform: none; font-size: 0.85rem; color: var(--text); }
