/* InnoSafe AI Office — luxury theme: deep emerald & navy, gold accents, serif headings. */
:root {
  --navy: #0b1a2e; --navy2: #12263f; --emerald: #0e3b31; --emerald2: #15513f;
  --gold: #c9a54a; --gold2: #e3c77a; --gold-dark: #8f7126;
  --bg: #f6f3ec; --card: #fffdf8; --text: #1a2230; --muted: #6b6f78; --line: #e6dfcf;
  --red: #a3282b; --orange: #b8742a; --ok: #1f6b4f;
  --serif: "Playfair Display", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-family: var(--sans); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--emerald2); text-decoration-color: var(--gold); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; margin: 0 0 .6rem; color: var(--navy); }
h2 { font-size: 1.9rem; }
h2::after { content: ""; display: block; width: 56px; height: 2px; margin-top: 8px; background: linear-gradient(90deg, var(--gold), transparent); }
h3 { font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(ellipse at 20% 0%, var(--emerald2) 0%, var(--emerald) 35%, var(--navy) 100%); }
.login-card { background: var(--card); padding: 40px 28px 32px; border-radius: 4px; width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
  border: 1px solid var(--gold); outline: 1px solid rgba(201,165,74,.35); outline-offset: 6px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login-card label { text-align: left; }
.login-card h1 { font-size: 2rem; }
.login-card h1 span, .brand span { color: var(--gold); font-style: italic; }
.login-card .muted { font-family: var(--serif); font-style: italic; letter-spacing: .08em; }
.crest { font-style: normal; width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--gold); color: var(--gold); font-family: var(--serif); font-size: 1.6rem; font-weight: 600;
  background: radial-gradient(circle, var(--emerald) 0%, var(--navy) 100%); box-shadow: inset 0 0 0 4px var(--navy), inset 0 0 0 5px rgba(201,165,74,.5); }
