:root {
  --bg: #212121;
  --sidebar: #171717;
  --sidebar-hover: #2b2b2b;
  --surface: #2f2f2f;
  --surface-hover: #3a3a3a;
  --text: #ececec;
  --muted: #a8a8a8;
  --border: #424242;
  --brand-green: #18b414;
  --brand-red: #f41418;
  --accent: #087d0b;
  --accent-hover: #066b09;
  --danger: #f05a5d;
  --warning: #e6a23c;
  --success: #49b99a;
  --sidebar-width: 280px;
  --content-width: 980px;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  color-scheme: dark;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button, input, textarea { font: inherit; }
button { letter-spacing: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  padding: 12px 10px;
  background: var(--sidebar);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
}

.brand {
  min-height: 52px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; }
.brand div > span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.brand-logo-crop {
  width: 44px;
  height: 38px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  background: #fff;
}
.brand-logo-crop img {
  display: block;
  width: auto;
  max-width: none;
  height: 38px;
}
.brand-name {
  font-family: Arial, "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}
.brand-name span { display: inline; }
.brand-med { color: var(--brand-red); }
.brand-onix { color: var(--brand-green); }
.brand-ai { margin-left: 5px; color: var(--text); font-weight: 700; }
.user-select { width: auto; min-height: 24px; margin: 3px 0 1px; border: 0; padding: 0 20px 0 0; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.current-user-name { display: block; margin-top: 3px; color: var(--text); font-size: 13px; font-weight: 600; }
.logout-link { border: 0; padding: 1px 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; text-align: left; }
.logout-link:hover { color: var(--text); }

.side-nav { display: grid; gap: 4px; }
.tab {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.tab:hover, .tab.is-active { background: var(--sidebar-hover); }
.tab > span:first-child { width: 18px; color: var(--muted); text-align: center; }
.tab.is-active > span:first-child { color: var(--accent); }

.sidebar-history {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-top: 1px solid #303030;
  padding-top: 12px;
}
.sidebar-section-title {
  padding: 0 9px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-section-title h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.sidebar-section-title span { color: var(--muted); font-size: 12px; }
.history-list { min-height: 0; overflow-y: auto; padding-right: 2px; }
.history-item {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: #d6d6d6;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item:hover, .history-item.is-current { background: var(--sidebar-hover); color: #fff; }
.history-empty { padding: 10px; color: var(--muted); font-size: 13px; }

.sidebar-footer {
  min-height: 42px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-top: 1px solid #303030;
  color: var(--muted);
  font-size: 13px;
}
.sidebar-footer > div { min-width: 0; }
.sidebar-footer strong, .sidebar-footer div > span { display: block; }
.sidebar-footer strong { color: var(--text); font-size: 12px; font-weight: 600; }
.sidebar-footer div > span { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.25; }
.sidebar-footer.has-error .status-dot { background: var(--danger); }
.sidebar-footer.is-syncing .status-dot { background: var(--warning); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: 64px minmax(0, 1fr); }
.topbar {
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #2d2d2d;
  background: rgba(33, 33, 33, 0.95);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: 0; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 6px; }

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
}
.icon-button:hover { background: var(--surface); color: var(--text); }
.mobile-only { display: none; }

main { min-height: 0; }
.panel { display: none; height: 100%; min-height: 0; }
.panel.is-active { display: grid; }
#chatPanel { grid-template-rows: minmax(0, 1fr) auto; }
#settingsPanel { display: none; overflow-y: auto; align-content: start; }
#settingsPanel.is-active { display: grid; }
#ideasPanel, #analysisIdeasPanel, #dataQualityPanel { grid-template-rows: auto minmax(0, 1fr); }

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 28px max(24px, calc((100% - var(--content-width)) / 2)) 42px;
  scroll-behavior: smooth;
}
.message {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto 26px;
  line-height: 1.55;
}
.message.user {
  width: fit-content;
  max-width: min(720px, 85%);
  margin-right: 0;
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--surface);
}
.message.assistant { padding: 0 4px; }
.message.system {
  margin-bottom: 24px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.message h3 { margin: 0 0 8px; font-size: 18px; line-height: 1.35; letter-spacing: 0; }
.message p { margin: 0 0 10px; white-space: pre-line; }
.insights, .actions { margin: 10px 0 0; padding-left: 22px; }
.actions { color: #c8c8c8; }
.calculation-details, .comparison-controls {
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.calculation-details summary, .comparison-controls summary {
  min-height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}
.calculation-details summary::-webkit-details-marker,
.comparison-controls summary::-webkit-details-marker { display: none; }
.calculation-details summary::before, .comparison-controls summary::before { content: "▸"; }
.calculation-details[open] summary::before, .comparison-controls[open] summary::before { content: "▾"; }
.calculation-body, .comparison-body { padding: 0 12px 12px; }
.calculation-body { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 12px 20px; }
.calculation-body strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 12px; }
.calculation-body ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.comparison-body > p { margin: 0; color: var(--muted); font-size: 12px; }
.detailed-report-actions { margin-top: 14px; display: flex; }
.detailed-report-button {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.detailed-report-button:hover { background: var(--surface-hover); border-color: #666; }
.detailed-report-button:disabled { cursor: progress; opacity: .6; }
.thinking-message {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking 1.1s ease-in-out infinite;
  animation-delay: calc(var(--dot-index) * 0.16s);
}
@keyframes thinking { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.report-table {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #252525;
}
.report-toolbar {
  min-height: 48px;
  padding: 8px 10px 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.report-toolbar h4 { margin: 0; font-size: 14px; letter-spacing: 0; }
.table-controls { padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: end; gap: 9px; border-bottom: 1px solid var(--border); background: var(--surface); }
.table-control { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.table-control input, .table-control select { width: auto; min-width: 130px; min-height: 34px; border: 1px solid var(--border); border-radius: 7px; padding: 0 9px; background: var(--bg); color: var(--text); }
.table-search { flex: 1 1 220px; }
.table-search input { width: 100%; }
.table-loading { margin-left: auto; align-self: center; color: var(--muted); font-size: 12px; }
.export-button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.export-button:hover { background: var(--surface-hover); }
.export-button:disabled { cursor: progress; opacity: .55; }
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll-top { width: 100%; height: 13px; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--border); }
.table-scroll-top > div { height: 1px; }
table { width: 100%; min-width: 620px; border-collapse: collapse; background: #252525; }
th, td { padding: 10px 12px; border-bottom: 1px solid #3b3b3b; text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: #2b2b2b; color: var(--muted); font-size: 12px; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #2a2a2a; }
.table-pagination { min-height: 48px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.pagination-actions { display: flex; align-items: center; gap: 6px; }
.pagination-actions button { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--text); cursor: pointer; }
.pagination-actions button:disabled { opacity: .35; cursor: default; }
.page-input { width: 58px !important; min-width: 58px !important; min-height: 32px !important; text-align: center; }
.patient-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: #7dcfb6;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.patient-link:hover { color: #9ee2cd; text-decoration: underline; }

.composer-shell {
  padding: 10px max(24px, calc((100% - 820px) / 2)) 14px;
  background: linear-gradient(180deg, rgba(33,33,33,0), var(--bg) 25%);
}
.composer {
  min-height: 54px;
  padding: 7px 7px 7px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid #555;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 22px rgba(0,0,0,.18);
}
.composer:focus-within { border-color: #6d6d6d; }
.composer textarea {
  min-height: 38px;
  max-height: calc(1.5em * 5 + 12px);
  flex: 1;
  border: 0;
  padding: 8px 0 6px;
  resize: none;
  overflow-y: hidden;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
}
.composer textarea::placeholder { color: #989898; }
.send-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f4f4f4;
  color: #171717;
  cursor: pointer;
  font-size: 21px;
  font-weight: 700;
}
.send-button:hover { background: #fff; }
.send-button:disabled { cursor: progress; opacity: .45; }
.composer-note { margin: 7px 0 0; color: #888; text-align: center; font-size: 11px; }

.section-header {
  padding: 28px max(24px, calc((100% - var(--content-width)) / 2)) 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #303030;
}
.section-header h2 { margin: 0; font-size: 22px; letter-spacing: 0; }
.section-header p { margin: 4px 0 0; color: var(--muted); }
.counter, .pill { padding: 5px 9px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; }
.settings-layout, .sync-summary, .list, .ideas-content { width: min(var(--content-width), calc(100% - 48px)); margin: 0 auto; }
.settings-layout { padding: 24px 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.settings-form, .item { padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: #282828; }
.settings-form h3, .item h3 { margin: 0 0 14px; font-size: 16px; }
.settings-card-heading { display: flex; align-items: flex-start; gap: 11px; }
.settings-card-heading h3 { margin: 0; }
.settings-card-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.settings-icon { flex: 0 0 32px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--surface); color: var(--accent); font-weight: 700; }
.settings-form label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 11px;
  background: #202020;
  color: var(--text);
}
.form-actions, .dialog-actions, .idea-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions button, .dialog-actions button, .idea-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.form-actions button:hover, .dialog-actions button:hover, .idea-actions button:hover { background: var(--accent-hover); }
.secondary-button { border: 1px solid var(--border) !important; background: transparent !important; color: var(--text) !important; }
.date-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.sync-summary { padding-bottom: 24px; }
.list { padding: 20px 0; overflow-y: auto; }
.ideas-content { min-height: 0; overflow-y: auto; }
.ideas-content .list { width: 100%; overflow: visible; }
.segmented-control { width: fit-content; margin-top: 18px; padding: 3px; display: flex; gap: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.segmented-control button { min-height: 34px; border: 0; border-radius: 6px; padding: 0 14px; background: transparent; color: var(--muted); cursor: pointer; }
.segmented-control button:hover { color: var(--text); }
.segmented-control button.is-active { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.item { margin-bottom: 10px; }
.item-header { display: flex; justify-content: space-between; gap: 12px; }
.pill { flex: 0 0 auto; align-self: flex-start; white-space: nowrap; border: 1px solid var(--border); background: transparent; }
.status-new { color: #68a5ff; }
.status-ready { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.status-hidden { color: var(--muted); }
.status-make_button, .status-in_progress { color: var(--warning); }
.ready-idea-content { flex: 1; border: 0; padding: 0; background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.ready-idea-content:hover h3 { color: var(--accent); }
.item p, .hint { margin: 5px 0; color: var(--muted); line-height: 1.45; }
.hint { font-size: 13px; }
.form-error { color: var(--danger); }
.query-prompt { padding: 14px 16px !important; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.query-prompt h3 { font-size: 16px; }
.prompt-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.prompt-actions button { min-height: 36px; border: 1px solid var(--border); border-radius: 7px; padding: 0 11px; background: transparent; color: var(--text); cursor: pointer; }
.prompt-actions button:hover { background: var(--surface-hover); }
.prompt-actions .primary-action { border-color: var(--accent); background: var(--accent); color: #fff; }
.custom-period { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)) auto; gap: 8px; margin-top: 10px; }
.custom-absence-days { display: grid; grid-template-columns: minmax(130px, 180px) auto; gap: 8px; margin-top: 10px; }
.custom-absence-days button { min-height: 42px; }

.switch-row { min-height: 64px; margin-top: 18px !important; padding: 11px 0; display: flex !important; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--border); cursor: pointer; }
.switch-row > span:first-child { flex: 1; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { color: var(--text); font-size: 14px; }
.switch-row small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: 0 0 44px; width: 44px; height: 24px; border-radius: 12px; background: #555; transition: background .15s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.analysis-catalog { min-height: 0; overflow-y: auto; padding: 6px max(24px, calc((100% - var(--content-width)) / 2)) 30px; }
.analysis-category { padding: 24px 0; border-bottom: 1px solid var(--border); }
.analysis-category:last-child { border-bottom: 0; }
.analysis-category-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.analysis-category h3 { margin: 0; font-size: 18px; }
.analysis-category-header p { margin: 4px 0 0; color: var(--muted); }
.availability { color: var(--success); font-size: 12px; white-space: nowrap; }
.availability.is-unavailable { color: var(--warning); }
.scenario-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.scenario-button { min-height: 68px; border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.scenario-button:hover { background: var(--surface); border-color: #666; }
.scenario-button strong, .scenario-button span { display: block; }
.scenario-button strong { font-size: 14px; }
.scenario-button span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.quality-content {
  min-height: 0;
  overflow-y: auto;
  padding: 22px max(24px, calc((100% - var(--content-width)) / 2)) 36px;
}
.quality-summary, .quality-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.quality-summary h3, .quality-section h3 { margin: 0; font-size: 17px; }
.quality-summary p, .quality-section > p { margin: 5px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.quality-score.is-good { color: var(--success); }
.quality-score.is-warning { color: var(--warning); }
.quality-score.is-error { color: var(--danger); }
.quality-table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.quality-table { min-width: 680px; }
.quality-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.quality-card { min-height: 132px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.quality-card > strong { display: block; margin-bottom: 7px; font-size: 24px; letter-spacing: 0; }
.quality-card h4 { margin: 0; font-size: 13px; }
.quality-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.quality-card.is-good > strong { color: var(--success); }
.quality-card.is-warning > strong { color: var(--warning); }
.quality-card.is-error > strong { color: var(--danger); }

html[data-theme="light"] {
  --bg: #ffffff;
  --sidebar: #f7f7f8;
  --sidebar-hover: #e9e9eb;
  --surface: #f4f4f4;
  --surface-hover: #e9e9e9;
  --text: #202123;
  --muted: #676767;
  --border: #dedede;
  color-scheme: light;
}
html[data-theme="light"] .sidebar-history,
html[data-theme="light"] .sidebar-footer,
html[data-theme="light"] .topbar { border-color: var(--border); }
html[data-theme="light"] .topbar { background: rgba(255,255,255,.96); }
html[data-theme="light"] .report-table,
html[data-theme="light"] table { background: #fff; }
html[data-theme="light"] th { background: #f5f5f5; }
html[data-theme="light"] th,
html[data-theme="light"] td { border-color: #e7e7e7; }
html[data-theme="light"] tbody tr:hover { background: #fafafa; }
html[data-theme="light"] .settings-form,
html[data-theme="light"] .item { background: #fff; }
html[data-theme="light"] input { background: #fff; }
html[data-theme="light"] .composer-shell { background: linear-gradient(180deg, rgba(255,255,255,0), #fff 25%); }
html[data-theme="light"] .composer { background: #fff; border-color: #d4d4d4; box-shadow: 0 4px 18px rgba(0,0,0,.08); }
html[data-theme="light"] .send-button { background: #202123; color: #fff; }
html[data-theme="light"] .send-button:hover { background: #000; }
html[data-theme="light"] .message.user { background: #f4f4f4; }
html[data-theme="light"] .patient-link { color: #087d62; }
html[data-theme="light"] .history-item { color: #3f3f46; }
html[data-theme="light"] .history-item:hover,
html[data-theme="light"] .history-item.is-current { color: #111; }
html[data-theme="light"] .table-controls { background: #f7f7f8; }
html[data-theme="light"] .quality-card,
html[data-theme="light"] .calculation-details,
html[data-theme="light"] .comparison-controls,
html[data-theme="light"] .detailed-report-button { background: #fff; }

.auth-page { min-height: 100vh; background: var(--bg); color: var(--text); }
.auth-layout { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-form { position: relative; width: min(100%, 400px); display: grid; gap: 12px; overflow: hidden; padding: 28px; border: 1px solid var(--border); border-top: 3px solid var(--brand-green); border-radius: 8px; background: var(--surface); box-shadow: 0 16px 48px rgba(0, 0, 0, .18); }
.auth-form::before { content: ""; position: absolute; top: -3px; left: 0; width: 34%; height: 3px; background: var(--brand-red); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.auth-brand .brand-logo-crop { width: 54px; height: 46px; }
.auth-brand .brand-logo-crop img { height: 46px; }
.auth-brand .brand-name { font-size: 22px; }
.auth-form h1 { margin: 0 0 6px; font-size: 24px; }
.auth-form p { margin: 0; color: var(--muted); line-height: 1.45; }
.auth-form label { margin-top: 4px; color: var(--text); font-size: 13px; font-weight: 600; }
.auth-form input { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; background: var(--bg); color: var(--text); font: inherit; }
.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-form > button { min-height: 44px; margin-top: 6px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.auth-form > button:disabled { opacity: .6; cursor: wait; }
.auth-message { min-height: 20px; color: var(--danger) !important; }
.auth-message.is-success { color: var(--brand-green) !important; }
.auth-link { justify-self: center; color: var(--muted); font-size: 13px; text-decoration: none; }
.auth-link:hover { color: var(--text); text-decoration: underline; }
.auth-inner-form { display: grid; gap: 12px; }
.auth-inner-form label { margin-top: 4px; color: var(--text); font-size: 13px; font-weight: 600; }
.auth-inner-form input { width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; background: var(--bg); color: var(--text); font: inherit; }
.auth-inner-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-inner-form > button { min-height: 44px; margin-top: 6px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.auth-inner-form > button:disabled { opacity: .6; cursor: wait; }
.auth-note { padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.68);
}
.dialog { width: min(430px,100%); padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: #292929; box-shadow: 0 18px 60px rgba(0,0,0,.45); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog h2 { margin: 0; font-size: 20px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); }
.dialog label { display: block; margin: 18px 0 7px; color: var(--muted); font-size: 13px; }
.dialog-actions { justify-content: flex-end; }
.toast {
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111;
  color: #fff;
  box-shadow: 0 12px 34px rgba(0,0,0,.4);
}
.sidebar-backdrop { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  .thinking-dots span { animation: none; opacity: .75; }
  .messages { scroll-behavior: auto; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(var(--sidebar-width), calc(100vw - 56px));
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: 16px 0 40px rgba(0,0,0,.35);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; display: block; background: rgba(0,0,0,.5); }
  .mobile-only { display: grid; }
  .topbar { padding: 0 12px; }
  .topbar p { display: none; }
  .messages { padding: 20px 14px 32px; }
  .message.user { max-width: 92%; }
  .composer-shell { padding: 8px 10px 10px; }
  .composer-note { display: none; }
  .section-header { padding: 20px 16px 16px; align-items: flex-start; }
  .section-header p { font-size: 13px; }
  .settings-layout, .sync-summary, .list, .ideas-content { width: calc(100% - 24px); }
  .settings-layout, .date-grid, .scenario-grid, .quality-card-grid, .calculation-body { grid-template-columns: 1fr; }
  .table-control, .table-control input, .table-control select { width: 100%; }
  .custom-period { grid-template-columns: 1fr; }
  .custom-absence-days { grid-template-columns: 1fr; }
  .report-toolbar { align-items: flex-start; }
}
