/* Clean-Shirt Dashboard — dark + terracotta */
:root {
  --bg: #0a0b0d;
  --bg-card: #131418;
  --bg-card-2: #1a1c22;
  --border: #232730;
  --border-strong: #2f3441;
  --fg: #ececf1;
  --fg-dim: #9ca0ad;
  --fg-mute: #6a6e7a;
  --accent: #d97a4a;
  --accent-2: #ffa472;
  --accent-soft: rgba(217, 122, 74, 0.15);
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --radius: 12px;
  --mono: 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, textarea, select {
  background: var(--bg-card-2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 900px) { .app { grid-template-columns: 1fr; } }

.sidebar {
  background: linear-gradient(180deg, #0e0f12 0%, #0a0b0d 100%);
  border-right: 1px solid var(--border);
  padding: 20px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
@media (max-width: 900px) { .sidebar { position: static; height: auto; } }

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px;
  border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.brand-logo { width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #1a0b04; }
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 10px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.1em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--fg-dim); font-size: 13px; font-weight: 500; }
.nav a:hover { background: var(--bg-card); color: var(--fg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); }
.nav .badge { margin-left: auto; font-size: 10px; background: var(--red); color: #fff;
  padding: 1px 6px; border-radius: 8px; font-weight: 600; }

.main { padding: 24px 32px; min-width: 0; }
@media (max-width: 900px) { .main { padding: 16px; } }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.h1 { font-size: 22px; font-weight: 700; margin: 0; }
.h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--fg-dim); font-size: 12px; }
.mono { font-family: var(--mono); }

.period-switch { display: inline-flex; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; }
.period-switch button { background: transparent; color: var(--fg-dim); border: none;
  padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 500; }
.period-switch button.active { background: var(--accent); color: #1a0b04; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden; transition: transform 0.15s, border-color 0.15s; }
.kpi-card:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); opacity: 0.6; }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-mute); font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 700; margin: 4px 0 2px; font-family: var(--mono); }
.kpi-delta { font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.kpi-delta.pos { color: var(--green); }
.kpi-delta.neg { color: var(--red); }
.kpi-delta.zero { color: var(--fg-mute); }

/* cards / sections */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; margin: 0; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 8px 10px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--fg-mute); border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.num { font-family: var(--mono); text-align: right; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.ok { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge.warn { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.badge.err { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.badge.info { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.badge.muted { background: var(--bg-card-2); color: var(--fg-mute); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; font-size: 12px; font-weight: 600; border: 1px solid var(--border);
  background: var(--bg-card-2); color: var(--fg); text-decoration: none; cursor: pointer; transition: all 0.15s; }
.btn:hover { border-color: var(--accent); color: var(--accent-2); }
.btn.primary { background: var(--accent); color: #1a0b04; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); color: #1a0b04; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 11px; }
.btn.danger { color: var(--red); border-color: rgba(248,113,113,0.4); }

/* charts containers */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }
.chart-wrap.short { height: 200px; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: 30px repeat(24, 1fr); gap: 2px; font-size: 9px; color: var(--fg-mute); }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg-card-2); transition: transform 0.1s; cursor: pointer; }
.heat-cell:hover { transform: scale(1.4); z-index: 2; box-shadow: 0 0 0 1px var(--fg); }

/* chat */
.chat-shell { display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - 48px); }
.chat-history { overflow-y: auto; padding: 16px 0; }
.msg { padding: 10px 14px; border-radius: 12px; margin-bottom: 8px; max-width: 78%; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { background: var(--accent-soft); border: 1px solid var(--accent); margin-left: auto; }
.msg.assistant { background: var(--bg-card); border: 1px solid var(--border); }
.msg.tool { background: rgba(96,165,250,0.07); border: 1px dashed rgba(96,165,250,0.3); color: var(--fg-dim); font-size: 11px; font-family: var(--mono); }
.chat-input-row { display: flex; gap: 8px; padding: 12px 0 4px; border-top: 1px solid var(--border); }
.chat-input-row textarea { resize: none; min-height: 44px; max-height: 160px; }

/* status dots */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.err { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.warn { background: var(--yellow); }
.dot.idle { background: var(--fg-mute); }

/* alert banner */
.alert { padding: 12px 16px; border-radius: 10px; border: 1px solid; margin-bottom: 16px; font-size: 13px; }
.alert.warn { background: rgba(251,191,36,0.07); border-color: rgba(251,191,36,0.3); color: var(--yellow); }
.alert.err { background: rgba(248,113,113,0.07); border-color: rgba(248,113,113,0.3); color: var(--red); }

/* loading skeleton */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-card-2) 50%, var(--bg-card) 100%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* utility */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.text-sm { font-size: 12px; } .text-xs { font-size: 11px; }
.text-dim { color: var(--fg-dim); } .text-mute { color: var(--fg-mute); }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
