:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

/* ─── Login Page ─────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(37,99,235,0.15) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 50%, rgba(124,58,237,0.12) 0%, transparent 50%);
  animation: loginBgShift 15s ease-in-out infinite alternate;
}

@keyframes loginBgShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-5%, 3%); }
}

.login-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 48px 40px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 32px 64px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,0.05) inset;
  position: relative;
  z-index: 1;
  animation: loginCardIn 0.6s cubic-bezier(0.16,1,0.3,1);
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card .login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.login-card .login-logo img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(37,99,235,0.3));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 4px 12px rgba(37,99,235,0.3)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 6px 20px rgba(124,58,237,0.4)); }
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
  color: #f1f5f9;
  text-align: center;
  font-weight: 700;
}

.login-card p {
  color: rgba(255,255,255,0.45);
  margin-bottom: 28px;
  text-align: center;
  font-size: 14px;
}

.login-card .form-group label {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.login-card input[type="email"],
.login-card input[type="password"],
.login-card input[type="text"] {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #f1f5f9;
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

.login-card input::placeholder {
  color: rgba(255,255,255,0.25);
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
  background: rgba(255,255,255,0.08);
}

.login-card .btn-login {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.login-card .btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37,99,235,0.35);
}

.login-card .btn-login:active {
  transform: translateY(0);
}

.login-card .login-error {
  background: rgba(220,38,38,0.15);
  border: 1px solid rgba(220,38,38,0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  text-align: center;
}

.login-card .login-lang-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.login-card .login-lang-btn {
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: rgba(255,255,255,0.45);
  transition: all 0.2s;
}

.login-card .login-lang-btn:hover {
  border-color: rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.7);
}

.login-card .login-lang-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.2);
}

.login-footer a {
  color: rgba(255,255,255,0.35);
  text-decoration: none;
  transition: color 0.2s;
}

.login-footer a:hover {
  color: var(--primary);
}

/* ─── Client Setup Page ──────────────────────────── */
.setup-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  position: relative;
  overflow: hidden;
}

.setup-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 40% 40%, rgba(16,185,129,0.12) 0%, transparent 50%),
              radial-gradient(ellipse at 60% 60%, rgba(37,99,235,0.1) 0%, transparent 50%);
}

.setup-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px;
  width: 520px;
  max-width: 92vw;
  box-shadow: 0 32px 64px rgba(0,0,0,.5);
  position: relative;
  z-index: 1;
  animation: loginCardIn 0.6s cubic-bezier(0.16,1,0.3,1);
}

.setup-card .setup-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.setup-card .setup-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.setup-card h1 {
  font-size: 20px;
  color: #f1f5f9;
  text-align: center;
  margin-bottom: 6px;
}

.setup-card .setup-subtitle {
  color: rgba(255,255,255,0.4);
  text-align: center;
  font-size: 14px;
  margin-bottom: 24px;
}

.setup-card .setup-welcome {
  background: rgba(37,99,235,0.1);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  line-height: 1.6;
}

.setup-card .setup-welcome strong {
  color: var(--primary);
}

.setup-card .setup-info-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.setup-card .setup-info-box h4 {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setup-card .setup-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}

.setup-card .setup-info-row:last-child {
  border-bottom: none;
}

.setup-card .setup-info-label {
  color: rgba(255,255,255,0.35);
}

.setup-card .setup-info-value {
  color: rgba(255,255,255,0.7);
  font-family: monospace;
}

.setup-card .form-group label {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setup-card input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: #f1f5f9;
  padding: 12px 14px;
}

.setup-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
  background: rgba(255,255,255,0.08);
}

.setup-card .btn-setup {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #10b981 0%, var(--primary) 100%);
  color: white;
  transition: transform 0.2s, box-shadow 0.2s;
}

.setup-card .btn-setup:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(16,185,129,0.3);
}

.setup-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.setup-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  transition: background 0.3s;
}

.setup-step.done {
  background: #10b981;
}

