/* ═══ KALDIN ANALYTICS v5 ═══ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:16px;-webkit-font-smoothing:antialiased}

:root {
  --sidebar-w: 244px;
  --header-h: 58px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;

  --bg: #e8e6e1;
  --bg-texture: linear-gradient(135deg, #ece9e4 0%, #e2dfd9 30%, #e8e5e0 60%, #dfdcd6 100%);
  --bg-card: rgba(255,255,255,0.85);
  --bg-card-solid: #ffffff;
  --bg-card-hover: rgba(255,255,255,0.95);
  --bg-sidebar-flat: #2f323e;
  --bg-sidebar-hover: rgba(255,255,255,0.06);
  --bg-sidebar-active: rgba(255,255,255,0.12);
  --bg-header: rgba(255,255,255,0.6);
  --bg-input: rgba(0,0,0,0.04);
  --bg-hover: rgba(0,0,0,0.02);

  --text-1: #1a1c2b;
  --text-2: #4a4d5e;
  --text-3: #8a8d9e;
  --text-sidebar: #a0a3b0;

  --border: rgba(0,0,0,0.06);
  --border-card: rgba(255,255,255,0.6);

  --accent: #5b6abf;
  --accent-soft: #eef0ff;

  --good: #2d9d78; --good-soft: #e8f5ef;
  --warn: #d4882e; --warn-soft: #fdf3e4;
  --crit: #d64545; --crit-soft: #fce8e8;
  --info: #6b5ce7; --info-soft: #f0edfe;

  --c1:#5b8def; --c2:#2d9d78; --c3:#d4882e; --c4:#d64545;
  --c5:#8b6cf0; --c6:#d06ca0; --c7:#3596a8; --c8:#7aab48;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
  --shadow-kpi: 0 2px 8px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);

  --glass: saturate(180%) blur(12px);
  --r: 14px; --r-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font);
  background: var(--bg-texture);
  background-attachment: fixed;
  color: var(--text-1);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* ═══ ICONS ═══ */
.i { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.i svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm svg { width: 14px; height: 14px; }
.i-xs svg { width: 11px; height: 11px; }

/* ═══ LAYOUT ═══ */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--header-h) 1fr; grid-template-areas: "side head" "side main"; height: 100vh; position: relative; z-index: 1; }

