/*
  Tema DSI portado del ai-dash (web-src/src/app.css) sin cambios de diseno.
  Unica desviacion: las URLs de @font-face son RELATIVAS al propio CSS
  (fonts/...), no absolutas (/fonts/...), porque el Tablero se sirve tanto en
  la raiz como bajo /tablero/ tras el proxy. Cero egreso: fuentes locales.
*/
/*
  DSI AI-Dash v3 - product UI theme
  Brand anchors: #0D3050 navy, #17938D turquoise, neutral work surfaces.
*/

@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/montserrat-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/montserrat-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/montserrat-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/montserrat-700.ttf') format('truetype');
}

:root {
  --dsi-navy: #0d3050;
  --dsi-navy-deep: #05243d;
  --dsi-turquoise: #17938d;
  --dsi-turquoise-bright: #1eb8b0;
  --dsi-white: #ffffff;

  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f7fafc;
  --sidebar: #0b2945;
  --sidebar-hover: rgba(255, 255, 255, 0.075);
  --sidebar-active: rgba(30, 184, 176, 0.16);
  --border: #dbe4ee;
  --border-strong: #b8c7d8;
  --text: #10263f;
  --text-secondary: #4c6178;
  --text-muted: #8293a8;
  --accent: var(--dsi-turquoise);
  --accent-hover: #117a75;
  --accent-soft: #e5f6f4;
  --accent-contrast: #ffffff;
  --ok: #12806f;
  --ok-bg: #def4ef;
  --bad: #c2413a;
  --bad-bg: #fde9e8;
  --warn: #a16207;
  --warn-bg: #fff4d6;
  --info: #2563eb;
  --info-bg: #e8f0ff;

  --font: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --topbar-height: 56px;
  --sidebar-width: 244px;
  --content-pad: 24px;
  /* Tracking scale — positive tracking on uppercase microlabels reads as refined. */
  --track-caps: 0.6px;
  --track-caps-tight: 0.4px;
  /* Layered elevation */
  --shadow-soft: 0 1px 2px rgba(16, 38, 63, 0.05), 0 1px 1px rgba(16, 38, 63, 0.04);
  --shadow: 0 1px 2px rgba(16, 38, 63, 0.06), 0 6px 16px -4px rgba(16, 38, 63, 0.10);
  --shadow-lg: 0 2px 4px rgba(16, 38, 63, 0.06), 0 16px 40px -8px rgba(16, 38, 63, 0.16);
  --ring: 0 0 0 3px rgba(23, 147, 141, 0.18);
}

html[data-theme="dark"] {
  --bg: #0b1521;
  --surface: #111f30;
  --surface-raised: #15263a;
  --surface-subtle: #0e1a29;
  --sidebar: #061220;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(30, 184, 176, 0.18);
  --border: #203247;
  --border-strong: #344b64;
  --text: #edf4fb;
  --text-secondary: #a7b8ca;
  --text-muted: #71849a;
  --accent: var(--dsi-turquoise-bright);
  --accent-hover: #34d3cc;
  --accent-soft: rgba(30, 184, 176, 0.16);
  --accent-contrast: #041c24;
  --ok: #45c7b5;
  --ok-bg: rgba(69, 199, 181, 0.16);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.15);
  --warn: #f7c867;
  --warn-bg: rgba(247, 200, 103, 0.15);
  --info: #7db1ff;
  --info-bg: rgba(125, 177, 255, 0.15);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 1px rgba(0, 0, 0, 0.20);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 8px 20px -4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 44px -8px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.page,
.agents-page,
.cockpit,
.control-page,
.network-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.header,
.hero,
.page-head,
.live-header,
.cockpit-header,
.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.header h1,
.hero h1,
.page-head h1,
.live-header h1,
.cockpit-header h1,
.head h1 {
  margin: 0 0 4px;
}

.header p,
.hero p,
.page-head p,
.live-header p,
.head p {
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.card h2,
.card h3 {
  margin: 0 0 12px;
}

.card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  background: var(--surface-subtle);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

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

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

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 20px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  white-space: nowrap;
}

.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }

.muted { color: var(--text-muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}

.kpi {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0;
  transition: opacity 160ms ease;
}

.kpi:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.kpi:hover::before {
  opacity: 0.9;
}

.kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 7px;
}

.kpi-value {
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data th {
  background: var(--surface-subtle);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--text-secondary);
}

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

table.data tbody tr:last-child td {
  border-bottom: 0;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  accent-color: var(--accent);
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

@keyframes content-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.table {
  overflow: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
  align-items: center;
}

.detail-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
}

pre {
  margin: 8px 0 16px;
  padding: 14px;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

@media (max-width: 900px) {
  :root {
    --content-pad: 16px;
  }

  body {
    overflow: auto;
  }

  .header,
  .hero,
  .page-head,
  .live-header,
  .cockpit-header,
  .head {
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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