.setup-step.active {
  background: var(--primary);
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-brand {
  padding: 20px 24px;
  font-size: 20px;
  font-weight: 800;
  color: white;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-400);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 24px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover, .nav-item.active {
  color: white;
  background: rgba(255,255,255,.08);
}

.nav-item.active {
  border-right: 3px solid var(--primary);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user .info {
  overflow: hidden;
}

.sidebar-user .info .name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .info .email {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Main Content ───────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 {
  font-size: 18px;
  font-weight: 600;
}

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

.content-area {
  padding: 32px;
}

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

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-card .sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

/* ─── Table ──────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

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

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

th {
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

tr:hover td {
  background: var(--gray-50);
}

/* ─── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active, .badge-paid { background: var(--success-light); color: var(--success); }
.badge-suspended, .badge-overdue { background: var(--danger-light); color: var(--danger); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-email { background: var(--primary-light); color: var(--primary); }

/* ─── Forms ──────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color .2s;
  outline: none;
  background: white;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.input-group {
  display: flex;
  align-items: center;
}

.input-group input {
  border-radius: 6px 0 0 6px;
}

.input-group .input-addon {
  padding: 10px 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-left: none;
  border-radius: 0 6px 6px 0;
  font-size: 14px;
  color: var(--gray-500);
  white-space: nowrap;
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  padding: 6px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  color: var(--gray-600);
  transition: all .15s;
}
.btn-icon:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary-light); }
.btn-icon.text-danger { color: var(--danger); border-color: var(--danger-light); }
.btn-icon.text-danger:hover { background: var(--danger-light); border-color: var(--danger-light); }

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

/* ─── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .2s;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: slideUp .2s;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

/* ─── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .3s;
  max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ─── Analytics ──────────────────────────────────── */
.analytics-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

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

.analytics-filter-select {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.analytics-filter-select span {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}

.analytics-active-filter {
  margin: -8px 0 20px;
  font-size: 13px;
  color: var(--gray-600);
}

.analytics-range-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.analytics-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.analytics-domain {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.analytics-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

.analytics-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-stack {
  display: grid;
  gap: 14px;
}

.analytics-progress-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 14px;
}

.analytics-progress-row-compact {
  grid-template-columns: minmax(100px, 1.1fr) minmax(120px, 2fr) auto;
}

.analytics-progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--gray-100);
  overflow: hidden;
}

.analytics-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
}

.analytics-progress-fill-secondary {
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
}

.analytics-note {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
  background: var(--gray-50);
  border-radius: 8px;
  padding: 12px 14px;
}

.analytics-meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}

.analytics-meta-row span {
  color: var(--gray-500);
}

.analytics-meta-row a {
  color: var(--primary);
  word-break: break-all;
}

.analytics-code {
  background: var(--gray-900);
  color: #f9fafb;
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
}

/* ─── Empty State ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 16px;
}

/* ─── DNS Records ────────────────────────────────── */
.dns-record {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.dns-record .type {
  font-weight: 700;
  color: var(--primary);
}

.dns-record .value {
  word-break: break-all;
  font-family: monospace;
  font-size: 12px;
}

/* ─── Loading ────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}

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

.loading-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* ─── Responsive ─────────────────────────────────── */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray-700);
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-toggle {
    display: block;
  }
  .content-area {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .analytics-toolbar,
  .analytics-progress-row,
  .analytics-progress-row-compact,
  .analytics-meta-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .analytics-grid-two {
    grid-template-columns: 1fr;
  }
}

/* ─── Utils ──────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-gray { color: var(--gray-500); }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-mono { font-family: monospace; }
.hidden { display: none; }
.w-full { width: 100%; }
.text-right { text-align: right; }

/* ─── Detail Grid ────────────────────────────────── */
.detail-grid { display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; gap: 12px; align-items: baseline; font-size: 14px; }
.detail-row .detail-label { min-width: 140px; color: var(--gray-500); font-size: 13px; flex-shrink: 0; }
.card-body { padding: 16px 24px; }
.text-warning { color: var(--warning); }
@media (max-width: 768px) {
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* ─── Icon sizing ────────────────────────────────── */
.icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.icon svg {
  width: 16px;
  height: 16px;
}
.btn-icon .icon svg {
  width: 16px;
  height: 16px;
}

/* ─── Accessible focus styles ────────────────────── */
.btn:focus-visible,
.btn-icon:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ─── File Manager ───────────────────────────────── */
.fm-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.fm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  font-size: 13px;
}
.fm-bc-item {
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  padding: 2px 4px;
  border-radius: 4px;
}
.fm-bc-item:hover { background: var(--hover); }
.fm-bc-sep { opacity: .4; }
.fm-bc-sep svg { width: 12px; height: 12px; }
.fm-actions { display: flex; gap: 4px; }

.fm-table { font-size: 13px; }
.fm-table tbody tr { cursor: default; }
.fm-table tbody tr:hover { background: var(--hover); }
.fm-item-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.fm-item-link:hover { color: var(--primary); }
.fm-row-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.fm-row:hover .fm-row-actions { opacity: 1; }

.fm-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.fm-editor-path {
  font-family: monospace;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fm-editor-textarea {
  width: 100%;
  min-height: 60vh;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  resize: vertical;
  tab-size: 4;
}

.rotate-180 svg { transform: rotate(180deg); }

/* ─── Database ───────────────────────────────────── */
.db-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.db-data-table {
  font-size: 12px;
  white-space: nowrap;
}
.db-data-table td {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
}
.badge-info { background: #3b82f6; }

/* ═══════════════════════════════════════════
   NOTIFICATION BELL
   ═══════════════════════════════════════════ */
.notification-bell { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  background: #ef4444; color: #fff; border-radius: 9px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}
.notif-dropdown {
  position: absolute; right: 0; top: 100%; margin-top: 8px;
  width: 360px; max-height: 440px; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  z-index: 200;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.notif-list { padding: 4px; }
.notif-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  transition: background .15s;
}
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: rgba(37,99,235,0.06); border-left: 3px solid var(--primary); }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-body { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px; }

@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 24px); right: -60px; }
}

