/* ============================================================
   DEADFRAME v4 — Design System
   Soft dark: muted palette, minimal glow, data-forward
   ============================================================ */

/* ── 1. CUSTOM PROPERTIES ───────────────────────────────── */
:root {
  /* Backgrounds — warmer, less blue-tinted */
  --bg:           #0d0d10;
  --surface:      #131318;
  --elevated:     #18181f;
  --overlay:      rgba(13, 13, 16, 0.92);

  /* Borders — neutral gray, not blue-purple */
  --border:        #252529;
  --border-dim:    #1d1d21;
  --border-bright: #38383e;

  /* Brand accents — each has ONE semantic role */
  --accent:        #c4602c;   /* terracotta: brand, primary actions, CTAs */
  --accent-dim:    rgba(196, 96, 44, 0.10);
  --accent-glow:   rgba(196, 96, 44, 0.22);
  --accent-glow-lg:rgba(196, 96, 44, 0.08);

  --cyan:          #6eafd4;   /* slate blue: data values, links, interactive */
  --cyan-dim:      rgba(110, 175, 212, 0.10);
  --cyan-glow:     rgba(110, 175, 212, 0.18);

  --purple:        #7c6ab8;   /* muted purple: decorative, secondary badges */
  --purple-dim:    rgba(124, 106, 184, 0.10);
  --purple-glow:   rgba(124, 106, 184, 0.18);

  /* Status colors — semantic only, never decorative */
  --up:            #22c55e;
  --up-glow:       rgba(34, 197, 94, 0.15);
  --down:          #ef4444;
  --down-glow:     rgba(239, 68, 68, 0.18);
  --warn:          #f59e0b;
  --warn-glow:     rgba(245, 158, 11, 0.15);
  --info:          #6eafd4;

  /* Text — slightly warmer, less blue-purple tint */
  --text:          #e4e4ee;
  --text-dim:      #b0b0c8;
  --muted:         #6e6e98;
  --dim:           #46465e;

  /* Sidebar */
  --sidebar-w:     220px;
  --sidebar-w-col: 56px;
  --topbar-h:      48px;

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

  /* Transitions */
  --t-fast: 0.12s ease;
  --t-med:  0.2s ease;
  --t-slow: 0.3s ease;
}

/* ── 2. BASE RESET ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

[x-cloak] { display: none !important; }

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

/* ── 3. TYPOGRAPHY ──────────────────────────────────────── */
.font-orbitron   { font-family: 'Orbitron', sans-serif; }
.font-mono       { font-family: 'Share Tech Mono', monospace; }
.font-inter      { font-family: 'Inter', sans-serif; }

/* Sizes */
.text-xs   { font-size: 13px; line-height: 1.4; }
.text-sm   { font-size: 13px; line-height: 1.4; }
.text-base { font-size: 15px; line-height: 1.5; }
.text-lg   { font-size: 18px; line-height: 1.4; }
.text-xl   { font-size: 24px; line-height: 1.3; }
.text-2xl  { font-size: 32px; line-height: 1.2; }

/* Colors */
.text-accent  { color: var(--accent); }
.text-cyan    { color: var(--cyan); }
.text-purple  { color: var(--purple); }
.text-muted   { color: var(--muted); }
.text-dim     { color: var(--dim); }
.text-up      { color: var(--up); }
.text-down    { color: var(--down); }
.text-warn    { color: var(--warn); }
.text-info    { color: var(--info); }

/* Subtle glows — soft dark theme, used sparingly */
.glow-accent { text-shadow: 0 0 10px var(--accent-glow); }
.glow-cyan   { text-shadow: 0 0 8px var(--cyan-glow); }
.glow-up     { text-shadow: 0 0 6px var(--up-glow); }
.glow-down   { text-shadow: 0 0 6px var(--down-glow); }

