/* ==========================================================================
   Scantron Nordic Design Language — Ping Monitor
   ========================================================================== */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap');

/* --- Design Tokens (Light Mode) --- */
:root {
  --surface-primary: #FAF9F7;
  --surface-secondary: #F2F0ED;
  --surface-tertiary: #E8E5E1;
  --text-primary: #5C5C5C;
  --text-heading: #666666;
  --text-secondary: #9A9590;
  --text-on-accent: #FFFFFF;
  --accent: #FF6600;
  --accent-hover: #E65C00;
  --accent-warm: #FEF5EF;
  --border: #DDD9D4;
  --success: #5A9E6F;
  --warning: #D4A017;
  --error: #C04040;
  --info: #6B8FA0;

  --shadow-color: 100, 90, 80;
  --shadow-l1: 0 1px 3px rgba(var(--shadow-color), 0.06);
  --shadow-l2: 0 4px 12px rgba(var(--shadow-color), 0.08);
  --shadow-l3: 0 8px 24px rgba(var(--shadow-color), 0.10);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 48px;

  --toggle-bg: var(--surface-tertiary);
  --toggle-knob: #fff;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --surface-primary: #1C1B19;
  --surface-secondary: #262523;
  --surface-tertiary: #302E2B;
  --text-primary: #D8D4CF;
  --text-heading: #E8E4DF;
  --text-secondary: #8A8580;
  --accent: #FF6600;
  --accent-hover: #FF7A1A;
  --accent-warm: #261400;
  --border: #3A3835;
  --success: #6BB880;
  --warning: #E6B830;
  --error: #D45555;
  --info: #7DA8B8;

  --shadow-color: 0, 0, 0;
  --shadow-l1: 0 1px 3px rgba(var(--shadow-color), 0.15);
  --shadow-l2: 0 4px 12px rgba(var(--shadow-color), 0.20);
  --shadow-l3: 0 8px 24px rgba(var(--shadow-color), 0.25);

  --toggle-bg: var(--accent);
  --toggle-knob: var(--surface-primary);
}

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

/* --- Base Typography --- */
body {
  font-family: 'Open Sans', Helvetica, Tahoma, Arial, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--surface-primary);
  min-height: 100vh;
  transition: background-color 200ms ease, color 200ms ease;
}

h1 {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.3px;
  color: var(--text-heading);
}

h2 {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.3;
  color: var(--text-heading);
}

h3 {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.4;
  color: var(--text-heading);
}

/* --- Section Labels (uppercase captions) --- */
.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Top Bar Navigation
   ========================================================================== */
.topbar {
  background: var(--surface-secondary);
  box-shadow: var(--shadow-l1);
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.topbar-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-heading);
  padding: 16px 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.topbar-nav {
  display: flex;
  gap: 0;
}

.topbar-link {
  padding: 16px 16px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: background 200ms ease;
  cursor: pointer;
}

.topbar-link:hover {
  background: var(--surface-tertiary);
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* --- Header Stats (pill badges) --- */
.header-stats {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 200ms ease;
  background: var(--surface-tertiary);
  color: var(--text-primary);
}

.stat-badge:hover {
  box-shadow: var(--shadow-l1);
}

.stat-badge.stat-active {
  background: var(--accent-warm);
  color: var(--accent);
}

.stat-badge .stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot-online { background: var(--success); }
.stat-dot-offline { background: var(--error); }
.stat-dot-unknown { background: var(--text-secondary); }
.stat-dot-total { background: var(--accent); }

/* --- Theme Toggle --- */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.theme-toggle-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--toggle-bg);
  border-radius: 11px;
  position: relative;
  transition: background-color 200ms ease;
}

.toggle-knob {
  width: 16px;
  height: 16px;
  background: var(--toggle-knob);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

[data-theme="dark"] .toggle-knob {
  transform: translateX(18px);
}

/* ==========================================================================
   Toolbar
   ========================================================================== */
.toolbar {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 200ms ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  line-height: 1.4;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--surface-secondary);
  box-shadow: var(--shadow-l1);
}

.btn:hover {
  background: var(--surface-tertiary);
  box-shadow: var(--shadow-l2);
  transform: translateY(-1px);
}

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

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 1px 4px rgba(255, 102, 0, 0.18);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(255, 102, 0, 0.28);
  background: var(--accent);
}

.btn-primary:active {
  filter: brightness(0.95);
}

.btn-danger {
  background: var(--error);
  color: var(--text-on-accent);
}

.btn-danger:hover {
  filter: brightness(1.1);
  background: var(--error);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  padding: 10px 4px;
}

.btn-ghost:hover {
  background: transparent;
  box-shadow: none;
  text-decoration: underline;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Form Inputs
   ========================================================================== */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  margin-bottom: var(--space-sm);
}

.form-input,
.form-select {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  outline: none;
  width: 100%;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.12);
}

.form-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239A9590' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Compact toolbar inputs */
.search-input {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  outline: none;
  width: 220px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.12);
}

.search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.filter-select {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 36px 8px 12px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239A9590' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 200ms ease;
}

