/* ===========================================================
   MikroNet-TR069 - Design System v2.0
   =========================================================== */

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

/* ─── Theme Variables ───────────────────── */

:root {
  --bg-canvas: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-elevated: rgba(255, 255, 255, 0.85);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-default: rgba(148, 163, 184, 0.3);

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-subtle: rgba(37, 99, 235, 0.08);

  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);

  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-blur: saturate(180%) blur(16px);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  --navbar-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-canvas: #0a0e1a;
    --bg-surface: #111827;
    --bg-elevated: rgba(17, 24, 39, 0.85);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --border-subtle: rgba(148, 163, 184, 0.1);
    --border-default: rgba(148, 163, 184, 0.16);

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.1);

    --glass-bg: rgba(17, 24, 39, 0.65);
    --glass-border: rgba(148, 163, 184, 0.08);
    --glass-blur: saturate(120%) blur(24px);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -4px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.2);
  }
}

/* ─── Base ──────────────────────────────── */

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-subtle), transparent),
    radial-gradient(ellipse 50% 80% at 20% 80%, rgba(16, 185, 129, 0.04), transparent);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.reveal-link {
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--accent);
  margin-left: var(--space-2);
}

.reveal-link:hover {
  text-decoration: underline;
}

/* ─── Login Page ────────────────────────── */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--navbar-height) - 48px);
  padding: var(--space-6);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-xl);
  animation: scaleIn 300ms ease;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.login-logo img {
  width: auto;
  height: 48px;
  display: block;
}

.login-logo h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.login-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.login-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-field input {
  padding: 10px var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  outline: none;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.login-error {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: 0.82rem;
  font-weight: 500;
  display: none;
  animation: fadeUp 200ms ease;
}

.login-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  margin-top: var(--space-2);
}  

.login-btn:disabled {
  opacity: 0.7;
  pointer-events: none;
}

.mono { font-family: var(--font-mono); font-size: 0.9em; letter-spacing: -0.01em; }

/* ─── Navbar ────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.navbar-brand img {
  height: 28px;
  width: auto;
  display: block;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-link {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-subtle);
  text-decoration: none;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}

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

.btn-icon svg { width: 18px; height: 18px; }

/* ─── Main Container ────────────────────── */

#app {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-6);
  min-height: calc(100vh - var(--navbar-height));
}

/* ─── Dashboard ─────────────────────────── */

.dashboard {
  animation: fadeUp 400ms ease;
}

.dashboard-hero {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

/* Stats */

.stat-card {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 80% 20%, var(--accent-subtle), transparent 60%);
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-default);
}

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

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon-total {
  background: var(--accent-subtle);
  color: var(--accent);
}

.stat-icon-online {
  background: var(--success-subtle);
  color: var(--success);
}

.stat-icon-offline {
  background: var(--danger-subtle);
  color: var(--danger);
}

.stat-body {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

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

.stat-card.stat-online .stat-value { color: var(--success); }
.stat-card.stat-offline .stat-value { color: var(--danger); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--space-1);
}

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Search & Filters */

.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.search-bar {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 480px;
}

.search-bar input {
  width: 100%;
  padding: 10px var(--space-4) 10px 42px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  transition: all var(--transition-normal);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--bg-surface);
}

.search-bar input::placeholder {
  color: var(--text-tertiary);
}

.search-bar svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-bar .search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--border-subtle);
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.search-bar .search-clear.visible {
  display: flex;
}

.search-bar .search-clear:hover {
  background: var(--border-default);
  color: var(--text-primary);
}

.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-default);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  white-space: nowrap;
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-chip.active:hover {
  background: var(--accent-hover);
}

.filter-chip.chip-success.active {
  background: var(--success);
  border-color: var(--success);
}

.filter-chip.chip-danger.active {
  background: var(--danger);
  border-color: var(--danger);
}

.results-count {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-left: auto;
  white-space: nowrap;
}

/* Device List */