/* Label style (widget headers, table headers) */
.label {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.label-mono {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* NOC stat label + value pair — use these in new widget code */
.stat-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.stat-val {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.meta-text {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ── 4. LAYOUT ──────────────────────────────────────────── */
.df-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.df-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px 0 0;
  z-index: 100;
  gap: 12px;
}

.df-topbar-brand {
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 8px;
  width: var(--sidebar-w);
  padding: 0 16px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.df-topbar-brand svg { width: 18px; height: 18px; stroke: var(--accent); flex-shrink: 0; }

.df-topbar-center { flex: 1; display: flex; align-items: center; gap: 8px; }

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

/* Sidebar */
.df-sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  transition: width var(--t-med);
}

.df-sidebar.collapsed { width: var(--sidebar-w-col); }

/* Sidebar section dividers */
.df-sidebar-section {
  padding: 20px 12px 6px;
}

.df-sidebar-section-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
}

.df-sidebar.collapsed .df-sidebar-section-label { opacity: 0; }

.df-sidebar-divider {
  height: 1px;
  background: var(--border-dim);
  margin: 4px 12px;
}

/* Sidebar nav items */
.df-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 8px;
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: color var(--t-fast), background var(--t-fast);
  position: relative;
}

.df-nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.df-nav-item.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  text-shadow: 0 0 6px var(--cyan-glow);
}

.df-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 5px var(--accent-glow);
}

.df-nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  transition: color var(--t-fast);
}

.df-nav-item span { overflow: hidden; }
.df-sidebar.collapsed .df-nav-item span { display: none; }
.df-sidebar.collapsed .df-nav-item { justify-content: center; padding: 8px; margin: 1px 4px; }

/* Main content */
.df-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  transition: margin-left var(--t-med);
  min-height: calc(100vh - var(--topbar-h));
}

.df-main.sidebar-collapsed { margin-left: var(--sidebar-w-col); }

.df-page {
  padding: 24px;
  max-width: 1600px;
}

.df-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.df-page-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-transform: uppercase;
}

.df-page-title .accent-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent-glow);
  margin-right: 10px;
  margin-bottom: 2px;
}

.df-page-actions { display: flex; align-items: center; gap: 8px; }

/* ── 5. TABS ────────────────────────────────────────────── */
.df-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding-bottom: 0;
}

.df-tab {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 16px 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  position: relative;
  transition: color var(--t-fast);
  white-space: nowrap;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

.df-tab:hover { color: var(--text-dim); }

.df-tab.active {
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan-glow);
}

.df-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent-glow);
}

.df-tab-content { display: none; }
.df-tab-content.active { display: block; }

/* ── 6. CARDS ───────────────────────────────────────────── */
.df-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}

/* Inset top highlight */
.df-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  pointer-events: none;
}

.df-card:hover { border-color: var(--border-bright); }

/* Featured card — corner notch + accent */
.df-card.featured {
  border-color: rgba(196,96,44,0.2);
}
.df-card.featured::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 16px 16px 0;
  border-color: transparent var(--accent) transparent transparent;
  pointer-events: none;
}

.df-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-dim);
  gap: 8px;
}

.df-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.df-card-title svg { width: 14px; height: 14px; stroke: currentColor; }

.df-card-body { padding: 16px; }
.df-card-body.p-0 { padding: 0; }