.filter-select:focus {
  border-color: var(--accent);
}

/* ==========================================================================
   Device Grid & Cards
   ========================================================================== */
.device-grid {
  padding: var(--space-md) var(--space-lg);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.device-card {
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
  padding: 24px var(--space-lg);
  box-shadow: var(--shadow-l1);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  cursor: pointer;
  transition: box-shadow 200ms ease, transform 200ms ease;
  position: relative;
}

.device-card:hover {
  box-shadow: var(--shadow-l2);
  transform: translateY(-2px);
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
}

.device-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.device-flag {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border-radius: 2px;
  line-height: 0;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.device-flag svg {
  display: block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.device-flag:hover {
  transform: scale(1.08);
}

.device-flag:focus-visible {
  outline: 2px solid var(--accent, #0066cc);
  outline-offset: 2px;
}

.device-name {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-heading);
}

/* --- Status Tags (pill badges) --- */
.device-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px 5px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.device-status.online {
  background: color-mix(in srgb, var(--success) 12%, var(--surface-primary));
  color: var(--success);
}

.device-status.offline {
  background: color-mix(in srgb, var(--error) 12%, var(--surface-primary));
  color: var(--error);
  cursor: pointer;
}

.device-status.offline.blink {
  animation: pulse-offline 2s ease-in-out infinite;
}

@keyframes pulse-offline {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.device-status.unknown {
  background: var(--surface-tertiary);
  color: var(--text-secondary);
}

/* --- Device Info --- */
.device-info {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.device-ip {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.device-group {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Card attribute icons (router type + supplier) --- */
.device-attrs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.device-attr {
  display: inline-flex;
  align-items: center;
  color: var(--text-secondary);
  cursor: help;
}

.device-attr.router-wireless {
  color: #0066cc;
}

.device-attr.supplier-scantron {
  color: var(--accent, #ED5300);
}

.device-attr svg {
  display: block;
}

/* --- Filter dropdown panel --- */
.filter-dropdown {
  position: relative;
  display: inline-block;
}

.filter-trigger {
  position: relative;
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent, #ED5300);
  color: #fff;
  border-radius: 9px;
  line-height: 1;
}

.filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 280px;
  max-width: 340px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface-secondary, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-l3, 0 8px 24px rgba(0, 0, 0, 0.12));
}

.filter-panel.hidden {
  display: none;
}

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  font-weight: 600;
  font-size: 13px;
  color: var(--text-heading);
}

.filter-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.filter-section-toggle {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #ED5300);
  cursor: pointer;
  border-radius: 4px;
}

.filter-section-toggle:hover {
  background: color-mix(in srgb, var(--accent, #ED5300) 10%, transparent);
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.filter-option:hover {
  background: var(--surface-tertiary, rgba(0, 0, 0, 0.04));
}

.filter-option input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.filter-flag-dk,
.filter-flag-se {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.filter-flag-dk {
  background: linear-gradient(#C8102E, #C8102E);
  position: relative;
}

.filter-flag-dk::before,
.filter-flag-dk::after,
.filter-flag-se::before,
.filter-flag-se::after {
  content: '';
  position: absolute;
  background: #fff;
}

.filter-flag-dk::before { left: 5px; top: 0; bottom: 0; width: 2px; }
.filter-flag-dk::after { left: 0; right: 0; top: 5px; height: 2px; }

.filter-flag-se {
  background: #006AA7;
  position: relative;
}

.filter-flag-se::before { left: 5px; top: 0; bottom: 0; width: 2px; background: #FECC00; }
.filter-flag-se::after { left: 0; right: 0; top: 5px; height: 2px; background: #FECC00; }

/* --- Two-line card layout --- */
.device-line-1 {
  display: flex;
  align-items: center;
}

.device-line-2 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.device-line-2 .device-status {
  margin-left: auto;
}

.device-line-2 .uptime-badge-label {
  margin-left: -4px;
}

/* Uniform 16px height for line-2 icons; flag scales proportionally */
.device-line-2 .device-flag svg {
  height: 16px;
  width: auto;
}

.device-line-2 .device-attr svg {
  height: 16px;
  width: 16px;
}

/* --- Card right-click context menu --- */
.context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  padding: 6px;
  background: var(--surface-secondary, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-l3, 0 8px 24px rgba(0, 0, 0, 0.18));
  font-size: 13px;
  color: var(--text-primary);
  user-select: none;
}

.context-menu.hidden {
  display: none;
}

.context-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.context-divider {
  height: 1px;
  background: var(--border, rgba(0, 0, 0, 0.08));
  margin: 6px 0;
}

.context-row {
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-row.context-ip {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-weight: 600;
  color: var(--text-primary);
  justify-content: space-between;
}

.context-ip-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.context-copy {
  background: none;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
}

.context-copy:hover {
  background: var(--surface-tertiary, rgba(0, 0, 0, 0.04));
  color: var(--text-primary);
}

.context-row.context-online {
  color: var(--success);
  font-weight: 600;
}

.context-row.context-offline {
  color: var(--error);
  font-weight: 600;
}

.context-action {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 4px;
}

.context-action:hover {
  background: var(--surface-tertiary, rgba(0, 0, 0, 0.06));
}

.context-action.context-action-danger {
  color: var(--error);
}

.context-action.context-action-danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.device-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.device-duration {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.device-duration.online {
  color: var(--success);
}

.device-duration.offline {
  color: var(--error);
}

/* --- Uptime Badge on Card --- */
.device-uptime {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.uptime-badge {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.uptime-badge-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.uptime-good {
  background: color-mix(in srgb, var(--success) 12%, var(--surface-primary));
  color: var(--success);
}

.uptime-warn {
  background: color-mix(in srgb, var(--warning) 12%, var(--surface-primary));
  color: var(--warning);
}

.uptime-bad {
  background: color-mix(in srgb, var(--error) 12%, var(--surface-primary));
  color: var(--error);
}

.uptime-insufficient {
  background: var(--surface-tertiary);
  color: var(--text-secondary);
}

/* --- Device Actions --- */
.device-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 25, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, visibility 250ms ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--surface-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-l3);
  padding: var(--space-xl);
  width: 90%;
  max-width: 480px;
  position: relative;
  transform: translateY(16px) scale(0.97);
  transition: transform 250ms ease;
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-dialog-wide {
  max-width: 640px;
}

.modal-dialog h2 {
  font-size: 20px;
  margin-bottom: var(--space-md);
}

.modal-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 200ms ease;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-heading);
}

/* Modal form layout */
.modal-form-group {
  margin-bottom: var(--space-md);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: 24px;
  justify-content: flex-end;
}

.export-options {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* Import result feedback */
#import-result {
  margin-top: var(--space-md);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

#import-result.success {
  background: color-mix(in srgb, var(--success) 6%, var(--surface-secondary));
  color: var(--success);
}

#import-result.error {
  background: color-mix(in srgb, var(--error) 6%, var(--surface-secondary));
  color: var(--error);
}

/* ==========================================================================
   Device Detail Modal
   ========================================================================== */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.detail-header h2 {
  margin-bottom: var(--space-xs);
}

.detail-ip {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.detail-uptime-section {
  margin-bottom: 24px;
}

.detail-uptime-section h3,
.detail-outage-section h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.uptime-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.uptime-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.uptime-row-insufficient .uptime-label {
  color: var(--text-secondary);
  opacity: 0.6;
}

.uptime-label {
  font-size: 14px;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: right;
}

.uptime-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  flex: 1;
  background: var(--surface-tertiary);
}

.uptime-bar-up {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.uptime-bar-down {
  height: 100%;
  background: var(--error);
  transition: width 0.3s ease;
}

.uptime-bar-grey {
  height: 100%;
  background: var(--surface-tertiary);
}

.uptime-pct {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
}

.uptime-pct.uptime-good { color: var(--success); }
.uptime-pct.uptime-warn { color: var(--warning); }
.uptime-pct.uptime-bad { color: var(--error); }
.uptime-pct.uptime-insufficient { color: var(--text-secondary); opacity: 0.6; }

/* --- Outage History --- */
.detail-outage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.detail-outage-header h3 {
  margin-bottom: 0;
}

.outage-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 300px;
  overflow-y: auto;
}

.outage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--border);
}

.outage-times {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.outage-start, .outage-end {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.outage-arrow {
  color: var(--text-secondary);
}

.outage-ongoing {
  color: var(--error);
  font-weight: 600;
}

.outage-duration {
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  white-space: nowrap;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  justify-content: center;
}

.pagination .btn-sm {
  min-width: 32px;
  text-align: center;
}

/* ==========================================================================
   Toast Notifications (Nordic: NO colored left border)
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 80vh;
  overflow-y: auto;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  box-shadow: var(--shadow-l2);
  font-size: 14px;
  min-width: 300px;
  max-width: 420px;
  color: var(--text-primary);
  animation: toast-slide-in 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  transition: box-shadow 200ms ease;
}

.toast:hover {
  box-shadow: var(--shadow-l3);
}

.toast-online {
  background: color-mix(in srgb, var(--success) 6%, var(--surface-secondary));
}

.toast-offline {
  background: color-mix(in srgb, var(--error) 6%, var(--surface-secondary));
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  width: 18px;
  height: 18px;
}

.toast-online .toast-icon {
  color: var(--success);
}

.toast-offline .toast-icon {
  color: var(--error);
}

.toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.toast-body strong {
  font-weight: 600;
  color: var(--text-heading);
  font-size: 14px;
}

.toast-detail {
  color: var(--text-secondary);
  font-size: 13px;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 200ms ease;
  flex-shrink: 0;
}

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

.toast-fade {
  opacity: 0;
  transition: opacity 300ms ease;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 300;
  margin-bottom: var(--space-sm);
  color: var(--text-heading);
}

.empty-state p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden {
  display: none !important;
}

/* Lucide icon sizing defaults */
.lucide, [data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}
