/* Agency City + Customer Portal application styles. City = dark command center; portal = light. */
:root {
  --bg: #0b0f17; --panel: #121826; --panel-2: #182033; --line: #24304a; --text: #e6ebf5; --muted: #8b98b3;
  --brand: #0F766E; --accent: #F2A93B; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #38bdf8;
  --radius: 10px; --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.portal-theme { --bg: #f6f7fb; --panel: #ffffff; --panel-2: #f1f3f9; --line: #e3e7f0; --text: #111827; --muted: #5b6475; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.mono, pre { font-family: var(--mono); font-size: 12px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

.sim-banner { background: repeating-linear-gradient(45deg, #b45309, #b45309 12px, #92400e 12px, #92400e 24px); color: #fff;
  text-align: center; font-weight: 800; letter-spacing: .2em; padding: 4px 8px; font-size: 12px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 10; }
.topbar .brand { font-weight: 800; letter-spacing: .02em; color: var(--text); white-space: nowrap; }
.topbar .brand small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .crumbs .world { color: var(--muted); font-weight: 600; }
.topbar .crumbs a { color: var(--text); }
.city-switcher { position: relative; font-size: 12px; }
.city-switcher summary { cursor: pointer; color: var(--muted); list-style: none; padding: 3px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel-2); white-space: nowrap; }
.city-switcher ul { position: absolute; top: 28px; left: 0; z-index: 30; margin: 0; padding: 8px 12px; list-style: none;
  min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.city-switcher li { padding: 4px 0; }
.city-switcher small, .city-switcher .disabled { color: var(--muted); }
.breadcrumb { margin: 0 0 4px; }
.badge.not_active, .badge.idle { background: transparent; border-color: var(--line); color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill.hot { color: #fff; background: var(--bad); border-color: var(--bad); }
.pill.attn { color: #111; background: var(--warn); border-color: var(--warn); }
.layout { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 50px); }
.sidenav { border-right: 1px solid var(--line); padding: 12px 8px; background: var(--panel); }
.sidenav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--muted); }
.sidenav a.active, .sidenav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.main { padding: 20px; min-width: 0; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.nodata { color: var(--muted); font-weight: 600; font-size: 13px; letter-spacing: .04em; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 4px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.badge.green, .badge.pass, .badge.complete, .badge.connected, .badge.executed, .badge.succeeded, .badge.paid, .badge.qualified,
.badge.delivered, .badge.won, .badge.sent, .badge.approved, .badge.active { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.4); color: #4ade80; }
.badge.yellow, .badge.amber, .badge.warning, .badge.pending, .badge.pending_approval, .badge.waiting, .badge.queued,
.badge.degraded, .badge.notice, .badge.attention { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.4); color: #fbbf24; }
.badge.orange, .badge.high { background: rgba(249,115,22,.18); border-color: rgba(249,115,22,.45); color: #fb923c; }
.badge.red, .badge.fail, .badge.failed, .badge.blocked, .badge.error, .badge.critical, .badge.lost, .badge.auth_expired,
.badge.rejected, .badge.blocked_connector, .badge.blocked_policy { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.45); color: #f87171; }
.badge.black { background: #000; color: #fff; border-color: #444; }
.badge.not_configured, .badge.simulated, .badge.info { background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.35); color: #7dd3fc; }
.portal-theme .badge.green, .portal-theme .badge.approved, .portal-theme .badge.paid { color: #15803d; }
.portal-theme .badge.pending, .portal-theme .badge.open { color: #b45309; }

form.inline { display: inline; margin: 0 4px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; }
textarea { min-height: 90px; resize: vertical; }
textarea.mono { font-family: var(--mono); font-size: 12px; min-height: 160px; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid transparent; background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { filter: brightness(1.1); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--panel-2); color: var(--text); border-color: var(--line); }
button.ok { background: #16a34a; } button.danger { background: #dc2626; } button.warn { background: #d97706; }
button.small { padding: 3px 9px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* City map */
.city-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.city-svg { width: 100%; height: auto; background: radial-gradient(ellipse at top, #121a2e, #0b0f17 70%); border: 1px solid var(--line);
  border-radius: var(--radius); }
.city-svg .road { stroke: #1d2740; stroke-width: 14; fill: none; }
.city-svg .bldg rect { fill: #151d31; stroke: #2a3757; stroke-width: 1.5; rx: 6; transition: fill .15s ease; }
.city-svg .bldg:hover rect, .city-svg .bldg:focus rect { fill: #1d2742; stroke: var(--accent); }
.city-svg .bldg text { fill: #dbe3f4; font-size: 10.5px; font-weight: 600; pointer-events: none; }
.city-svg .bldg text.sub { fill: #8b98b3; font-size: 9px; font-weight: 500; }
.city-svg .status-dot { stroke: #0b0f17; stroke-width: 2; }
.st-ACTIVE { fill: var(--ok); } .st-ATTENTION { fill: var(--bad); } .st-NO-DATA-YET { fill: #475569; }
.st-CONNECTOR-NOT-CONFIGURED { fill: var(--info); }
.feed { max-height: 560px; overflow: auto; }
.feed .item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed .item small { color: var(--muted); display: block; }
.bldg-list { display: none; }
.floor { border-left: 2px solid var(--line); padding-left: 12px; margin: 12px 0; }
.office { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; }

/* Approvals */
.approval { border-left: 4px solid var(--warn); }
.approval.risk-RED { border-left-color: var(--bad); } .approval.risk-ORANGE { border-left-color: #f97316; }
.approval .why { white-space: pre-wrap; }
.approval details { margin-top: 8px; }

/* Drago */
.drago { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 170px); min-height: 420px; }
.drago .log { overflow: auto; padding: 4px; }
.msg { max-width: 860px; padding: 10px 14px; border-radius: 12px; margin: 8px 0; white-space: pre-wrap; }
.msg.you { background: var(--brand); color: #fff; margin-left: auto; max-width: 600px; }
.msg.bot { background: var(--panel-2); border: 1px solid var(--line); }
.msg .links a { margin-right: 10px; }
.drago form { display: flex; gap: 8px; padding-top: 10px; }
.drago input { flex: 1; }
.mic.listening { background: var(--bad); }

/* Portal */
.portal-shell { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.timeline { display: flex; gap: 0; margin: 10px 0 4px; flex-wrap: wrap; }
.timeline .step { flex: 1; min-width: 110px; padding: 8px 6px; border-top: 4px solid var(--line); font-size: 12px; color: var(--muted); }
.timeline .step.done { border-top-color: var(--accent); color: var(--text); }
.timeline .step.current { border-top-color: var(--brand); color: var(--text); font-weight: 700; }
.progress { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.login-box { max-width: 380px; margin: 10vh auto; }
.error-text { color: var(--bad); }
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

@media (max-width: 1000px) {
  .city-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: none; position: fixed; inset: 50px 0 0 0; z-index: 20; overflow: auto; }
  .sidenav.open { display: block; }
  .nav-toggle { display: inline-block; }
  .main { padding: 14px; }
  .city-svg { display: none; }
  .bldg-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .kv { grid-template-columns: 1fr; }
  .topbar .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