/* Hover interactive card */
.df-card.interactive {
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.df-card.interactive:hover {
  border-color: var(--border-bright);
  box-shadow: -3px 0 0 0 var(--accent), 0 0 10px var(--accent-glow-lg);
}

/* ── 7. STATUS INDICATORS ───────────────────────────────── */
.df-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.df-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.df-dot.up     { background: var(--up); box-shadow: 0 0 6px var(--up-glow); }
.df-dot.down   { background: var(--down); box-shadow: 0 0 5px var(--down-glow); animation: pulse-down 2s ease-in-out infinite; }
.df-dot.warn   { background: var(--warn); box-shadow: 0 0 6px var(--warn-glow); }
.df-dot.unknown { background: var(--dim); }

@keyframes pulse-down {
  0%, 100% { box-shadow: 0 0 6px var(--down-glow); }
  50%       { box-shadow: 0 0 8px var(--down-glow), 0 0 16px rgba(239,68,68,0.10); }
}

/* Badges */
.df-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.df-badge.p1  { background: rgba(239,68,68,0.15); color: var(--down); border-color: rgba(239,68,68,0.3); }
.df-badge.p2  { background: rgba(196,96,44,0.12); color: var(--accent); border-color: rgba(196,96,44,0.28); }
.df-badge.p3  { background: rgba(245,158,11,0.15); color: var(--warn); border-color: rgba(245,158,11,0.3); }
.df-badge.p4  { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(110,175,212,0.22); }
.df-badge.up   { background: rgba(34,197,94,0.1); color: var(--up); border-color: rgba(34,197,94,0.25); }
.df-badge.down { background: rgba(239,68,68,0.1); color: var(--down); border-color: rgba(239,68,68,0.25); }
.df-badge.warn { background: rgba(245,158,11,0.1); color: var(--warn); border-color: rgba(245,158,11,0.25); }
.df-badge.info { background: rgba(56,189,248,0.1); color: var(--info); border-color: rgba(56,189,248,0.25); }
.df-badge.open        { background: rgba(239,68,68,0.1); color: var(--down); border-color: rgba(239,68,68,0.25); }
.df-badge.investigating { background: rgba(245,158,11,0.1); color: var(--warn); border-color: rgba(245,158,11,0.25); }
.df-badge.resolved    { background: rgba(34,197,94,0.1); color: var(--up); border-color: rgba(34,197,94,0.25); }
.df-badge.closed      { background: rgba(104,104,160,0.1); color: var(--muted); border-color: rgba(104,104,160,0.2); }

/* ── 8. BUTTONS ─────────────────────────────────────────── */
.df-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.df-btn svg { width: 14px; height: 14px; stroke: currentColor; flex-shrink: 0; }

/* Primary */
.df-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-shadow: none;
}
.df-btn-primary:hover {
  background: #d4703a;
  box-shadow: 0 0 10px var(--accent-glow);
  text-decoration: none;
  color: #fff;
}

/* Secondary */
.df-btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-bright);
}
.df-btn-secondary:hover {
  color: var(--text);
  border-color: var(--muted);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

/* Ghost (icon-only or minimal) */
.df-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 7px;
}
.df-btn-ghost:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-color: var(--border);
  text-decoration: none;
}

/* Danger */
.df-btn-danger {
  background: transparent;
  color: var(--down);
  border-color: rgba(239,68,68,0.3);
}
.df-btn-danger:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--down);
  text-decoration: none;
  color: var(--down);
}

/* Cyan (data/link actions) */
.df-btn-cyan {
  background: transparent;
  color: var(--cyan);
  border-color: rgba(110,175,212,0.22);
}
.df-btn-cyan:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  text-shadow: 0 0 5px var(--cyan-glow);
  text-decoration: none;
  color: var(--cyan);
}

.df-btn:disabled, .df-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── 9. TABLES ──────────────────────────────────────────── */
.df-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.df-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.df-table thead th {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
  white-space: nowrap;
}

.df-table tbody tr {
  border-bottom: 1px solid var(--border-dim);
  transition: background var(--t-fast);
}

.df-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.df-table tbody tr:hover { background: rgba(110,175,212,0.04); }
.df-table tbody tr.clickable { cursor: pointer; }

/* Row accent on hover */
.df-table tbody tr.clickable:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.df-table td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

.df-table td.mono {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: var(--cyan);
}

.df-table td.muted { color: var(--muted); font-size: 14px; }

/* Row action buttons — hidden, revealed on hover */
.df-row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--t-fast); }
.df-table tbody tr:hover .df-row-actions { opacity: 1; }

/* ── 10. FORMS ──────────────────────────────────────────── */
.df-input, .df-select, .df-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  padding: 8px 12px;
  width: 100%;
  transition: border-color var(--t-fast);
  outline: none;
}

.df-input::placeholder, .df-textarea::placeholder { color: var(--dim); }

