:root {
  --ink: #21282b;
  --menu: #21282b;
  --accent: #e94e26;
  --accent-dark: #d8431d;
  --hint: #e5e7eb;
  --bg: #f9f9f9;
  --card: #ffffff;
  --muted: #6b7280;
  --line: #e5e7eb;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-synthesis: none;
}
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, .brand { font-family: "Graphik LCG", Inter, "Segoe UI", sans-serif; }

/* ===== App shell: rail + sub + work + chat ===== */
.app { min-height: 100vh; display: flex; gap: 8px; padding: 12px; }

.rail, .sub { background: var(--menu); color: var(--hint); border-radius: var(--radius); display: flex; flex-direction: column; }

.rail { width: 72px; padding: 12px 8px; align-items: center; flex-shrink: 0; }
.rail-brand { margin: 4px 0 16px; display: grid; place-items: center; }
.rail-brand img { height: 28px; width: auto; display: block; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; flex: 1; align-items: center; }
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }

.icon-btn { border: 0; background: transparent; color: var(--hint); cursor: pointer; border-radius: 10px; display: grid; place-items: center; width: 44px; height: 44px; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.active { color: var(--accent); }
.icon-btn:hover { color: #fff; }
.rail-foot { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #3a4246; color: var(--hint); display: grid; place-items: center; font-size: 15px; font-weight: 600; }

.sub { width: 220px; padding: 16px 12px; flex-shrink: 0; }
.sub-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--hint); opacity: .7; margin: 4px 8px 12px; }
.sub nav { display: flex; flex-direction: column; gap: 2px; }
.sub .sublink { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--hint); text-decoration: none; font-size: 14px; background: transparent; border: 0; cursor: pointer; }
.sub .sublink:hover { color: #fff; }
.sub .sublink.active { color: #fff; background: rgba(255,255,255,.07); }
.sub-foot { margin-top: auto; padding: 12px 8px 4px; display: flex; flex-direction: column; gap: 8px; }
.sub-foot .who { font-size: 12px; color: var(--hint); opacity: .75; overflow-wrap: anywhere; }
.sub-foot select { width: 100%; }

.work { flex: 1; min-width: 0; background: var(--card); border-radius: var(--radius); padding: 12px 20px 20px; overflow: auto; display: flex; flex-direction: column; }
.page-title { font-size: 20px; margin: 4px 0 16px; font-weight: 700; }
.foot { font-size: 11px; color: var(--muted); margin-top: auto; padding-top: 14px; }

/* ===== Content components ===== */
.panel { background: var(--bg); border-radius: 12px; padding: 16px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 4px 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { line-height: 1.5; margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); }
.small { font-size: 12px; color: var(--muted); }
.subtle { color: var(--muted); font-size: 12px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.spaced { justify-content: space-between; }
.form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.stack .input, .stack select { width: 100%; }

input, select { padding: 9px 11px; border: 2px solid var(--bg); background: var(--bg); border-radius: 10px; min-width: 0; }
input:hover, select:hover { border-color: var(--line); }
input:focus, input:hover:focus, select:focus { outline: none; border-color: var(--accent); }
.input { flex: 1; min-width: 165px; }

.btn { padding: 9px 14px; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--accent-dark); }
.btn.ghost, .btn.alt { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover, .btn.alt:hover { border-color: var(--accent); color: var(--accent); }
.btn.red { background: #a94440; }
.btn.tiny { padding: 6px 10px; font-size: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

.card { background: var(--bg); border-radius: 12px; padding: 14px 16px; margin: 0 0 10px; }
.card strong { display: block; font-size: 18px; margin-bottom: 2px; }

.alert { border-radius: 10px; padding: 10px 13px; margin: 10px 0; background: var(--bg); color: var(--ink); font-size: 13px; }
.alert.error { background: #fae5e0; color: #9a3531; }
.alert.ok { background: #e1f3e8; color: #256346; }

.pill { font-size: 11px; border-radius: 50px; background: #dff1ea; color: #24684c; padding: 5px 9px; font-weight: 700; }
.warning { background: #fff3d9; color: #825900; }

.choice { width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 6px; }
.choice:hover { background: #fafafa; border-color: var(--accent); }

/* ===== Chat panel ===== */
.chat { width: 390px; flex-shrink: 0; background: var(--card); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 24px); position: sticky; top: 12px; }
.chathead { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chatscroll { overflow: auto; padding: 14px; flex: 1; min-height: 170px; }
.bubble { border-radius: 12px; padding: 12px; background: var(--bg); margin-bottom: 12px; overflow-wrap: anywhere; }
.bubble.user { margin-left: 38px; background: #f6e3db; }
.bubble h3 { margin-top: 0; }
.chatbottom { padding: 12px 14px; border-top: 1px solid var(--line); }

/* ===== Login ===== */
.loginwrap { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login { padding: 32px; width: min(440px, 100%); background: var(--card); border-radius: var(--radius); box-shadow: 0 5px 18px #243e4a08; }
.brandlogo { display: block; height: 44px; width: auto; max-width: 100%; margin: 0 auto 14px; }
.brandlogo.mini { height: 28px; width: auto; margin: 0; }
.login h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.02em; }
.login .login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.login .input { width: 100%; margin: 0 0 12px; }
.login .btn { width: 100%; margin-top: 8px; }
.login .brand { text-align: center; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 4px; }

.loading { color: var(--muted); }

/* ===== Responsive ===== */
@media (max-width: 1180px) { .chat { width: 340px; } }
@media (max-width: 960px) {
  .sub { display: none; }
  .chat { position: fixed; z-index: 5; right: 12px; top: 12px; bottom: 12px; max-height: none; width: min(430px, calc(100vw - 104px)); box-shadow: -15px 0 36px #163c3f38; }
  .work { padding: 12px 14px 14px; }
}