/* ═══ SIDEBAR ═══ */
.side {
  grid-area: side;
  background: var(--bg-sidebar-flat);
  background-image: linear-gradient(180deg, #3e414f 0%, #33363f 50%, #2a2d35 100%);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.logo { padding: 20px 20px 18px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.logo-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #6b7fff 0%, #a855f7 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 16px;
  box-shadow: 0 2px 12px rgba(107,127,255,0.25);
}
.logo-name { color: #fff; font-weight: 600; font-size: 14.5px; letter-spacing: -0.2px; }
.logo-sub { color: var(--text-sidebar); font-size: 11px; font-weight: 400; margin-top: 1px; }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 13px; border-radius: 9px; color: var(--text-sidebar); font-size: 13.5px; font-weight: 500; text-decoration: none; transition: all 120ms var(--ease); cursor: pointer; }
.nav a:hover { background: rgba(255,255,255,0.07); color: #d0d3e0; }
.nav a.on { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.nav a .i { color: var(--text-sidebar); opacity: 0.6; transition: all 150ms; }
.nav a:hover .i { opacity: 0.85; color: #b0b5d4; }
.nav a.on .i { opacity: 1; color: #c0ccff; }
.nav-sep { height: 1px; background: rgba(255,255,255,0.07); margin: 8px 13px; }

/* ═══ HEADER ═══ */
.head {
  grid-area: head;
  background: var(--bg-header);
  backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; z-index: 50;
}
.head-title { font-weight: 700; font-size: 17px; letter-spacing: -0.3px; }
.head-r { display: flex; align-items: center; gap: 10px; }
.ps { display: flex; align-items: center; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; padding: 6px 12px; font-size: 13px; backdrop-filter: blur(8px); }
.ps input { border: none; background: none; outline: none; font-family: var(--font); font-size: 12.5px; color: var(--text-1); cursor: pointer; font-weight: 500; }
.hb { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-card); color: var(--text-3); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 120ms; backdrop-filter: blur(8px); }
.hb:hover { border-color: var(--accent); color: var(--accent); }

/* ═══ MAIN ═══ */
.main { grid-area: main; overflow-y: auto; padding: 22px 26px 40px; }

/* ═══ KPI ═══ */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--bg-card); backdrop-filter: blur(8px);
  border: 1px solid var(--border-card); border-radius: var(--r);
  padding: 16px 18px 14px; box-shadow: var(--shadow-kpi);
  transition: all 200ms var(--ease); position: relative;
}
.kpi:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); background: var(--bg-card-hover); }
.kpi-label { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.kpi-val { font-size: 28px; font-weight: 800; color: var(--text-1); line-height: 1; margin-bottom: 8px; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.kpi-val-warn { color: var(--warn); }
.kpi-bot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-period { font-size: 11px; color: var(--text-3); }
.kpi-tr { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px; display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.kpi-tr.up { background: var(--good-soft); color: var(--good); }
.kpi-tr.dn { background: var(--crit-soft); color: var(--crit); }
.kpi-tr.nt { background: var(--bg-input); color: var(--text-3); }

/* ═══ BENTO ═══ */
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.b8 { grid-column: span 8; } .b6 { grid-column: span 6; }
.b4 { grid-column: span 4; } .b3 { grid-column: span 3; }

.card {
  background: var(--bg-card); backdrop-filter: blur(8px);
  border: 1px solid var(--border-card); border-radius: var(--r);
  box-shadow: var(--shadow-card); overflow: hidden; transition: box-shadow 200ms;
}
.card:hover { box-shadow: var(--shadow-card-hover); }
.card-h { padding: 16px 18px 12px; display: flex; align-items: center; justify-content: space-between; }
.card-t { font-size: 14px; font-weight: 700; color: var(--text-1); display: flex; align-items: center; gap: 8px; letter-spacing: -0.2px; }
.card-t .i { color: var(--text-3); }
.card-sub { font-size: 11px; color: var(--text-3); font-weight: 500; }
.card-b { padding: 0 18px 18px; }

/* ═══ ACTION TILES ═══ */
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act-tile {
  padding: 14px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-card-solid);
  transition: all 150ms; cursor: pointer;
}
.act-tile:hover { box-shadow: var(--shadow-card); transform: translateY(-1px); }
.act-tile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.act-tile-name { font-size: 14px; font-weight: 700; }
.act-tile-loss { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.act-tile-loss-crit { color: var(--crit); }
.act-tile-loss-warn { color: var(--warn); }
.act-tile-desc { font-size: 11.5px; color: var(--text-2); line-height: 1.4; margin-bottom: 8px; }
.act-tile-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.act-chip { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.act-chip-ds { background: var(--crit-soft); color: var(--crit); }
.act-chip-load { background: var(--warn-soft); color: var(--warn); }
.act-chip-badge { padding: 3px 8px; border-radius: 5px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: #fff; }
.act-chip-crit { background: var(--crit); }
.act-chip-warn { background: var(--warn); }

/* ═══ HEALTH MAP ═══ */
.hm { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.hm thead th { padding: 7px 8px; text-align: left; font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.hm thead th.c { text-align: center; }
.hm tbody td { padding: 8px 8px; border-bottom: 1px solid rgba(0,0,0,0.03); vertical-align: middle; }
.hm tbody tr { transition: background 80ms; cursor: pointer; }
.hm tbody tr:hover { background: var(--bg-hover); }
.hm tbody tr:last-child td { border-bottom: none; }
.hm-doc { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12.5px; }
.hm-spec { font-size: 11px; color: var(--text-3); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-r,.dot-critical { background: var(--crit); box-shadow: 0 0 5px rgba(214,69,69,0.3); }
.dot-y,.dot-warning { background: var(--warn); box-shadow: 0 0 5px rgba(212,136,46,0.25); }
.dot-g,.dot-ok { background: var(--good); box-shadow: 0 0 5px rgba(45,157,120,0.25); }

.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 5px; text-align: center; font-variant-numeric: tabular-nums; }
.chip-r { background: var(--crit-soft); color: var(--crit); }
.chip-y { background: var(--warn-soft); color: var(--warn); }
.chip-g { background: var(--good-soft); color: var(--good); }
.chip-n { color: var(--text-3); }

/* ═══ GAUGE ═══ */
.gauge-box { display: flex; flex-direction: column; align-items: center; padding: 12px 0 4px; }
.gauge-ring { position: relative; width: 160px; height: 160px; }
.gauge-ring svg { width: 100%; height: 100%; }
.gauge-ring .track { fill: none; stroke: var(--bg-input); stroke-width: 14; stroke-dasharray: 236; stroke-linecap: round; }
.gauge-ring .fill { fill: none; stroke-width: 14; stroke-dasharray: 236; stroke-linecap: round; transition: stroke-dashoffset 1.5s var(--ease); }
.gauge-ring .fill-glow { fill: none; stroke-width: 18; stroke-dasharray: 236; stroke-linecap: round; opacity: 0.15; filter: blur(4px); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-num { font-size: 32px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.gauge-status { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; margin-top: 2px; padding: 2px 10px; border-radius: 4px; }
.gauge-lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 2px; font-weight: 600; margin-top: 2px; }
.gauge-norm { font-size: 12px; color: var(--text-3); margin-top: 10px; font-weight: 500; }

/* ═══ DS BARS ═══ */
.ds-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.ds-row:last-child { margin-bottom: 0; }
.ds-lbl { font-size: 12px; font-weight: 500; color: var(--text-2); width: 80px; text-align: right; flex-shrink: 0; }
.ds-track { flex: 1; height: 20px; background: var(--bg-input); border-radius: 5px; overflow: hidden; }
.ds-fill { height: 100%; border-radius: 5px; transition: width 1s var(--ease); opacity: 0.85; }
.ds-val { font-size: 12px; font-weight: 700; color: var(--text-1); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

/* ═══ XY CHART ═══ */
.xy-duo { display: flex; gap: 16px; margin-bottom: 14px; }
.xy-block { display: flex; align-items: center; gap: 10px; flex: 1; }
.xy-letter { font-size: 28px; font-weight: 800; line-height: 1; opacity: 0.8; }
.xy-big { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.xy-sub-label { font-size: 10px; color: var(--text-3); font-weight: 500; margin-top: 1px; }
.xy-canvas-wrap { position: relative; margin: 0 -4px; }
.xy-svg { width: 100%; height: 120px; display: block; }
.xy-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; }
.xy-leg-item { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-3); font-weight: 500; }
.xy-leg-line { width: 16px; height: 2.5px; border-radius: 2px; }
.xy-leg-dash { background: repeating-linear-gradient(90deg, var(--crit) 0, var(--crit) 4px, transparent 4px, transparent 7px) !important; height: 2px; }
.xy-verdict { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ═══ TOOLTIPS ═══ */
.tip-wrap { position: relative; display: inline-flex; }
.tip-btn {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-3); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 120ms; flex-shrink: 0; line-height: 1;
}
.tip-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tip-pop {
  display: none; position: absolute; z-index: 999;
  top: calc(100% + 8px); right: -8px;
  width: 280px; padding: 14px 16px;
  background: var(--bg-card-solid); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  font-size: 12px; line-height: 1.55; color: var(--text-2);
}
.tip-pop::before {
  content: ''; position: absolute; top: -5px; right: 16px;
  width: 10px; height: 10px;
  background: var(--bg-card-solid); border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.tip-pop.show { display: block; animation: tipIn 150ms var(--ease); }
.tip-pop strong { color: var(--text-1); font-weight: 600; }
.tip-pop .tip-title { font-size: 12px; font-weight: 700; color: var(--text-1); margin-bottom: 6px; }
.tip-divider { height: 1px; background: var(--border); margin: 8px 0; }
@keyframes tipIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ CONNECTION ERROR ═══ */
.conn-err { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; text-align: center; }
.conn-err-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.conn-err-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.conn-err-text { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.conn-err-hint { font-size: 12px; color: var(--text-3); margin-bottom: 20px; }
.conn-err-btn { padding: 8px 20px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; font-family: var(--font); font-size: 13px; }

/* ═══ LOADING ═══ */
.loading-box { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-3); margin-top: 12px; }

/* ═══ PLACEHOLDER ═══ */
.page-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--text-3); }
.page-placeholder-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.4; }
.page-placeholder-text { font-size: 13px; }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 2px; }