.df-input:focus, .df-select:focus, .df-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.df-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236868a0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.df-select option { background: var(--elevated); }

.df-textarea { resize: vertical; min-height: 80px; }

.df-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.df-input-group .df-input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.df-input-group .df-btn  { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: none; }

.df-label {
  display: block;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.df-field { margin-bottom: 16px; }

/* ── 11. DRAWERS ────────────────────────────────────────── */
.df-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--t-med);
  pointer-events: none;
}
.df-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.df-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 580px;
  max-width: 100vw;
  background: var(--elevated);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  overflow: hidden;
}
.df-drawer.open { transform: translateX(0); }

.df-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.df-drawer-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.df-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.df-drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── 12. MODALS ─────────────────────────────────────────── */
.df-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.df-modal {
  background: var(--elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.df-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.df-modal-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.df-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.df-modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ── 13. HTMX PROGRESS BAR ──────────────────────────────── */
#df-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent-glow);
  z-index: 9999;
  transition: width 0.3s ease, opacity 0.4s ease;
  pointer-events: none;
  opacity: 0;
}
#df-progress.running { opacity: 1; }

/* HTMX loading indicators */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; align-items: center; gap: 6px; }
.htmx-request.htmx-indicator { display: inline-flex; align-items: center; gap: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }
.df-spinner { animation: spin 0.8s linear infinite; }

/* ── 14. TOAST NOTIFICATIONS ────────────────────────────── */
#df-toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.df-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--elevated);
  border: 1px solid var(--border-bright);
  font-size: 13px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.df-toast svg { width: 16px; height: 16px; flex-shrink: 0; }

.df-toast.success { border-color: rgba(34,197,94,0.3); }
.df-toast.success svg { stroke: var(--up); }

.df-toast.error { border-color: rgba(239,68,68,0.3); }
.df-toast.error svg { stroke: var(--down); }

.df-toast.warning { border-color: rgba(245,158,11,0.3); }
.df-toast.warning svg { stroke: var(--warn); }

.df-toast.info { border-color: rgba(110,175,212,0.20); }
.df-toast.info svg { stroke: var(--cyan); }

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

/* ── 15. USER AVATAR ────────────────────────────────────── */
.df-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid var(--border-bright);
  overflow: hidden;
  flex-shrink: 0;
}

.df-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── 16. SYSTEM HEALTH BAR (topbar) ─────────────────────── */
.df-health-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-left: 1px solid var(--border);
}

.df-health-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}
.df-health-item.active { color: var(--text-dim); }

/* ── 17. BENTO GRID (Dashboard) ─────────────────────────── */
.df-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.df-col-3  { grid-column: span 3; }
.df-col-4  { grid-column: span 4; }
.df-col-6  { grid-column: span 6; }
.df-col-8  { grid-column: span 8; }
.df-col-9  { grid-column: span 9; }
.df-col-12 { grid-column: span 12; }

