/* ================================================================
   DNS Updater - Complete Stylesheet (Dark Theme)
   ================================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #1e1e36;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #0f3460;
  --accent-hover: #154a8a;
  --accent-light: #1a4f8a;
  --success: #00c853;
  --success-bg: #00c85315;
  --warning: #ffd600;
  --warning-bg: #ffd60015;
  --error: #ff1744;
  --error-bg: #ff174415;
  --info: #2196f3;
  --info-bg: #2196f315;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --transition: 0.2s ease;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea, button { font-size: inherit; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ================================================================
   Layout: App
   ================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.content {
  padding: 24px;
  flex: 1;
}

/* ---------- Top Bar ---------- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-height);
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.top-bar .user-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 4px 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.sidebar-toggle:hover {
  background: var(--border);
}

/* ================================================================
   Sidebar
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 2;
}

.sidebar-brand .brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-secondary);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--accent);
  color: var(--text-primary);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav a .nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .user-name {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}

.sidebar-footer-actions {
  display: flex;
  gap: 6px;
}

.sidebar-footer-actions .change-password-link,
.sidebar-footer-actions .logout-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.sidebar-footer-actions .change-password-link:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-footer-actions .logout-btn:hover {
  background: var(--error-bg);
  border-color: var(--error);
  color: var(--error);
}

/* ---------- Sidebar Overlay (mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
}

/* ================================================================
   Auth Pages (login, register) - standalone, centered
   ================================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card .auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .auth-header .auth-logo {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-card .auth-header .auth-logo svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 2;
}

.auth-card .auth-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-card .auth-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.auth-card .auth-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-card .auth-footer a {
  color: var(--info);
  font-weight: 500;
}

/* ================================================================
   Cards
   ================================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ---------- Stat Cards (Dashboard) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card .stat-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-card .stat-icon.icon-accent { background: var(--accent); }
.stat-card .stat-icon.icon-accent svg { stroke: var(--info); }
.stat-card .stat-icon.icon-success { background: var(--success-bg); }
.stat-card .stat-icon.icon-success svg { stroke: var(--success); }
.stat-card .stat-icon.icon-warning { background: var(--warning-bg); }
.stat-card .stat-icon.icon-warning svg { stroke: var(--warning); }
.stat-card .stat-icon.icon-error { background: var(--error-bg); }
.stat-card .stat-icon.icon-error svg { stroke: var(--error); }

.stat-card .stat-info { flex: 1; min-width: 0; }
.stat-card .stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-card .stat-info .stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.stat-card .stat-info .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ================================================================
   Tables
   ================================================================ */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: var(--bg-card);
}

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

/* Stripes */
.table-striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--bg-card);
}

/* Table actions column */
.table .actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

/* ================================================================
   Forms
   ================================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:hover {
  border-color: var(--border-light);
}

.form-control:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

.form-control:disabled,
.form-control[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select.form-control option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 4px;
}

.form-control.is-invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 23, 68, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--info);
  cursor: pointer;
}

.form-check label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin: 0;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  min-height: 42px;
}

.btn:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-light);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #000;
}

.btn-success:hover:not(:disabled) {
  background: #00e060;
  border-color: #00e060;
}

.btn-success:active:not(:disabled) {
  background: #00b548;
}

.btn-danger {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #ff3d5c;
  border-color: #ff3d5c;
}

.btn-danger:active:not(:disabled) {
  background: #d0002a;
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--border-light);
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-outline:active:not(:disabled) {
  background: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  min-height: 32px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  min-height: 50px;
}

.btn-block {
  width: 100%;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

/* ================================================================
   Badges
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(0, 200, 83, 0.3);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(255, 23, 68, 0.3);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(255, 214, 0, 0.3);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.badge-neutral {
  background: rgba(160, 160, 176, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Dot badge (status indicator) */
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  padding: 0;
}

.badge-dot.badge-success { background: var(--success); }
.badge-dot.badge-error { background: var(--error); }
.badge-dot.badge-warning { background: var(--warning); }
.badge-dot.badge-info { background: var(--info); }

