/* ============================================================
   SHORT LINKS ADMIN — Design System
   Microsoft Fluent-inspired. Dark navy sidebar, white content.
   Mobile-first. No framework dependencies.
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  /* Brand */
  --accent:          #0078d4;
  --accent-hover:    #106ebe;
  --accent-light:    #e3f2fd;
  --accent-muted:    rgba(0, 120, 212, 0.12);

  /* Sidebar */
  --sidebar-bg:      #1b2a4a;
  --sidebar-hover:   rgba(255,255,255,0.07);
  --sidebar-active:  rgba(0, 120, 212, 0.25);
  --sidebar-active-border: #0078d4;
  --sidebar-text:    rgba(255,255,255,0.82);
  --sidebar-text-muted: rgba(255,255,255,0.45);
  --sidebar-width:   224px;

  /* Topbar */
  --topbar-h:        56px;
  --topbar-bg:       #ffffff;
  --topbar-border:   #e5e7eb;

  /* Surface / Neutral */
  --surface:         #ffffff;
  --surface-raised:  #ffffff;
  --bg:              #f3f5f8;
  --border:          #e5e7eb;
  --border-focus:    #0078d4;

  /* Text */
  --text-primary:    #111827;
  --text-secondary:  #6b7280;
  --text-muted:      #9ca3af;
  --text-inverse:    #ffffff;

  /* Status */
  --danger:          #d13438;
  --danger-hover:    #b02a2d;
  --danger-bg:       #fef2f2;
  --success:         #107c10;
  --success-bg:      #e8f5e9;
  --warning:         #ca5010;
  --warning-bg:      #fff3e0;

  /* Radius / Shadow */
  --radius-sm:       4px;
  --radius:          8px;
  --radius-lg:       12px;
  --shadow-sm:       0 1px 2px rgba(0,0,0,0.05);
  --shadow:          0 1px 4px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg:       0 8px 28px rgba(0,0,0,0.14);

  /* Typography */
  --font:            -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:       "Cascadia Code", "SF Mono", "Consolas", "Liberation Mono", monospace;
}

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

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

body {
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* ── LOGIN SCREEN ───────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1b2a4a 0%, #0d1b33 60%, #0a1628 100%);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.btn-login {
  width: 100%;
  padding: 13px 24px;
  font-size: 0.9375rem;
  font-weight: 500;
  justify-content: center;
  gap: 8px;
}

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
  padding: 0 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-right: 20px;
  margin-right: 4px;
  border-right: 1px solid var(--border);
  text-decoration: none;
}

.brand-icon { flex-shrink: 0; }

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 0.85rem;
}

/* ── TOP NAV LINKS ──────────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: stretch;
  height: var(--topbar-h);
  padding: 0 4px;
}

.topnav-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
}

.topnav-link:hover {
  color: var(--text-primary);
  background: var(--bg);
}

.topnav-link.active {
  color: var(--accent);
  font-weight: 600;
}

.topnav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.topnav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── TOPBAR RIGHT ───────────────────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}


.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.btn-signout:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}

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

/* Responsive topbar */
@media (max-width: 767px) {
  .topbar { padding: 0 12px; }
  .topbar-brand { padding-right: 12px; }
  .brand-sub { display: none; }
  .user-details { display: none; }
}

@media (max-width: 599px) {
  .topnav-link { padding: 0 10px; font-size: 0.82rem; }
}

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.main-content {
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px 20px;
}

@media (min-width: 768px) {
  .main-content { padding: 28px 32px; }
}

/* ── STATS BAR ──────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .stats-bar {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.stat-summary-card:hover {
  box-shadow: var(--shadow);
}

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

.stat-icon-links  { background: #eff6ff; color: #1d4ed8; }
.stat-icon-clients{ background: #fef3c7; color: #b45309; }
.stat-icon-depts  { background: #f0fdf4; color: #15803d; }
.stat-icon-users  { background: #fdf4ff; color: #7e22ce; }

.stat-summary-body { min-width: 0; }

.stat-summary-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ── SECTION HEADER ─────────────────────────────────────────── */
.section-header {
  margin-bottom: 20px;
}

.section-title-group { }

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── TAB CONTENT ────────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── FORM CARD ──────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.form-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.form-card-title svg {
  color: var(--accent);
  flex-shrink: 0;
}

/* Form layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .form-row-3 {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .form-row-3 {
    grid-template-columns: 2fr 1.2fr 1fr;
  }
}

/* Line 1: client (narrow) + URL (wide) */
@media (min-width: 640px) {
  .form-row-link-1 { grid-template-columns: 1fr 2fr; }
}

/* Line 2: custom code + description + button aligned to input height */
@media (min-width: 640px) {
  .form-row-link-2 { grid-template-columns: 1fr 1fr auto; align-items: end; }
}

/* Generic: any number of fields + button at the end, baseline-aligned */
@media (min-width: 640px) {
  .form-row-btn { grid-template-columns: 1fr auto; align-items: end; }
}