/* Responsive grid fallbacks */
@media (max-width: 1280px) {
  .df-col-3 { grid-column: span 6; }
  .df-col-4 { grid-column: span 6; }
}
@media (max-width: 768px) {
  /* Grid: stack everything */
  .df-col-3, .df-col-4, .df-col-6, .df-col-8, .df-col-9 { grid-column: span 12; }

  /* Sidebar: slide-in overlay instead of hidden */
  .df-sidebar {
    transform: translateX(-100%);
    transition: transform var(--t-med);
    z-index: 150;
    width: var(--sidebar-w) !important;
    box-shadow: none;
  }
  .df-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.7);
  }

  /* When mobile sidebar is open, always show full text regardless of collapsed state */
  .df-sidebar.mobile-open .df-nav-item span { display: inline; }
  .df-sidebar.mobile-open .df-nav-item { justify-content: flex-start; padding: 8px 12px; margin: 1px 8px; }
  .df-sidebar.mobile-open .df-sidebar-section-label { opacity: 1; }

  /* Main: full width regardless of sidebar state */
  .df-main,
  .df-main.sidebar-collapsed { margin-left: 0; }

  /* Topbar: auto-width brand so it doesn't push content */
  .df-topbar-brand {
    width: auto !important;
    min-width: unset;
    padding: 0 12px;
  }

  /* Hide desktop health bar — too cramped on mobile */
  .df-health-bar { display: none; }

  /* Tighter page padding */
  .df-page { padding: 16px; }

  /* Tabs: scrollable row, hide scrollbar */
  .df-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .df-tabs::-webkit-scrollbar { display: none; }

  /* Split panel: stack vertically */
  .df-split {
    grid-template-columns: 1fr;
    height: auto;
  }
  .df-split-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 280px;
  }

  /* Drawer: full width on mobile */
  .df-drawer { width: 100vw; }

  /* Filter bar: tighter wrap, inputs fill available space */
  .df-filter-bar { padding: 10px 12px; gap: 8px; }
  .df-filter-bar .df-select,
  .df-filter-bar .df-input { flex: 1; min-width: 0; width: auto; }

  /* Page header: wrap actions below title on small screens */
  .df-page-header { flex-wrap: wrap; margin-bottom: 16px; }
  .df-page-title { font-size: 16px; }

  /* Hide username in topbar — avatar alone is enough */
  .df-topbar-username { display: none !important; }

  /* Panel divider: border-right on desktop → border-bottom when stacked */
  .df-panel-divider-r { border-right: none !important; border-bottom: 1px solid rgba(255,255,255,0.05); }

  /* ── Text wrapping ───────────────────────────────────── */

  /* Tables: let cell content wrap instead of clipping */
  .df-table td { white-space: normal !important; }
  .df-table td > div,
  .df-table td > span {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
  }
  /* Preserve single-line display for badges and action buttons */
  .df-table .df-badge,
  .df-table .df-row-actions { white-space: nowrap !important; }

  /* Cards: unwrap elements actively using text-overflow:ellipsis.
     Deliberately targets only truncating text, not badges/chips (which
     use white-space:nowrap but not text-overflow:ellipsis). */
  .df-card [style*="ellipsis"] {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Media page rows: let title wrap */
  .media-row-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* Utility: hide content that clutters mobile layouts */
  .df-hide-mobile { display: none !important; }
}

/* ── iOS PWA Safe Area (notch + home indicator) ──────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .df-topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .df-sidebar {
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .df-main {
    margin-top: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Responsive 2-column layout helpers ─────────────────── */
.df-col-sidebar-sm { display:grid; grid-template-columns:220px 1fr; gap:16px; align-items:start; }
.df-col-sidebar-md { display:grid; grid-template-columns:240px 1fr; gap:16px; align-items:start; }
.df-col-sidebar-l  { display:grid; grid-template-columns:280px 1fr; gap:20px; align-items:start; }
.df-col-sidebar-lg { display:grid; grid-template-columns:340px 1fr; gap:16px; align-items:start; }
.df-col-sidebar-r  { display:grid; grid-template-columns:1fr 300px; gap:20px; align-items:start; }
.df-col-half       { display:grid; grid-template-columns:1fr 1fr;   gap:16px; }

@media (max-width: 768px) {
  .df-col-sidebar-sm,
  .df-col-sidebar-md,
  .df-col-sidebar-l,
  .df-col-sidebar-lg,
  .df-col-sidebar-r,
  .df-col-half { grid-template-columns:1fr; }
}

/* Mobile sidebar backdrop */
.df-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  z-index: 140;
  animation: backdrop-in 0.2s ease;
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Widget card header */
.df-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-dim);
}

.df-widget-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.df-widget-label svg { width: 12px; height: 12px; stroke: currentColor; }

/* Subtle grid background (dashboard ambiance) */
.df-grid-bg {
  background-image:
    linear-gradient(rgba(37,37,41,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,37,41,0.5) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center;
}

/* ── 18. SPLIT PANEL (Incidents, Runbooks) ───────────────── */
.df-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  height: calc(100vh - var(--topbar-h) - 180px);
  min-height: 400px;
}

.df-split-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--surface);
}

