:root {
  --bg: #0b0c0f;
  --panel: #14161c;
  --border: #2a2e38;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #ff7f36;
  --accent2: #3dcf7a;
  --danger: #ff4d6a;
  --radius: 12px;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1a120c, transparent),
    radial-gradient(900px 500px at 100% 0%, #0f1a14, transparent), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.view { min-height: 100vh; }
.muted { color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}
.login-card {
  max-width: 420px;
  margin: 12vh auto;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.login-card h1 { margin: 0.2rem 0 0.5rem; font-size: 1.75rem; }
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
input, select, button, textarea {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0e1015;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}
button {
  background: linear-gradient(145deg, #ff9a4a, var(--accent));
  color: #111;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger {
  background: linear-gradient(145deg, #ff7a8c, var(--danger));
  color: #fff;
}
button.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}
button.tab.active {
  color: #111;
  background: var(--accent);
}
.err { color: var(--danger); font-size: 0.9rem; }
.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20,22,28,.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top nav { display: flex; gap: 0.35rem; flex: 1; justify-content: center; }
.top-right { display: flex; align-items: center; gap: 0.75rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.row-head { display: flex; justify-content: space-between; align-items: center; }
.case-list { display: grid; gap: 0.75rem; }
.case-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.case-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.case-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.hot { border-color: var(--danger); color: #ffb3bf; }
.badge.ir { border-color: #f0c14b; color: #f0c14b; }
.badge.ok { border-color: var(--accent2); color: var(--accent2); }
.form-grid { display: grid; gap: 0.75rem; max-width: 480px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}
.case-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  margin-top: 0.5rem;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin: 0.5rem 0 1rem;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.check-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.45rem 0;
  border-bottom: 1px solid #1c1f27;
  font-size: 0.92rem;
}
.callout {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #3a2a1c;
  background: #1a140f;
  color: #ffd2b0;
  font-size: 0.9rem;
}
.code {
  background: #0a0b0e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  overflow: auto;
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 60vh;
}
.code.small { max-height: 220px; }
.events { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.events li {
  padding: 0.45rem 0;
  border-bottom: 1px solid #1c1f27;
  color: var(--muted);
}
.events strong { color: var(--text); }

/* HA assistant */
.ha-btn {
  background: linear-gradient(145deg, #ff9a4a, var(--accent)) !important;
  color: #111 !important;
  border: 0 !important;
  font-weight: 700;
}
.ha-shell { position: relative; z-index: 2147483000; }
.ha-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483646;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 2px solid #ffb088;
  background: linear-gradient(145deg, #ff9a4a, #ff5a00);
  color: #111;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 12px 40px rgba(255, 90, 0, 0.45);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.ha-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  display: block;
}
.ha-dot.on { background: #3dcf7a; box-shadow: 0 0 8px #3dcf7a; }
.ha-panel {
  position: fixed;
  right: 18px;
  bottom: 96px;
  width: min(420px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 120px));
  background: #12141a;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483645;
}
.ha-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: #181b22;
}
.ha-head-actions { display: flex; gap: 0.35rem; }
.ha-status {
  font-size: 0.75rem;
  padding: 0.4rem 0.9rem;
  color: var(--muted);
  border-bottom: 1px solid #1c1f27;
}
.ha-status[data-kind="ok"] { color: var(--accent2); }
.ha-status[data-kind="warn"] { color: #f0c14b; }
.ha-status[data-kind="busy"] { color: var(--accent); }
.ha-case-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: #1a140f;
  border-bottom: 1px solid #3a2a1c;
  font-size: 0.8rem;
  color: #ffd2b0;
}
.ha-msgs {
  flex: 1;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.ha-bubble {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}
.ha-bubble.user {
  align-self: flex-end;
  background: #2a2118;
  border: 1px solid #4a3520;
}
.ha-bubble.bot, .ha-bubble.system {
  align-self: flex-start;
  background: #161a22;
  border: 1px solid var(--border);
}
.ha-bubble.typing { opacity: 0.7; font-style: italic; }
.ha-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid #1c1f27;
}
.ha-chips button {
  font-size: 0.72rem;
  padding: 0.3rem 0.5rem;
  background: #1a1e28;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 600;
}
.ha-form {
  display: flex;
  gap: 0.45rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border);
  background: #0e1015;
}
.ha-form textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
}
.ha-form button { align-self: flex-end; }
