/* ═══════════════════════════════════════════════════════════════════
   NetMon Dashboard — Design System
   Audience: IT Support Staff (B2B, data-dense, professional)
   Style: Dark industrial, high contrast, data-forward
   Color: Charcoal base + Amber accent (NOT default blue/purple)
═══════════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Base */
  --bg-0: #0d0e11;
  --bg-1: #13151a;
  --bg-2: #1a1d24;
  --bg-3: #22262f;
  --bg-4: #2a2f3b;

  /* Text */
  --text-primary:   #e8eaf0;
  --text-secondary: #8b92a8;
  --text-muted:     #4a5068;

  /* Accent - Amber (operational, alert-friendly) */
  --amber-bright: #f5a623;
  --amber-dim:    #7a5010;
  --amber-glow:   rgba(245, 166, 35, 0.12);

  /* Status Colors */
  --ok:       #22c55e;
  --ok-dim:   rgba(34, 197, 94, 0.12);
  --ok-text:  #4ade80;

  --warn:     #f59e0b;
  --warn-dim: rgba(245, 158, 11, 0.12);
  --warn-text:#fbbf24;

  --danger:   #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --danger-text: #f87171;

  --info:     #3b82f6;
  --info-dim: rgba(59, 130, 246, 0.12);
  --info-text: #60a5fa;

  --muted:    #4a5068;
  --muted-dim: rgba(74, 80, 104, 0.12);

  /* Border */
  --border: rgba(255,255,255,0.06);
  --border-active: rgba(255,255,255,0.14);

  /* Typography */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Spacing (8pt grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, select { font: inherit; }

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-6);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--sp-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.logo-icon {
  font-size: 1.4rem;
  color: var(--amber-bright);
  line-height: 1;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-left: 1px solid var(--border-active);
  padding-left: var(--sp-2);
  margin-left: var(--sp-1);
}

.clock {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.refresh-info {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-active);
  background: var(--bg-3);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.btn-icon:hover { background: var(--bg-4); color: var(--text-primary); }
.btn-icon.spinning { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Summary Bar ─────────────────────────────────────────────────── */
.summary-bar {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.summary-card {
  flex: 1;
  min-width: 110px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
  transition: border-color 0.2s;
}
.summary-card:hover { border-color: var(--border-active); }

.sum-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: var(--sp-1);
}

.sum-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.highlight-ok    { border-color: rgba(34,197,94,0.25);   }
.highlight-ok .sum-value    { color: var(--ok-text); }
.highlight-warn  { border-color: rgba(245,158,11,0.25);  }
.highlight-warn .sum-value  { color: var(--warn-text); }
.highlight-info  { border-color: rgba(59,130,246,0.25);  }
.highlight-info .sum-value  { color: var(--info-text); }
.highlight-muted { border-color: rgba(74,80,104,0.25);   }
.highlight-muted .sum-value { color: var(--muted); }

/* ── Toolbar ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.view-btn {
  padding: var(--sp-1) var(--sp-2);
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-btn:hover {
  background: var(--bg-3);
  color: var(--text-secondary);
}

.view-btn.active {
  background: var(--bg-4);
  color: var(--text-primary);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) calc(var(--sp-3) + 1.4rem);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--amber-bright); }
.search-input::placeholder { color: var(--text-muted); }

.filter-tabs {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.filter-tab {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}
.filter-tab:hover { border-color: var(--border-active); color: var(--text-primary); }
.filter-tab.active {
  background: var(--amber-glow);
  border-color: var(--amber-bright);
  color: var(--amber-bright);
}

/* ── Branch Grid & List View ─────────────────────────────────────── */
.branch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
  padding: 0 var(--sp-6) var(--sp-7);
}

.branch-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Branch Card */
.branch-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.branch-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  transition: opacity 0.2s;
}

.branch-grid.list-view .branch-card {
  flex-direction: row;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  gap: var(--sp-4);
}

.branch-grid.list-view .branch-card::before {
  top: 0; bottom: 0; left: 0; right: auto;
  width: 4px; height: 100%;
  border-radius: var(--r-md) 0 0 var(--r-md);
}

.branch-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  border-color: var(--border-active);
}

/* Status colors */
.branch-card[data-status="NORMAL"]       { --status-color: var(--ok); }
.branch-card[data-status="ISP_ISSUE"]    { --status-color: var(--warn); }
.branch-card[data-status="SERVER_ISSUE"] { --status-color: var(--info); }
.branch-card[data-status="UNKNOWN"]      { --status-color: var(--warn); }
.branch-card[data-status="OFFLINE"]      { --status-color: var(--muted); }

.branch-card::before { background: var(--status-color, var(--muted)); }

.branch-card[data-status="NORMAL"]       { border-color: rgba(34,197,94,0.2); }
.branch-card[data-status="ISP_ISSUE"]    { border-color: rgba(245,158,11,0.3); }
.branch-card[data-status="SERVER_ISSUE"] { border-color: rgba(59,130,246,0.3); }
.branch-card[data-status="OFFLINE"]      { border-color: rgba(74,80,104,0.3); opacity: 0.7; }

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-3);
}

