/* FlowOps AI portal */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e5e7eb; --line-2: #eef0f3;
  --brand: #0f766e; --brand-2: #115e59; --brand-soft: #e6f4f2; --side: #0b1220; --side-ink: #cbd5e1; --side-mute: #64748b;
  --ok: #15803d; --ok-soft: #e8f5ec; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdecec; --info: #1d4ed8; --info-soft: #e9effd;
  --s1: #0f766e; --s2: #94a3b8; --s3: #f59e0b;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--ink-2); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; }
.org-switch { margin: 0 12px 12px; }
.org-switch select, .org-name { width: 100%; background: #111a2e; color: #e2e8f0; border: 1px solid #1e293b; border-radius: 8px; padding: 8px 10px; font: inherit; }
.org-name { display: block; }
.org-name small { display: block; color: var(--side-mute); font-size: 11px; }
.nav { padding: 4px 8px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--side-mute); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: #111a2e; text-decoration: none; color: #fff; }
.nav a.on { background: #13243b; color: #fff; }
.nav a.on .ico { color: #5eead4; }
.nav .ico { width: 18px; height: 18px; flex: none; color: #64748b; }
.nav .count { margin-left: auto; background: #f59e0b; color: #111; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.side-foot { border-top: 1px solid #1e293b; padding: 12px 16px; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .links { display: flex; gap: 14px; margin-top: 6px; }
.side-foot a, .side-foot button { color: var(--side-ink); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 32px 0; flex-wrap: wrap; }
.content { padding: 20px 32px 48px; max-width: 1360px; }
.menu-btn { display: none; }

/* ---------- panels ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta { font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }

/* ---------- attention strip ---------- */
.attention { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.att { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.att:hover { text-decoration: none; border-color: #cbd5e1; }
.att .n { font-size: 20px; font-weight: 700; min-width: 28px; }
.att.hot { background: var(--warn-soft); border-color: #f5d9a8; }
.att.bad { background: var(--bad-soft); border-color: #f5c2c2; }
.att span { font-size: 13px; color: var(--ink-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td.title a { font-weight: 600; color: var(--ink); }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- filters / tabs ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--ink-2); }
.chip:hover { text-decoration: none; border-color: #cbd5e1; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip b { font-weight: 600; margin-left: 4px; opacity: .7; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg a { padding: 6px 12px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a.on { background: var(--ink); color: #fff; }
.seg a:hover { text-decoration: none; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #99d5cd; border-color: var(--brand); }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 14px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #d1d5db; }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f1b5b5; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
form.inline { display: inline; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-weight: 500; }
.alert.ok { background: var(--ok-soft); color: #14532d; border: 1px solid #bfe3c9; }
.alert.bad { background: var(--bad-soft); color: #7f1d1d; border: 1px solid #f5c2c2; }
.alert.warn { background: var(--warn-soft); color: #78350f; border: 1px solid #f5d9a8; }

/* ---------- switch ---------- */
.switch-form { display: inline-flex; align-items: center; gap: 10px; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 0; background: #cbd5e1; cursor: pointer; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch.on { background: var(--brand); }
.switch.on::after { left: 21px; }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- agents ---------- */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.agent { display: flex; flex-direction: column; gap: 12px; }
.agent-top { display: flex; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #0f766e, #14b8a6); flex: none; }
.avatar.paused { background: #94a3b8; }
.agent-name { font-weight: 700; font-size: 15px; }
.agent-role { color: var(--muted); font-size: 13px; }
.agent-metrics { display: flex; gap: 20px; }
.agent-metrics div b { display: block; font-size: 18px; }
.agent-metrics div span { font-size: 12px; color: var(--muted); }
.agent-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line-2); padding-top: 12px; margin-top: auto; font-size: 12px; color: var(--muted); }
.mini-agents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-agent { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--ink); }
.mini-agent:hover { background: #f8fafc; text-decoration: none; }
.mini-agent .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.mini-agent small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- charts ---------- */
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #eef0f3; stroke-width: 1; }
.chart .axis { fill: #94a3b8; font-size: 10px; }
.chart .s1, .legend .s1 { fill: var(--s1); background: var(--s1); }
.chart .s2, .legend .s2 { fill: var(--s2); background: var(--s2); }
.chart .s3, .legend .s3 { fill: var(--s3); background: var(--s3); }
.legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ring { width: 92px; height: 92px; }
.ring-bg { fill: none; stroke: #eef0f3; stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 10; stroke-linecap: round; }
.ring-text { font-size: 16px; font-weight: 700; fill: var(--ink); }
.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%}.w95{width:95%}.w100{width:100%}

/* ---------- feed / timeline ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed .who { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; text-transform: uppercase; }
.feed .what { flex: 1; min-width: 0; }
.feed .when { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- details ---------- */
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; }
.transcript { display: flex; flex-direction: column; gap: 10px; max-height: 640px; overflow-y: auto; padding-right: 4px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.bubble.ai { background: var(--brand-soft); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { background: #f1f5f9; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
audio { width: 100%; margin: 4px 0 12px; }
.preview { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: #fff; }
.preview img { max-width: 100%; border-radius: 8px; }
.post { border: 1px solid var(--line); border-radius: 10px; padding: 14px; white-space: pre-wrap; }
.post .plat { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; white-space: normal; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 10% 10%, #134e4a 0%, #0b1220 60%); color: #e2e8f0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art .brand { padding: 0; font-size: 18px; }
.auth-art h2 { font-size: 32px; line-height: 1.2; letter-spacing: -.02em; color: #fff; max-width: 460px; margin: 0 0 16px; }
.auth-art p { color: #94a3b8; max-width: 440px; font-size: 15px; }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; color: #cbd5e1; }
.auth-art li::before { content: "✓"; color: #5eead4; margin-right: 10px; font-weight: 700; }
.auth-form { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }

@media (max-width: 1100px) {
  .g4, .attention { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .fields, .mini-agents { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  dl.kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 30px; }
}
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.fields { display: grid; }
.btn.menu-btn { display: none; }
.grid > .card + .card { margin-top: 0; }
.bar-track, .bar-fill { display: block; }
@media (max-width: 820px) { .btn.menu-btn { display: inline-flex; } }
.agents > .card + .card { margin-top: 0; }
@media (min-width: 821px) { .shell { background: linear-gradient(to right, var(--side) 248px, var(--bg) 248px); } }
.menu-btn .ico { width: 18px; height: 18px; }