.rule { height: 1px; width: 120px; margin: 0 auto; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
label { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--navy2); }
input, select, textarea { font: inherit; font-size: .95rem; letter-spacing: 0; text-transform: none; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 3px; background: #fff; width: 100%; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,165,74,.2); }
textarea { min-height: 120px; resize: vertical; text-transform: none; }
.msg { min-height: 1.2em; margin: 0; font-size: .9rem; }

/* Buttons */
.btn { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 9px 16px; border-radius: 3px; cursor: pointer; letter-spacing: .03em; transition: all .15s; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--emerald2), var(--emerald)); color: #fff; border-color: var(--gold-dark); font-weight: 600; }
.btn.primary:hover { box-shadow: 0 0 0 1px var(--gold), 0 6px 18px rgba(14,59,49,.3); }
.btn.warn { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: var(--navy); border-color: var(--gold-dark); font-weight: 600; }
.btn.danger { color: var(--red); border-color: #e7c9c9; }
.btn.link { background: none; border: none; color: var(--emerald2); text-decoration: underline; text-decoration-color: var(--gold); padding: 4px; font-size: .85rem; }
.btn.small { padding: 5px 11px; font-size: .82rem; }
.btn.icon { background: none; border: none; color: var(--gold); font-size: 1.3rem; }
.btn:disabled { opacity: .5; cursor: wait; }
.topbar .btn.small { background: transparent; color: var(--gold2); border-color: rgba(201,165,74,.5); }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(90deg, var(--navy) 0%, var(--emerald) 100%); color: #fff; border-bottom: 1px solid var(--gold-dark); }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; flex: 1; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.brand .crest { width: 34px; height: 34px; font-size: .95rem; margin: 0; box-shadow: none; }
.me { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: #d9d2bf; }
#menuBtn { display: none; }
.nav { background: var(--navy); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--gold-dark); }
.nav a { padding: 10px 14px; border-radius: 2px; text-decoration: none; color: #d9d2bf; font-size: .92rem; letter-spacing: .03em; border-left: 2px solid transparent; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav a.active { color: var(--gold2); border-left-color: var(--gold); background: linear-gradient(90deg, rgba(201,165,74,.14), transparent); }
.nav .nav-sep { height: 1px; margin: 10px 14px; background: linear-gradient(90deg, rgba(201,165,74,.5), transparent); }
.view { padding: 28px 20px 48px; max-width: 1120px; width: 100%; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  #menuBtn { display: block; }
  .nav { display: none; border-right: none; border-bottom: 1px solid var(--gold-dark); }
  .nav.open { display: flex; }
  .me span { display: none; }
  h2 { font-size: 1.5rem; }
}

/* Cards & grids */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 2px solid var(--gold); border-radius: 3px; padding: 18px 20px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(11,26,46,.04), 0 8px 24px rgba(11,26,46,.05); }
.stat .num { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--emerald); }
.stat .lbl { color: var(--muted); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: #ece6d7; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald2), var(--gold)); }
.bar.warn > i { background: linear-gradient(90deg, var(--gold), var(--orange)); }
.bar.bad > i { background: var(--red); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.banner { padding: 12px 16px; border-radius: 3px; margin-bottom: 12px; border: 1px solid; border-left-width: 4px; background: var(--card); }
.banner.warning { border-color: #e9d9a6; border-left-color: var(--gold); }
.banner.escalation { border-color: #ebcfae; border-left-color: var(--orange); }
.banner.hard_stop, .banner.daily_cap { border-color: #e7c9c9; border-left-color: var(--red); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 2px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: #efe9da; color: var(--navy2); }
.badge.on { background: #e1efe8; color: var(--ok); } .badge.off { background: #f0eee9; color: #8a8a8a; }
.badge.human { background: #f6e3e3; color: var(--red); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gold-dark); font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-size: .95rem; font-weight: 400; }
.switch b { font-family: var(--serif); font-size: 1.05rem; color: var(--navy); }
.switch input { width: auto; transform: scale(1.4); accent-color: var(--emerald); }
.agent-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.agent-item { cursor: pointer; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 3px; padding: 14px; font: inherit; transition: all .15s; }
.agent-item b { font-family: var(--serif); font-size: 1.15rem; color: var(--navy); }
.agent-item:hover { border-color: var(--gold); box-shadow: 0 6px 18px rgba(11,26,46,.08); transform: translateY(-1px); }
.chatlog { background: #f3efe4; border: 1px solid var(--line); border-radius: 3px; padding: 12px; max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { padding: 9px 13px; border-radius: 12px; max-width: 85%; white-space: pre-wrap; font-size: .93rem; }
.bubble.user { align-self: flex-end; background: var(--emerald); color: #fff; border-bottom-right-radius: 3px; }
.bubble.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble .who { display: block; font-size: .7rem; opacity: .7; margin-bottom: 2px; }
details summary { cursor: pointer; padding: 6px 0; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; border: 1px solid var(--gold); padding: 11px 18px; border-radius: 3px; z-index: 50; max-width: 90vw; }
.help { background: #f1ecdf; border-left: 3px solid var(--gold); border-radius: 2px; padding: 10px 14px; font-size: .88rem; color: #3c4250; }

/* Brand logo placements */
.loading { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, var(--bg) 70%); padding: 24px 16px; }
.loading-logo { width: min(320px, 70vw); animation: breathe 2.2s ease-in-out infinite; }
.loading p { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0; }
.loading-bar { width: min(220px, 60vw); height: 2px; background: var(--line); overflow: hidden; }
.loading-bar i { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--gold), transparent); animation: slide 1.2s linear infinite; }
@keyframes breathe { 50% { transform: scale(1.03); opacity: .85; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .loading-logo, .loading-bar i { animation: none; } }
.login-logo { width: 100%; max-width: 260px; margin: 0 auto 2px; display: block; }
.topbar-logo { height: 34px; width: auto; display: block; }
.brand-sub { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 1.15rem; padding-left: 12px; border-left: 1px solid rgba(201,165,74,.5); }
@media (max-width: 760px) { .topbar-logo { height: 26px; } .brand-sub { font-size: .95rem; padding-left: 8px; } }

/* Office View */
.office-wrap { position: relative; overflow-x: auto; border: 1px solid var(--gold); border-radius: 3px; overflow: hidden; box-shadow: 0 10px 30px rgba(11,26,46,.15); background: #0d2f43; }
canvas.office { display: block; width: 100%; min-width: 640px; aspect-ratio: 320 / 200; image-rendering: pixelated; }
.office-tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; border: 1px solid var(--gold); padding: 8px 10px; border-radius: 3px; font-size: .82rem; max-width: 240px; z-index: 5; }
.office-tip b { font-family: var(--serif); color: var(--gold2); font-size: .95rem; }
.office-tip em { color: #ffb4a8; font-style: normal; }
