:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #1a2233;
  --border: #24304a;
  --text: #e6ecf5;
  --muted: #8494ad;
  --accent: #2f7df6;
  --accent-2: #4a9cff;
  --ok: #27c06c;
  --bad: #e5484d;
  --warn: #f0a020;
  --info: #38bdf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* Login */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-brand { text-align: center; margin-bottom: 10px; }
.login-brand h1 { margin: 8px 0 4px; font-size: 20px; }
.login-brand p { margin: 0; font-size: 12px; }

.brand-mark {
  width: 46px; height: 46px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px;
}
.brand-mark.small { width: 28px; height: 28px; font-size: 13px; border-radius: 7px; margin: 0; }

label { font-size: 12px; color: var(--muted); }

input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 6px;
}
button:hover { background: var(--accent-2); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: 0;
  padding: 6px 12px;
}
.ghost-btn:hover { border-color: var(--accent); background: transparent; }

.error { color: var(--bad); font-size: 12px; text-align: center; }

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

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.disabled { opacity: 0.45; cursor: not-allowed; }
.nav-link.disabled:hover { background: transparent; color: var(--muted); }

.sidebar-foot { margin-top: auto; font-size: 11px; }

.main { flex: 1; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar h2 { margin: 0; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.view { padding: 24px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.kv {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge.ok { background: rgba(39,192,108,0.15); color: var(--ok); }
.badge.bad { background: rgba(229,72,77,0.15); color: var(--bad); }
.badge.warn { background: rgba(240,160,32,0.15); color: var(--warn); }
.badge.info { background: rgba(56,189,248,0.15); color: var(--info); }
.badge.muted { background: rgba(132,148,173,0.15); color: var(--muted); }


/* Chat (UI-4) */
.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 180px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.msg { padding: 10px 12px; border-radius: 8px; max-width: 85%; }
.msg-user { align-self: flex-end; background: var(--panel-2); border: 1px solid var(--border); }
.msg-agent { align-self: flex-start; background: rgba(47,125,246,0.10); border: 1px solid var(--accent); }
.msg-system { align-self: flex-start; background: rgba(132,148,173,0.10); border: 1px solid var(--border); }
.msg-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 11px; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; margin-top: 0; }
.chat-form button { margin-top: 0; }
.badge.role-user { background: rgba(56,189,248,0.15); color: var(--info); }
.badge.role-agent { background: rgba(47,125,246,0.15); color: var(--accent-2); }
.badge.role-system { background: rgba(132,148,173,0.15); color: var(--muted); }

/* Notifications (UI-4) */
.notif-badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); }
.notif-title { font-weight: 600; margin-bottom: 2px; }
.notif-critical { border-left: 3px solid var(--bad); }
.notif-warning { border-left: 3px solid var(--warn); }
.notif-success { border-left: 3px solid var(--ok); }
.notif-info { border-left: 3px solid var(--info); }

/* Operations (UI-5) */
.op-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.op-form-row { display: flex; flex-direction: column; gap: 4px; }
.op-form-row select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
}
.op-form button { margin-top: 0; }
.op-actions { display: flex; gap: 10px; margin-top: 12px; }
.op-actions button { margin-top: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }
.kv-list { margin-bottom: 8px; }
