:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #152033;
  --muted: #64718a;
  --line: #dfe4ee;
  --primary: #146ef5;
  --primary-strong: #0e55bf;
  --good: #0f9d58;
  --warn: #b7791f;
  --danger: #c53030;
  --shadow: 0 12px 40px rgba(21, 32, 51, .08);
}

[data-theme="dark"] {
  --bg: #10141f;
  --panel: #171d2b;
  --text: #eef3ff;
  --muted: #a5afc4;
  --line: #2c3447;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}
button:hover { background: var(--primary-strong); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
}
.hidden { display: none !important; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
}
.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vw;
  background: linear-gradient(135deg, #0d9488, #146ef5);
  color: white;
}
.brand-panel h1 { font-size: clamp(48px, 8vw, 96px); margin: 20px 0 10px; letter-spacing: 0; }
.brand-panel p { max-width: 560px; font-size: 20px; line-height: 1.55; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  background: white;
  color: #146ef5;
  font-weight: 900;
  font-size: 42px;
}
.brand-mark.small {
  width: 36px;
  height: 36px;
  font-size: 20px;
  background: var(--primary);
  color: white;
}
.auth-card {
  align-self: center;
  width: min(420px, calc(100% - 32px));
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.tabs, .row, .toolbar, .inline-form, .top-actions, .brand-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.tab.active { color: white; background: var(--primary); }
.auth-form, .panel-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.subtle-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.message, .toast, #userLine { color: var(--muted); }
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.brand-row { margin-bottom: 22px; }
.nav {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  margin: 3px 0;
  background: transparent;
  color: var(--muted);
}
.nav.active, .nav:hover {
  color: white;
  background: var(--primary);
}
.workspace { min-width: 0; padding: 20px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.topbar h2 { margin: 0; }
.icon-btn {
  width: 42px;
  padding: 0;
}
.view { display: none; }
.active-view { display: block; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat, .chart-wrap, .list, .card, .panel-form, .inline-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat { padding: 18px; }
.stat span { color: var(--muted); display: block; }
.stat strong { font-size: 32px; }
.chart-wrap { padding: 16px; min-height: 320px; }
.toolbar, .inline-form {
  padding: 12px;
  margin-bottom: 12px;
}
.toolbar input { max-width: 320px; }
.list {
  overflow: hidden;
}
.item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item small { color: var(--muted); }
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.item-actions button { min-height: 32px; }
.panel-form { padding: 16px; max-width: 860px; }
.editor {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  padding: 16px;
}
.locked {
  opacity: .62;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
@media (max-width: 860px) {
  .auth-shell, .app { grid-template-columns: 1fr; }
  .brand-panel { min-height: 34vh; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
  .brand-row { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar, .toolbar, .inline-form { align-items: stretch; flex-direction: column; }
}