.device-list {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-header {
  display: grid;
  grid-template-columns: 50px 1fr 140px minmax(140px,1fr) 130px;
  padding: 10px var(--space-4);
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border-default);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.list-header span {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.list-header .sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.list-header .sortable:hover {
  color: var(--accent);
}

.list-header .sortable .sort-arrow {
  opacity: 0;
  font-size: 0.65rem;
}

.list-header .sortable:hover .sort-arrow,
.list-header .sortable.sorted .sort-arrow {
  opacity: 1;
}

.list-header .sortable.sorted {
  color: var(--accent);
}

.list-row {
  display: grid;
  grid-template-columns: 50px 1fr 140px minmax(140px,1fr) 130px;
  padding: 0 var(--space-4);
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: fadeUp 300ms ease backwards;
  gap: var(--space-2);
}

.list-row:last-child {
  border-bottom: none;
}

.list-row:hover {
  background: var(--accent-subtle);
}

.list-row:active {
  background: var(--border-subtle);
}

.list-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.router-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.router-icon.online {
  color: var(--success);
  filter: drop-shadow(0 0 4px var(--success));
}

.router-icon.offline {
  color: var(--danger);
}

.status-tag {
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 3px;
  padding: 0 4px;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.status-tag.online {
  color: var(--success);
  background: var(--success-subtle);
}

.status-tag.offline {
  color: var(--danger);
  background: var(--danger-subtle);
}

.list-model {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.list-model-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.list-model-serial {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-cell {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-cell.mono {
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.list-wifi {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.list-wifi span {
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.list-wifi .wifi-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.list-last {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.list-last svg {
  width: 13px;
  height: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.list-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.list-status-badge.online {
  background: var(--success-subtle);
  color: var(--success);
}

.list-status-badge.offline {
  background: var(--danger-subtle);
  color: var(--danger);
}

/* responsive list -> compact */

@media (max-width: 1024px) {
  .list-header,
  .list-row {
    grid-template-columns: 50px 1fr 120px;
  }
  .list-header .h-wifi,
  .list-header .h-ip {
    display: none;
  }
  .list-row .list-cell.mono,
  .list-row .list-wifi {
    display: none;
  }
}

@media (max-width: 640px) {
  .list-header,
  .list-row {
    grid-template-columns: 50px 1fr;
    padding: 0 var(--space-3);
    gap: var(--space-1);
  }
  .list-header .h-wifi,
  .list-header .h-ip,
  .list-header .h-last {
    display: none;
  }
  .list-row .list-cell.mono,
  .list-row .list-wifi,
  .list-row .list-last {
    display: none;
  }
  }
  .list-row {
    min-height: 42px;
  }
}

/* Status Badge */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.online {
  background: var(--success-subtle);
  color: var(--success);
}

.status-badge.online::before {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.status-badge.offline {
  background: var(--danger-subtle);
  color: var(--danger);
}

.status-badge.offline::before {
  background: var(--danger);
}

/* ─── Device Detail ─────────────────────── */

.detail-header {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

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

.detail-title {
  flex: 1;
  min-width: 200px;
}

.detail-title h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.detail-title .serial {
  display: block;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.detail-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Section Cards */

.device-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.section-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
}

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.section-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-body {
  padding: var(--space-5);
}

/* Info Grid */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

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

.info-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-all;
}

/* ─── Tables ────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  border-bottom: 2px solid var(--border-default);
}

.data-table th {
  text-align: left;
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

.data-table tbody tr:hover {
  background: var(--accent-subtle);
}

/* ─── Badges ────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-muted { background: var(--border-subtle); color: var(--text-tertiary); }

/* ─── Buttons ───────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

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

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

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

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-warning:hover {
  background: #d97706;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
  border-radius: 6px;
}

/* ─── Modal ─────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 200ms ease;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: scaleIn 250ms ease;
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-close:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.modal-body {
  padding: var(--space-5);
}

.modal-body p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.modal-body .text-danger {
  color: var(--danger);
  font-weight: 500;
  margin-top: var(--space-3);
}

.modal-body .text-muted {
  color: var(--text-tertiary);
  font-size: 0.82rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

/* Form groups in modals */

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

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

.form-check label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Toast Notifications ──────────────── */

#toasts {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all var(--transition-normal);
  max-width: 380px;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

/* ─── Loading ───────────────────────────── */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  gap: var(--space-4);
  color: var(--text-tertiary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Skeleton loader */

.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.skeleton-line {
  height: 14px;
  background: var(--border-subtle);
  border-radius: 4px;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line:nth-child(odd) {
  width: 70%;
}

.skeleton-line:nth-child(even) {
  width: 90%;
}

/* ─── Empty / Error States ─────────────── */

.empty-state,
.error-state,
.section-empty,
.section-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  text-align: center;
  gap: var(--space-2);
  color: var(--text-tertiary);
}

.empty-state h3,
.error-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p,
.error-state p {
  font-size: 0.85rem;
}

.error-state button {
  margin-top: var(--space-3);
}

.section-empty,
.section-error {
  padding: var(--space-6);
  font-size: 0.85rem;
}

/* ─── Animations ────────────────────────── */

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

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

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

@keyframes shimmer {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ────────────────────────── */

@media (max-width: 768px) {
  #app {
    padding: var(--space-4);
  }

  .dashboard-hero {
    flex-direction: column;
  }

  .stat-card {
    min-width: 0;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .dashboard-toolbar {
    flex-direction: column;
  }

  .search-bar {
    max-width: 100%;
    min-width: 0;
  }

  .filter-chips {
    width: 100%;
  }

  .results-count {
    margin-left: 0;
    width: 100%;
    text-align: right;
  }

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

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

  .detail-actions {
    justify-content: stretch;
  }

  .detail-actions .btn {
    flex: 1;
  }

  .modal {
    margin: var(--space-3);
    max-height: 90vh;
    overflow-y: auto;
  }

  #toasts {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 0 var(--space-4);
  }

  .navbar-brand {
    font-size: 0.95rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }
}