.form-field-btn { flex-shrink: 0; }
.form-field-btn .btn-primary { white-space: nowrap; height: 38px; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field-full { grid-column: 1 / -1; }

.form-field-grow { flex: 1; }

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.required {
  color: var(--danger);
  margin-left: 2px;
}

/* Form controls */
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-control:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

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

.form-control-sm {
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* Select arrow */
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Input group (select + add button side by side) */
.input-group {
  display: flex;
  gap: 6px;
}

.input-group .form-control {
  flex: 1;
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

/* Checklist group (invite client checkboxes) */
.checklist-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checklist-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.checklist-group label:hover { background: var(--bg); }

.checklist-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-bar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-search {
  position: relative;
}

.filter-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-search-input {
  padding-left: 28px;
  width: 180px;
}

.filter-search-input::-webkit-search-cancel-button { display: none; }

/* ── TABLE CARD ─────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

thead tr {
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 11px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

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

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

tbody tr:hover { background: #fafafa; }

/* ── BUTTONS ────────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled { cursor: not-allowed; }

/* Primary */
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border: 1px solid var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(0,120,212,0.3);
}

.btn-primary:active:not(:disabled) {
  background: #004578;
  box-shadow: none;
}

.btn-primary:disabled {
  background: #a0c4e8;
  border-color: #a0c4e8;
}

/* Outline */
.btn-outline {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-light);
}

.btn-outline:disabled {
  color: var(--text-muted);
  border-color: var(--border);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 5px 12px;
  font-size: 0.82rem;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: var(--text-inverse);
}

/* Small */
.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

/* Icon-only button */
.btn-icon {
  padding: 9px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-color: rgba(255,255,255,0.4) rgba(255,255,255,0.4) #fff transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-outline.btn-loading::after {
  border-color: var(--accent-muted) var(--accent-muted) var(--accent) transparent;
}

/* Copy button */
.btn-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  font-size: 0.72rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-copy:hover { background: var(--bg); color: var(--text-primary); }

.btn-copy.copied {
  background: var(--success-bg);
  color: var(--success);
  border-color: #86efac;
}

/* ── SPINNER ────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}

.loading-row td {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* ── BADGES ─────────────────────────────────────────────────── */
.code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.88rem;
}

.code a {
  color: var(--accent);
  text-decoration: none;
}

.code a:hover { text-decoration: underline; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.url {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.dept-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.domain-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: #e8eaf6;
  color: #283593;
}

.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-badge.manager { background: var(--warning-bg); color: var(--warning); }
.role-badge.member  { background: #f5f5f5; color: var(--text-secondary); }

.clicks {
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

/* ── EMPTY & TOAST ──────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1f2937;
  color: var(--text-inverse);
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

/* ── ALERTS (modal context) ─────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

.alert svg { flex-shrink: 0; margin-top: 1px; }

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-left: 3px solid #fb923c;
}

.alert-info {
  background: var(--accent-light);
  color: #0d47a1;
  border-left: 3px solid var(--accent);
}

/* ── ANALYTICS ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
}

.stat-card .value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-card .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 5px;
  font-weight: 600;
}

.analytics-section { margin-bottom: 16px; }

.analytics-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.analytics-section-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.recent-table { width: 100%; }
.recent-table th { font-size: 0.75rem; padding: 8px 12px; }
.recent-table td { font-size: 0.82rem; padding: 8px 12px; }

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.modal.modal-wide {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

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

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Key display */
.key-display {
  background: #0f172a;
  color: #7dd3fc;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
  margin-bottom: 20px;
  user-select: all;
  border: 1px solid #1e3a5f;
  letter-spacing: 0.02em;
}

/* DNS section inside modal */
.dns-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.dns-section-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.dns-section-note--muted {
  color: var(--text-muted);
  margin-bottom: 0;
  margin-top: 8px;
}

/* Confirm modal */
.confirm-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

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

/* ── USERS & ADMINS SECTION CARDS ───────────────────────────── */
.users-section {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
}

.users-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.875rem;
}

.user-row .email { flex: 1; }

.invite-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.invite-row input,
.invite-row select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
}

.invite-row input {
  flex: 1;
}

.invite-row input:focus,
.invite-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* ── UTILITIES ──────────────────────────────────────────────── */
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

/* ── RESPONSIVE TWEAKS ──────────────────────────────────────── */
@media (max-width: 639px) {
  .main-content { padding: 16px 14px; }
  .form-card    { padding: 16px; }

  .stats-bar { gap: 8px; }

  .stat-summary-card { padding: 12px; gap: 8px; }
  .stat-summary-value { font-size: 1.2rem; }

  .table-card { border-radius: var(--radius); }

  td, th { padding: 9px 12px; font-size: 0.82rem; }

  .modal { padding: 18px 16px; }
  .modal.modal-wide { max-height: 90vh; }

  .toast { left: 14px; right: 14px; bottom: 16px; }

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

  .section-title { font-size: 1.1rem; }
}

/* ── CLIENT CARDS ───────────────────────────────────────────── */
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.client-card:hover { box-shadow: var(--shadow); }

.client-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.client-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.client-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
}

.client-card-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  align-items: center;
}

.client-card-meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.client-card-meta-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.client-card-meta-value.plain {
  font-family: var(--font);
  font-size: 0.85rem;
}

.client-card-footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* SSL / status badges */
.badge-ssl-active {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--success-bg);
  color: var(--success);
}

.badge-ssl-pending {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-env {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--success-bg);
  color: var(--success);
}

.badge-you {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent-light);
  color: #1565c0;
}

/* ── USER CARDS ─────────────────────────────────────────────── */
.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.user-card:hover { box-shadow: var(--shadow); }

.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.user-card-email {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-card-clients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-client-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 6px 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: border-color 0.12s;
}

.user-client-chip:hover { border-color: #d1d5db; }

.user-client-remove {
  padding: 1px 4px;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.user-client-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── ADMIN CARDS ────────────────────────────────────────────── */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.admin-card:hover { box-shadow: var(--shadow); }

.admin-card-info { flex: 1; min-width: 0; }

.admin-card-email {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-card-badges {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
  margin-left: 8px;
}

.admin-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── DNS INFO BLOCK ─────────────────────────────────────────── */
.dns-info-block {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.dns-info-block-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.dns-record-line {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  word-break: break-all;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
