/* ===========================================================
   TAI Operator Dashboard  —  brand styles
   Palette: indigo #151184 · navy #0A2A44 · gold #F2C230 · teal #1E6B4B
   Clean, modern, light. Tasteful, trustworthy, client-demo-ready.
   =========================================================== */

:root {
  --tai-indigo:   #151184;
  --tai-indigo-2: #2a25a8;
  --tai-navy:     #0A2A44;
  --tai-gold:     #F2C230;
  --tai-teal:     #1E6B4B;
  --tai-teal-2:   #2f9169;
  --tai-rose:     #c0436b;
  --tai-sky:      #2f6fed;

  --bg:        #f6f7fb;
  --bg-2:      #eef0f7;
  --surface:   #ffffff;
  --surface-2: #fbfbfe;
  --line:      #e6e8f0;
  --line-2:    #dcdfec;
  --ink:       #10142b;
  --ink-2:     #454a63;
  --ink-3:     #7a8098;
  --shadow:    0 1px 2px rgba(16,20,43,.04), 0 8px 24px rgba(16,20,43,.06);
  --shadow-sm: 0 1px 2px rgba(16,20,43,.05), 0 2px 8px rgba(16,20,43,.05);
  --radius:    16px;
  --radius-sm: 11px;

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
::selection { background: rgba(21,17,132,.14); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #14113f 0%, #0d0b2e 60%, #0a0922 100%);
  color: #cfd2ec;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 20px;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--tai-gold), #f6d873);
  color: var(--tai-navy);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: -.5px;
  box-shadow: 0 6px 16px rgba(242,194,48,.28);
}
.brand .brand-txt b { display: block; color: #fff; font-size: 15px; letter-spacing: -.2px; }
.brand .brand-txt span { font-size: 11px; color: #9b9fc9; letter-spacing: .3px; }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: #7d81ad; padding: 16px 12px 8px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: #c3c6e6; cursor: pointer;
  font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .82; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(242,194,48,.16), rgba(242,194,48,.02));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--tai-gold);
}
.nav-item.active svg { opacity: 1; color: var(--tai-gold); }

.sidebar-foot {
  margin-top: auto; padding: 14px 12px 4px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px; color: #8286b3;
}
.sidebar-foot .dot { color: var(--tai-teal-2); }