.branch-grid.list-view .card-header {
  margin-bottom: 0;
  flex: 1.5;
  min-width: 200px;
  align-items: center;
}

.branch-grid.list-view .card-title-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.card-branch-id {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-1);
}

.branch-grid.list-view .card-branch-id {
  margin-bottom: 0;
}

.card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.card-location {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.branch-grid.list-view .card-location {
  margin-top: 0;
}

.status-badge {
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.NORMAL       { background: var(--ok-dim); color: var(--ok-text); }
.status-badge.ISP_ISSUE    { background: var(--warn-dim); color: var(--warn-text); }
.status-badge.SERVER_ISSUE { background: var(--info-dim); color: var(--info-text); }
.status-badge.UNKNOWN      { background: var(--warn-dim); color: var(--warn-text); }
.status-badge.OFFLINE      { background: var(--muted-dim); color: var(--muted); }

/* ISP Badge */
.isp-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px var(--sp-2);
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  margin-top: var(--sp-2);
}

.branch-grid.list-view .isp-badge {
  margin-top: 0;
}

.isp-badge.LTE    { border-color: rgba(245,166,35,0.4); color: var(--amber-bright); }
.isp-badge.FIBER  { border-color: rgba(34,197,94,0.4);  color: var(--ok-text); }
.isp-badge.COPPER { border-color: rgba(59,130,246,0.4); color: var(--info-text); }

/* Metric Bars */
.card-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}

.branch-grid.list-view .card-metrics {
  flex-direction: row;
  flex: 3;
  margin-top: 0;
  border-top: none;
  padding-top: 0;
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
  gap: var(--sp-4);
  align-items: center;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.branch-grid.list-view .metric-row {
  flex: 1;
}

.metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  width: 65px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.branch-grid.list-view .metric-label {
  display: none;
}

.metric-bar-track {
  flex: 1;
  height: 4px;
  background: var(--bg-4);
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  width: 45px;
  text-align: right;
  flex-shrink: 0;
}

/* Color by severity */
.bar-ok   { background: var(--ok); }
.bar-warn { background: var(--warn); }
.bar-crit { background: var(--danger); }
.bar-muted{ background: var(--muted); }

/* Card footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-3);
}

.branch-grid.list-view .card-footer {
  margin-top: 0;
  flex: 0.5;
  flex-direction: column;
  align-items: flex-end;
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
}

.card-timestamp {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.card-ip {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Loading / Empty States ──────────────────────────────────────── */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
  color: var(--text-muted);
  gap: var(--sp-4);
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-4);
  border-top-color: var(--amber-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: fade-in 0.2s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-active);
  border-radius: var(--r-md);
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  overflow-y: auto;
  position: relative;
  animation: slide-up 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-4) transparent;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
  position: sticky;
  top: var(--sp-2);
  float: right;
  margin: var(--sp-2) var(--sp-2) 0 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-4);
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}
.modal-close:hover { background: var(--danger-dim); color: var(--danger-text); }

.modal-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.modal-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-badge.NORMAL       { background: var(--ok-dim); }
.modal-badge.ISP_ISSUE    { background: var(--warn-dim); }
.modal-badge.SERVER_ISSUE { background: var(--info-dim); }
.modal-badge.OFFLINE      { background: var(--muted-dim); }

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.modal-body {
  padding: var(--sp-3) var(--sp-5) var(--sp-5);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.metric-section {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
}

.metric-section:nth-of-type(5),
.metric-section:nth-of-type(6),
.metric-section:nth-of-type(7) {
  grid-column: 1 / -1;
}

.metric-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.05em;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-2);
}

.metric-cell {
  background: var(--bg-3);
  border-radius: var(--r-sm);
  padding: var(--sp-2);
}

.metric-cell-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.metric-cell-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
}

.metric-cell-value.ok   { color: var(--ok-text); }
.metric-cell-value.warn { color: var(--warn-text); }
.metric-cell-value.crit { color: var(--danger-text); }
.metric-cell-value.muted{ color: var(--muted); }

/* Chart */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
}

.chart-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  padding: 3px var(--sp-2);
  font-size: 0.7rem;
  outline: none;
}
.chart-select:focus { border-color: var(--amber-bright); }

#latency-chart,
#traffic-chart {
  width: 100%;
  height: 96px;
}

/* Edit Form */
.edit-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: var(--sp-2);
}

.edit-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-width: 0;
  padding: 7px var(--sp-2);
  color: var(--text-primary);
  outline: none;
  font-size: 0.78rem;
  transition: border-color 0.2s;
}
.edit-input:focus { border-color: var(--amber-bright); }
.edit-input::placeholder { color: var(--text-muted); }
.edit-input option { background: var(--bg-3); }

.btn-save {
  background: var(--amber-glow);
  border: 1px solid var(--amber-bright);
  color: var(--amber-bright);
  padding: 7px var(--sp-3);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 0.78rem;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-save:hover { background: rgba(245,166,35,0.2); }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* ── Traffic Badge on Card ───────────────────────────────────────── */
.card-traffic {
  display: flex;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-3);
}