/* ================================================================
   Alerts / Notifications Toast
   ================================================================ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  width: 100%;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.toast.toast-success::before { background: var(--success); }
.toast.toast-error::before { background: var(--error); }
.toast.toast-warning::before { background: var(--warning); }
.toast.toast-info::before { background: var(--info); }

.toast .toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast .toast-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast.toast-success .toast-icon svg { stroke: var(--success); }
.toast.toast-error .toast-icon svg { stroke: var(--error); }
.toast.toast-warning .toast-icon svg { stroke: var(--warning); }
.toast.toast-info .toast-icon svg { stroke: var(--info); }

.toast .toast-content {
  flex: 1;
  min-width: 0;
}

.toast .toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast .toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.toast .toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 0 0 0 8px;
  cursor: pointer;
  line-height: 1;
}

.toast .toast-close:hover {
  color: var(--text-primary);
}

.toast.toast-leaving {
  animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Inline alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(0, 200, 83, 0.2);
  color: var(--success);
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(255, 23, 68, 0.2);
  color: var(--error);
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid rgba(255, 214, 0, 0.2);
  color: var(--warning);
}

.alert-info {
  background: var(--info-bg);
  border: 1px solid rgba(33, 150, 243, 0.2);
  color: var(--info);
}

.alert-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px;
}

.alert-dismiss:hover { opacity: 1; }

/* ================================================================
   Pagination
   ================================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--transition);
}

.pagination a:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
  color: var(--text-primary);
  text-decoration: none;
}

.pagination a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.pagination .active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-primary);
}

.pagination .disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination .page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 12px;
  border: none;
}

/* ================================================================
   Loading Spinner
   ================================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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

/* Loading overlay */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ================================================================
   Modal / Dialog
   ================================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-header .modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  padding: 4px;
  cursor: pointer;
  line-height: 1;
  border-radius: var(--radius-sm);
}

.modal-header .modal-close:hover {
  color: var(--text-primary);
  background: var(--border);
}

.modal-body {
  padding: 20px 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ================================================================
   Bar Chart (CSS only - dashboard)
   ================================================================ */
.chart-container {
  padding: 8px 0;
}

.chart-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 500;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding: 0 4px;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  gap: 2px;
}

.chart-bar {
  width: 100%;
  max-width: 32px;
  border-radius: 3px 3px 0 0;
  transition: height 0.6s ease;
  position: relative;
  min-height: 2px;
}

.chart-bar-success {
  background: var(--success);
}

.chart-bar-error {
  background: var(--error);
}

.chart-bar-info {
  background: var(--info);
}

.chart-bar-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  padding-top: 4px;
}

.chart-tooltip {
  display: none;
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.7rem;
  color: var(--text-primary);
  white-space: nowrap;
  z-index: 5;
}

.chart-bar:hover .chart-tooltip {
  display: block;
}

/* Chart legend */
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ================================================================
   Empty States
   ================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.empty-state .empty-icon svg {
  width: 56px;
  height: 56px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 300px;
}

/* ================================================================
   Toolbar / Filters
   ================================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.toolbar-start {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.filter-group .form-control {
  width: auto;
  min-width: 150px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* Search input */
.search-input {
  position: relative;
}

.search-input .form-control {
  padding-left: 36px;
}

.search-input .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ================================================================
   Page Header
   ================================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ================================================================
   Info Grid (Config page)
   ================================================================ */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-item .info-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.info-item .info-value {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ================================================================
   Responsive
   ================================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .sidebar-toggle {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .content {
    padding: 16px;
  }

  .top-bar {
    padding: 0 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-start,
  .toolbar-end {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group .form-control {
    width: 100%;
    min-width: 0;
  }

  .search-input .form-control {
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-container {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .table th,
  .table td {
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .table .actions-cell {
    flex-direction: column;
    gap: 4px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .btn-block-mobile {
    width: 100%;
    justify-content: center;
  }

  .modal {
    max-width: 100%;
    margin: 16px;
  }
}

/* Large */
@media (min-width: 1440px) {
  .content {
    padding: 32px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ================================================================
   Utility Classes
   ================================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }

.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }

.w-full { width: 100%; }

.hidden { display: none; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Mark required fields */
.required::after {
  content: ' *';
  color: var(--error);
}