.df-split-detail {
  overflow-y: auto;
  background: var(--bg);
}

.df-split-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  transition: background var(--t-fast);
}
.df-split-item:hover { background: rgba(255,255,255,0.03); }
.df-split-item.selected {
  background: rgba(110,175,212,0.05);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ── 19. EMPTY STATE ────────────────────────────────────── */
.df-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
}

.df-empty svg {
  width: 40px; height: 40px;
  stroke: var(--dim);
}

.df-empty-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.df-empty-desc { font-size: 13px; color: var(--dim); max-width: 300px; }

/* ── 20. TIMELINE (Incident detail) ─────────────────────── */
.df-timeline { position: relative; padding-left: 28px; }
.df-timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 4px; bottom: 4px;
  width: 1px;
  background: var(--border);
}

.df-timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.df-timeline-item::before {
  content: '';
  position: absolute;
  left: -24px; top: 5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid var(--surface);
}

.df-timeline-item.opened::before { background: var(--down); }
.df-timeline-item.resolved::before { background: var(--up); }
.df-timeline-item.note::before { background: var(--cyan); }
.df-timeline-item.status_change::before { background: var(--warn); }

.df-timeline-time {
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 4px;
}

.df-timeline-msg {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── 21. USER MENU DROPDOWN ─────────────────────────────── */
.df-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--r-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 200;
  overflow: hidden;
}

.df-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}
.df-dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--text); text-decoration: none; }
.df-dropdown-item svg { width: 15px; height: 15px; stroke: currentColor; }
.df-dropdown-item.danger { color: var(--down); }
.df-dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }

.df-dropdown-divider { height: 1px; background: var(--border-dim); margin: 4px 0; }

/* ── 22. LOG / CODE OUTPUT ──────────────────────────────── */
.df-log-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: var(--cyan);
  overflow-x: auto;
  white-space: pre;
  max-height: 400px;
  overflow-y: auto;
}

/* ── 23. SERVICE CATEGORY GRID ──────────────────────────── */
.df-service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.df-service-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.df-service-card:hover {
  border-color: var(--border-bright);
  background: rgba(255,255,255,0.03);
}
.df-service-card.down { border-color: rgba(239,68,68,0.2); }
.df-service-card.down:hover { border-color: var(--down); }

.df-service-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.df-service-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.df-service-meta {
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}

/* ── 24. GALLERY ────────────────────────────────────────── */
.df-gallery-grid {
  columns: 4;
  column-gap: 12px;
}
@media (max-width: 1400px) { .df-gallery-grid { columns: 3; } }
@media (max-width: 900px)  { .df-gallery-grid { columns: 2; } }
@media (max-width: 600px)  { .df-gallery-grid { columns: 1; } }

.df-gallery-item {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border);
  display: block;
}
.df-gallery-item img {
  width: 100%;
  display: block;
  transition: transform var(--t-med);
}
.df-gallery-item:hover img { transform: scale(1.03); }
.df-gallery-item:hover .df-gallery-overlay { opacity: 1; }

.df-gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6,6,8,0.8) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--t-med);
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
}

/* ── 25. MISC UTILITIES ─────────────────────────────────── */
.df-divider {
  height: 1px;
  background: var(--border-dim);
  margin: 16px 0;
}

.df-code {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: var(--cyan);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.df-scroll-area {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.df-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Collapsed sidebar tooltip (title attribute handles this, but custom for polish) */
.df-sidebar.collapsed .df-nav-item {
  position: relative;
}

/* Admin sub-nav */
.df-admin-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 180px;
  flex-shrink: 0;
}

.df-admin-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
}
.df-admin-nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); text-decoration: none; }
.df-admin-nav-item.active { color: var(--cyan); background: var(--cyan-dim); text-shadow: 0 0 8px var(--cyan-glow); }
.df-admin-nav-item svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }

/* Admin page layout (sub-nav + content) */
.df-admin-layout {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  min-height: 500px;
}
.df-admin-content { flex: 1; padding: 24px; overflow: auto; }