.branch-grid.list-view .card-traffic {
  flex: 1.5;
  margin-top: 0;
  border-top: none;
  padding-top: 0;
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
  gap: var(--sp-2);
}

.traffic-chip {
  flex: 1;
  background: var(--bg-3);
  border-radius: var(--r-sm);
  padding: var(--sp-1) var(--sp-2);
  text-align: center;
}

.traffic-chip-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 2px;
}

.branch-grid.list-view .traffic-chip-label {
  display: none;
}

.traffic-chip-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.traffic-chip-value.recv { color: var(--ok-text); }
.traffic-chip-value.sent { color: var(--amber-bright); }
.traffic-chip-value.total { color: var(--text-primary); }

.no-traffic-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-2);
  font-style: italic;
}

/* ── Traffic Bar Chart (Daily) ───────────────────────────────────── */
#traffic-chart { width: 100%; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: var(--sp-3) var(--sp-4); }
  .summary-bar { padding: var(--sp-3) var(--sp-4); }
  .toolbar { padding: var(--sp-3) var(--sp-4); }
  .branch-grid { padding: 0 var(--sp-4) var(--sp-7); }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .clock { display: none; }
}

/* Compact dashboard overrides */
body.theme-light {
  --bg-0: #f4f6f8;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #eef2f6;
  --bg-4: #d9e0e8;
  --text-primary: #17202a;
  --text-secondary: #4b5563;
  --text-muted: #7b8491;
  --amber-bright: #b96b00;
  --amber-glow: rgba(185, 107, 0, 0.11);
  --ok-text: #148044;
  --warn-text: #a45f00;
  --danger-text: #c73737;
  --info-text: #2563b8;
  --muted: #8b95a1;
  --border: rgba(23, 32, 42, 0.09);
  --border-active: rgba(23, 32, 42, 0.18);
}

.summary-bar {
  padding-top: var(--sp-3);
  padding-bottom: var(--sp-3);
}

.summary-card {
  min-width: 86px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
}

.sum-value {
  font-size: 1.45rem;
}

.sum-label {
  font-size: 0.66rem;
}

.toolbar {
  padding-top: var(--sp-3);
  padding-bottom: var(--sp-3);
}

.branch-grid.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}

.branch-card.compact-card {
  min-height: 116px;
  padding: var(--sp-3);
  border-radius: var(--r-sm);
}

.compact-card .card-header {
  margin-bottom: var(--sp-3);
}

.compact-header {
  gap: var(--sp-3);
}

.compact-card .card-name {
  font-size: 0.92rem;
  line-height: 1.2;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  display: flex;
  gap: var(--sp-2);
  margin-top: 3px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  white-space: nowrap;
}

.card-meta span:not(:last-child)::after {
  content: "·";
  margin-left: var(--sp-2);
  color: var(--text-muted);
}

.compact-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: auto;
}

.stat-cell {
  min-width: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 7px;
}

.stat-label {
  display: block;
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 0.57rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value.ok { color: var(--ok-text); }
.stat-value.warn { color: var(--warn-text); }
.stat-value.crit { color: var(--danger-text); }
.stat-value.muted { color: var(--muted); }

.branch-grid.list-view {
  gap: 6px;
}

.branch-grid.list-view .branch-card.compact-card {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 12px;
}

.branch-grid.list-view .compact-card .card-header {
  margin: 0;
  min-width: 0;
}

.branch-grid.list-view .compact-card .card-title-group {
  min-width: 0;
  display: block;
}

.branch-grid.list-view .compact-card .card-name {
  max-width: none;
}

.branch-grid.list-view .compact-stats {
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  margin: 0;
}

.branch-grid.list-view .stat-cell {
  padding: 4px 6px;
  background: transparent;
}

.branch-grid.list-view .status-badge {
  justify-self: start;
}

body.theme-light .branch-card:hover {
  box-shadow: 0 5px 18px rgba(17, 24, 39, 0.08);
}

body.theme-light .modal-overlay {
  background: rgba(15, 23, 42, 0.28);
}

@media (max-width: 900px) {
  .modal {
    max-width: 94vw;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .metric-section:nth-of-type(5),
  .metric-section:nth-of-type(6),
  .metric-section:nth-of-type(7) {
    grid-column: auto;
  }

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

  .btn-save {
    justify-self: start;
  }

  .branch-grid.list-view .branch-card.compact-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .branch-grid.list-view .compact-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .logo-sub,
  .refresh-info {
    display: none;
  }

  .compact-stats,
  .branch-grid.list-view .compact-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-meta {
    flex-wrap: wrap;
  }

  .modal {
    max-width: 100vw;
    max-height: 94vh;
  }

  .modal-header {
    padding: var(--sp-3);
  }

  .modal-body {
    padding: var(--sp-3);
  }

  .metric-grid,
  .edit-form {
    grid-template-columns: 1fr;
  }
}