/* ═══════════════════════════════════════════
   SUPPORT TICKETS
   ═══════════════════════════════════════════ */
.ticket-header-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.ticket-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.ticket-table { width: 100%; }
.ticket-table th { font-size: 12px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.ticket-table td { vertical-align: middle; }
.ticket-row:hover { background: var(--hover); }

.priority-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}
.priority-low { background: #6b7280; }
.priority-normal { background: #3b82f6; }
.priority-high { background: #f59e0b; }
.priority-urgent { background: #ef4444; animation: pulse-dot 1.5s infinite; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Ticket Detail */
.ticket-detail { max-width: 900px; }
.ticket-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.ticket-meta-bar {
  display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap;
}
.ticket-subject-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.ticket-subject-bar h2 { font-size: 20px; font-weight: 700; margin: 0; }
.ticket-admin-controls { display: flex; gap: 8px; }
.input-sm { padding: 4px 8px; font-size: 13px; height: 32px; }
.ticket-client-info {
  padding: 10px 14px; background: var(--hover); border-radius: 8px;
  font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 6px;
}

/* Messages Thread */
.ticket-messages {
  max-height: 600px; overflow-y: auto;
  padding: 8px 0; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.ticket-message {
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--border);
  max-width: 85%;
}
.ticket-message.client { align-self: flex-start; background: var(--card-bg); }
.ticket-message.admin { align-self: flex-end; background: rgba(37,99,235,0.06); border-color: rgba(37,99,235,0.15); }
.ticket-message.internal {
  align-self: flex-end; background: rgba(245,158,11,0.06);
  border-color: rgba(245,158,11,0.2); border-style: dashed;
}
.msg-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin-bottom: 8px;
}
.msg-time { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.msg-body { font-size: 14px; line-height: 1.6; word-break: break-word; }
.msg-body a { color: var(--primary); }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--hover); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; color: var(--text); text-decoration: none;
  transition: all .15s;
}
.attachment-chip:hover { border-color: var(--primary); background: rgba(37,99,235,0.06); }
.attachment-chip small { color: var(--text-muted); }

/* Reply Box */
.ticket-reply-box {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
  transition: border-color .2s;
}
.ticket-reply-box.drag-over { border-color: var(--primary); background: rgba(37,99,235,0.03); }
.reply-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.reply-header h3 { font-size: 14px; font-weight: 600; margin: 0; }
.internal-toggle {
  font-size: 12px; display: flex; align-items: center; gap: 4px;
  cursor: pointer; color: var(--text-secondary);
}
.internal-toggle input { accent-color: #f59e0b; }
.reply-actions {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-top: 10px; gap: 12px; flex-wrap: wrap;
}
.reply-files-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }

.ticket-closed-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--hover); border-radius: 12px;
  font-size: 14px; color: var(--text-muted);
}

/* File Upload Zone */
.file-upload-zone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: all .2s;
}
.file-upload-zone:hover, .file-upload-zone.drag-over {
  border-color: var(--primary); background: rgba(37,99,235,0.03);
}
.drop-content .icon { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 8px; }
.drop-content p { font-size: 14px; margin: 4px 0; }

.file-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.file-list.compact { flex-direction: row; flex-wrap: wrap; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: var(--hover); border-radius: 8px;
  font-size: 13px;
}
.file-item.compact { padding: 4px 8px; font-size: 12px; }
.file-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-size { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.file-total { font-size: 12px; color: var(--text-muted); padding: 4px 0; }

.file-pdf, .file-xls, .file-doc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 4px;
  font-size: 8px; font-weight: 800; letter-spacing: 0.5px;
}
.file-pdf { background: #fde2e2; color: #dc2626; }
.file-xls { background: #d1fae5; color: #059669; }
.file-doc { background: #dbeafe; color: #2563eb; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 2px; color: var(--text-muted);
  display: inline-flex; align-items: center;
}
.btn-icon:hover { color: var(--danger); }
.btn-icon .icon { width: 14px; height: 14px; }

.form-row { display: flex; gap: 12px; }
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .ticket-message { max-width: 95%; }
  .ticket-subject-bar { flex-direction: column; align-items: flex-start; }
}

.btn-xs { padding: 2px 6px; font-size: 11px; }
.btn-danger { color: #ef4444; border-color: #ef4444; }
.btn-danger:hover { background: #ef4444; color: #fff; }