/* ---------- Main ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; display: flex; align-items: center; gap: 16px;
  padding: 0 28px; background: rgba(246,247,251,.82);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: 13px; color: var(--ink-3); }
.topbar .crumb b { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2); font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.pill .live { width: 7px; height: 7px; border-radius: 50%; background: var(--tai-teal-2); box-shadow: 0 0 0 3px rgba(47,145,105,.18); }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 6px; color: var(--ink); }
.hamburger svg { width: 22px; height: 22px; }

.view { padding: 26px 28px 48px; animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 20px; }
.view-head h1 { font-size: 24px; letter-spacing: -.4px; margin: 0 0 4px; }
.view-head p { margin: 0; color: var(--ink-3); font-size: 13.5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }

/* Hero metric cards */
.hero-grid { grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; }
.metric-card {
  position: relative; overflow: hidden; padding: 20px 20px 0;
  border-radius: var(--radius); color: #fff; min-height: 152px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.metric-card.m-indigo { background: linear-gradient(135deg, #1b1793 0%, #120f66 100%); }
.metric-card.m-teal   { background: linear-gradient(135deg, #1f7a55 0%, #0f5138 100%); }
.metric-card.m-navy   { background: linear-gradient(135deg, #123a5c 0%, #0a2438 100%); }
.metric-card .m-top { display: flex; align-items: center; justify-content: space-between; }
.metric-card .m-label { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: rgba(255,255,255,.72); font-weight: 600; }
.metric-card .m-badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.16); font-weight: 600; }
.metric-card .m-badge.up { background: rgba(101,214,160,.24); color: #c9f6de; }
.metric-card .m-badge.dn { background: rgba(255,140,140,.22); color: #ffd6d6; }
.metric-card .m-value { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 10px 0 2px; }
.metric-card .m-sub { font-size: 12px; color: rgba(255,255,255,.66); }
.metric-card .spark { margin: 0 -20px; margin-top: auto; height: 66px; }
.metric-card .spark canvas { display: block; }

/* Panel */
.panel { padding: 20px 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 15px; letter-spacing: -.2px; }
.panel-head .sub { font-size: 12px; color: var(--ink-3); }

.two-col { grid-template-columns: 1.15fr .85fr; align-items: start; }

/* Subscription rows */
.sub-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0; border-top: 1px solid var(--line);
}
.sub-row:first-of-type { border-top: none; }
.sub-icon {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
}
.sub-meta { flex: 1; min-width: 0; }
.sub-meta b { font-size: 13.5px; display: block; }
.sub-meta span { font-size: 11.5px; color: var(--ink-3); }
.sub-price { text-align: right; }
.sub-price b { font-size: 15px; }
.sub-price span { display: block; font-size: 11px; color: var(--ink-3); }

/* Usage bars */
.usage-row { margin-bottom: 15px; }
.usage-row .u-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.usage-row .u-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.usage-row .u-name small { font-weight: 500; color: var(--ink-3); margin-left: 6px; }
.usage-row .u-val { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.track { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.fill-indigo { background: linear-gradient(90deg, var(--tai-indigo), var(--tai-indigo-2)); }
.fill-teal   { background: linear-gradient(90deg, var(--tai-teal), var(--tai-teal-2)); }
.fill-gold   { background: linear-gradient(90deg, #d9a516, var(--tai-gold)); }
.fill-navy   { background: linear-gradient(90deg, var(--tai-navy), #1a557f); }
.fill-warn   { background: linear-gradient(90deg, #d98014, #f0a93a); }

.mini-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-top: 4px; }
.mini-stat { padding: 14px 16px; }
.mini-stat .ms-v { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.mini-stat .ms-l { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.mini-stat .ms-v small { font-size: 13px; color: var(--ink-3); font-weight: 600; }

/* ---------- Knowledge graph ---------- */
.graph-wrap { position: relative; }
.graph-card { padding: 0; overflow: hidden; height: calc(100vh - 210px); min-height: 460px; position: relative; }
#graph { display: block; width: 100%; height: 100%; }
.graph-toolbar {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; gap: 10px; align-items: center; pointer-events: none; flex-wrap: wrap;
}
.graph-toolbar > * { pointer-events: auto; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 7px 14px; box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.search-box svg { width: 15px; height: 15px; color: var(--ink-3); }
.search-box input { border: none; outline: none; background: none; font-size: 13px; width: 190px; color: var(--ink); }
.legend {
  display: flex; gap: 6px; flex-wrap: wrap;
  background: rgba(255,255,255,.94); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 6px 12px; box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
}
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); cursor: pointer; padding: 1px 4px; border-radius: 6px; font-weight: 500; }
.legend .lg:hover { background: var(--bg-2); }
.legend .lg.off { opacity: .35; }
.legend .lg i { width: 10px; height: 10px; border-radius: 50%; }
.graph-stat {
  position: absolute; bottom: 14px; left: 14px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 6px 14px; font-size: 11.5px; color: var(--ink-3);
  box-shadow: var(--shadow-sm); backdrop-filter: blur(6px);
}
.node-panel {
  position: absolute; top: 62px; right: 14px; width: 258px;
  background: rgba(255,255,255,.97); border: 1px solid var(--line-2);
  border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px;
  transform: translateX(20px); opacity: 0; pointer-events: none; transition: .2s;
}
.node-panel.show { transform: none; opacity: 1; pointer-events: auto; }
.node-panel .np-type { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.node-panel h4 { margin: 6px 0 8px; font-size: 16px; letter-spacing: -.2px; }
.node-panel p { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.node-panel .np-conn { font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.node-panel .np-chip { display: inline-block; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); margin: 0 4px 4px 0; }
.node-panel .np-close { position: absolute; top: 12px; right: 12px; cursor: pointer; color: var(--ink-3); font-size: 18px; line-height: 1; }

/* ---------- Skills catalog ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tab {
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  cursor: pointer; transition: .15s; box-shadow: var(--shadow-sm);
}
.tab:hover { border-color: var(--line-2); color: var(--ink); }
.tab.active { background: var(--tai-indigo); border-color: var(--tai-indigo); color: #fff; box-shadow: 0 6px 16px rgba(21,17,132,.24); }
.tab .cnt { opacity: .6; margin-left: 5px; font-weight: 500; }

.cat-block { margin-bottom: 30px; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cat-head h3 { margin: 0; font-size: 16px; letter-spacing: -.2px; }
.cat-head .cat-count { font-size: 12px; color: var(--ink-3); background: var(--bg-2); padding: 2px 9px; border-radius: 999px; font-weight: 600; }

.skill-grid { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.skill-card { padding: 16px 18px; transition: transform .15s, box-shadow .15s; }
.skill-card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(16,20,43,.10); }
.skill-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.skill-name { display: flex; align-items: center; gap: 10px; }
.skill-name .sk-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: 0 0 34px; }
.skill-name .sk-ic svg { width: 17px; height: 17px; }
.skill-name b { font-size: 14px; font-family: "SFMono-Regular", ui-monospace, Menlo, monospace; letter-spacing: -.3px; display: block; }
.skill-name span { font-size: 11px; color: var(--ink-3); }
.badge { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.badge.active   { background: rgba(47,145,105,.14); color: var(--tai-teal); }
.badge.learning { background: rgba(217,165,22,.16); color: #a5760b; }
.badge.stale    { background: rgba(122,128,152,.14); color: var(--ink-3); }
.badge.expert   { background: rgba(21,17,132,.10); color: var(--tai-indigo); }
.skill-metrics { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px 16px; margin-top: 4px; }
.sm { }
.sm .sm-l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
.sm .sm-v { font-size: 15px; font-weight: 700; letter-spacing: -.3px; }
.sm .sm-v small { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.load-line { grid-column: 1 / -1; margin-top: 4px; }
.load-line .u-top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.load-line .u-top span { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ---------- Agent gallery ---------- */
.agent-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.agent-card { overflow: hidden; transition: transform .15s, box-shadow .15s; }
.agent-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(16,20,43,.13); }
.agent-banner { height: 84px; position: relative; display: flex; align-items: flex-end; padding: 14px 18px; }
.agent-banner::after { content:""; position:absolute; inset:0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.18)); }
.agent-avatar {
  width: 54px; height: 54px; border-radius: 14px; position: absolute; bottom: -22px; left: 18px;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px;
  border: 3px solid var(--surface); box-shadow: var(--shadow); z-index: 2;
}
.agent-status {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  font-size: 11px; font-weight: 600; color: #fff; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18); backdrop-filter: blur(4px); display: inline-flex; align-items: center; gap: 6px;
}
.agent-status i { width: 6px; height: 6px; border-radius: 50%; background: #6ee7a8; box-shadow: 0 0 0 3px rgba(110,231,168,.3); }
.agent-status.idle i { background: #f5cf6a; box-shadow: 0 0 0 3px rgba(245,207,106,.3); }
.agent-body { padding: 30px 18px 18px; }
.agent-body h3 { margin: 0; font-size: 16px; letter-spacing: -.3px; }
.agent-body .a-role { font-size: 12.5px; color: var(--ink-3); margin: 2px 0 12px; }
.agent-body .a-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; margin: 0 0 14px; min-height: 38px; }
.model-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; background: var(--bg-2); color: var(--ink-2); margin-bottom: 12px;
}
.model-badge i { width: 7px; height: 7px; border-radius: 2px; }
.tool-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-tag { font-size: 11px; padding: 3px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
.agent-foot { display: flex; gap: 18px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.agent-foot .af { font-size: 11px; color: var(--ink-3); }
.agent-foot .af b { display: block; font-size: 14px; color: var(--ink); font-weight: 700; letter-spacing: -.3px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --sidebar-w: 232px; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: none; }
  .hamburger { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(10,10,30,.4); z-index: 25; opacity: 0; pointer-events: none; transition: .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .hero-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .view { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .node-panel { width: 210px; }
  .graph-card { height: 62vh; }
}
@media (max-width: 560px) {
  .mini-stats { grid-template-columns: 1fr; }
  .search-box input { width: 120px; }
}
