:root {
  color-scheme: light;
  --bg: #eef4f8;
  --bg-alt: #f9fbfd;
  --panel: rgba(255, 255, 255, 0.68);
  --panel-solid: #ffffff;
  --panel-strong: rgba(255, 255, 255, 0.84);
  --input-bg: rgba(255, 255, 255, 0.78);
  --line: rgba(141, 157, 171, 0.34);
  --line-strong: rgba(109, 128, 145, 0.46);
  --text: #1f2328;
  --muted: #6b7280;
  --odoo: #714b67;
  --odoo-dark: #5e3f56;
  --odoo-soft: rgba(113, 75, 103, 0.12);
  --teal: #00a09d;
  --warn: #b45f06;
  --error: #b42318;
  --shadow: 0 20px 55px rgba(31, 35, 40, 0.12);
  --shadow-soft: 0 8px 22px rgba(31, 35, 40, 0.08);
  --glass-blur: blur(18px) saturate(165%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08131a;
  --bg-alt: #111b25;
  --panel: rgba(18, 28, 38, 0.68);
  --panel-solid: #172431;
  --panel-strong: rgba(27, 39, 51, 0.84);
  --input-bg: rgba(12, 22, 31, 0.76);
  --line: rgba(180, 205, 224, 0.18);
  --line-strong: rgba(196, 216, 232, 0.34);
  --text: #eef6fb;
  --muted: #a8b8c5;
  --odoo: #d79bc6;
  --odoo-dark: #f0c7e4;
  --odoo-soft: rgba(215, 155, 198, 0.16);
  --teal: #35d4c7;
  --warn: #f2b35d;
  --error: #ff8a80;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(0, 160, 157, 0.18), transparent 42%),
    linear-gradient(315deg, rgba(113, 75, 103, 0.16), transparent 48%),
    linear-gradient(180deg, var(--bg), var(--bg-alt));
  background-attachment: fixed;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 4px;
  background: var(--odoo);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
  min-height: 38px;
  padding: 0 16px;
}

button:hover {
  background: var(--odoo-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 8px 18px;
  border-bottom: 1px solid #cfc8ce;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(31, 35, 40, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo {
  width: 164px;
  height: 46px;
  flex: 0 0 auto;
  object-fit: contain;
}

.app-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.app-title span,
.eyebrow {
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-title strong {
  overflow: hidden;
  color: #2f2a2e;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-button {
  min-height: 34px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(245, 245, 247, 0.88);
  backdrop-filter: blur(3px);
  padding: 18px;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  display: grid;
  gap: 10px;
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 22px 60px rgba(31, 35, 40, 0.2);
  padding: 22px;
}

.login-logo {
  width: 172px;
  height: 48px;
  object-fit: contain;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--error);
  font-size: 0.9rem;
}

.login-help {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.version-badge {
  position: fixed;
  bottom: 10px;
  left: 12px;
  z-index: 30;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  padding: 5px 9px;
  box-shadow: 0 4px 14px rgba(31, 35, 40, 0.08);
}

.panel-title,
.answer-header,
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.12rem;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 12px;
  white-space: nowrap;
}

.status.ok {
  border-color: #b9ded4;
  background: #eef9f6;
  color: #006b5f;
}

.status.warn {
  border-color: #efd0a3;
  background: #fff8ed;
  color: var(--warn);
}

.category-panel,
.ask-panel,
.settings-panel,
.answer,
.results {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.category-panel,
.ask-panel,
.settings-panel,
.answer,
.results {
  padding: 18px;
}

.category-panel[hidden],
.ask-panel[hidden],
.settings-panel[hidden],
.answer[hidden],
.results[hidden] {
  display: none;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.app-tile {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 22px 16px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(31, 35, 40, 0.06);
}

.app-tile:hover {
  border-color: #b99ab0;
  background: #fbf8fb;
  color: var(--text);
  transform: translateY(-1px);
}

.app-tile.locked {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.app-tile strong {
  font-size: 1.12rem;
}

.app-tile span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 13px;
  color: #ffffff;
}

.app-icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ticket-tile .app-icon {
  background: #875a7b;
}

.time-tile .app-icon {
  background: #00a09d;
}

.stock-tile .app-icon {
  background: #f0ad4e;
}

.repair-tile .app-icon {
  background: #2f6f9f;
}

.settings-tile .app-icon {
  background: #344767;
}

.settings-home {
  display: grid;
  grid-template-columns: minmax(280px, 420px);
  gap: 14px;
}

.settings-home[hidden],
.settings-subsection[hidden] {
  display: none;
}

.settings-menu-button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 16px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(31, 35, 40, 0.06);
}

.settings-menu-button:hover {
  border-color: #b99ab0;
  background: #fbf8fb;
}

.settings-menu-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: #875a7b;
  color: #ffffff;
}

.settings-menu-icon svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.settings-menu-button strong,
.settings-menu-button small {
  display: block;
}

.settings-menu-button small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.settings-subsection {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  padding: 16px;
}

.subsection-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.subsection-title h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.2rem;
}

.settings-help {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.settings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.settings-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.settings-table td:first-child {
  display: grid;
  gap: 2px;
}

.settings-table td:first-child span {
  color: var(--muted);
  font-size: 0.82rem;
}

.settings-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--odoo);
}

.settings-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.settings-status {
  margin: 0;
  color: var(--muted);
}

.answer,
.results {
  margin-top: 16px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #4b5563;
  font-size: 0.92rem;
  font-weight: 650;
}

.client-picker {
  margin-bottom: 14px;
}

.client-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.client-search {
  position: relative;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  height: 38px;
  padding: 0 12px;
}

select {
  height: 38px;
  padding: 0 34px 0 12px;
}

input:focus,
select:focus {
  border-color: var(--odoo);
  box-shadow: 0 0 0 2px rgba(113, 75, 103, 0.16);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 38px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 20;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(31, 35, 40, 0.16);
}

.suggestion {
  display: grid;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f2;
  border-radius: 0;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.suggestion:hover {
  background: var(--odoo-soft);
  color: var(--text);
}

.suggestion strong {
  font-size: 0.92rem;
}

.suggestion span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-clients {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
  margin-top: 8px;
}

.client-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  max-width: 100%;
  border: 1px solid #cab7c5;
  border-radius: 999px;
  background: var(--odoo-soft);
  color: #4c3947;
  padding: 3px 5px 3px 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

.client-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-chip button {
  display: grid;
  place-items: center;
  width: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 999px;
  background: #ffffff;
  color: #6f5166;
  font-size: 0.85rem;
}

.client-chip button:hover {
  background: #e8dce5;
}

.analysis-block,
.period-block {
  margin-top: 16px;
}

.analysis-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.analysis-choice,
.secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #2f2a2e;
  min-height: 42px;
}

.analysis-choice:hover,
.secondary:hover {
  border-color: #b99ab0;
  background: var(--odoo-soft);
  color: var(--odoo-dark);
}

.analysis-choice.active {
  border-color: var(--odoo);
  background: var(--odoo);
  color: #ffffff;
}

.period-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 8px;
}

.period-grid [hidden] {
  display: none;
}

.technician-filter {
  display: grid;
  gap: 6px;
  max-width: 360px;
  margin-top: 14px;
}

.technician-filter[hidden] {
  display: none;
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.generated-query {
  min-height: 42px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfbfc;
  color: #4b5563;
  padding: 10px 12px;
  line-height: 1.35;
}

.answer-text {
  margin: 14px 0 0;
  color: var(--text);
  line-height: 1.55;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfbfc;
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
  color: #2f2a2e;
  font-size: 1.18rem;
}

.results-head {
  margin-bottom: 12px;
}

#rowCount {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  background: #f4f4f5;
  color: #4b5563;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

.error {
  color: var(--error);
}

.theme-switch {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 80;
  display: grid;
  width: 60px;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  padding: 0;
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.theme-switch:hover {
  background: var(--panel-strong);
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 48px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(0, 160, 157, 0.28), rgba(113, 75, 103, 0.28));
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(31, 35, 40, 0.28);
  transition: transform 160ms ease;
}

.theme-switch[aria-checked="true"] .theme-switch-thumb {
  transform: translateX(24px);
}

button {
  border-radius: 7px;
  box-shadow: 0 10px 24px rgba(113, 75, 103, 0.16);
}

.appbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.appbar-actions {
  padding-right: 72px;
}

.logo,
.login-logo {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  object-fit: contain;
}

.logo {
  width: 168px;
  height: 52px;
  padding: 5px;
}

.login-logo {
  justify-self: start;
  width: 104px;
  height: 124px;
  padding: 7px;
}

.app-title strong,
.metric strong,
.secondary,
.analysis-choice {
  color: var(--text);
}

.login-overlay {
  background: rgba(238, 244, 248, 0.62);
  backdrop-filter: blur(18px) saturate(165%);
  -webkit-backdrop-filter: blur(18px) saturate(165%);
}

:root[data-theme="dark"] .login-overlay {
  background: rgba(8, 19, 26, 0.72);
}

.login-card,
.category-panel,
.ask-panel,
.settings-panel,
.answer,
.results,
.settings-subsection,
.settings-menu-button,
.app-tile,
.metric,
.generated-query,
.table-wrap,
.settings-table-wrap {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.category-panel,
.ask-panel,
.settings-panel,
.answer,
.results {
  box-shadow: var(--shadow);
}

.app-tile:hover,
.settings-menu-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-strong);
  color: var(--text);
}

label,
th,
.generated-query,
.settings-help,
.settings-status,
#rowCount {
  color: var(--muted);
}

input,
select,
.status,
.suggestions,
.suggestion,
.client-chip button {
  border-color: var(--line-strong);
  background: var(--input-bg);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 160, 157, 0.16);
}

.suggestion {
  border-bottom-color: var(--line);
}

.suggestion:hover,
.secondary:hover,
.analysis-choice:hover {
  border-color: var(--line-strong);
  background: var(--odoo-soft);
  color: var(--text);
}

.client-chip {
  border-color: var(--line-strong);
  background: var(--odoo-soft);
  color: var(--text);
}

.client-chip button:hover {
  background: var(--panel-strong);
}

.status {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.status.ok {
  border-color: rgba(0, 160, 157, 0.36);
  background: rgba(0, 160, 157, 0.13);
  color: var(--teal);
}

.status.warn {
  border-color: rgba(242, 179, 93, 0.4);
  background: rgba(242, 179, 93, 0.12);
  color: var(--warn);
}

.version-badge {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

th {
  background: var(--panel-strong);
}

@media (max-width: 720px) {
  .appbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .appbar-actions {
    width: 100%;
    padding-right: 72px;
  }

  .logo {
    width: 146px;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .app-grid {
    grid-template-columns: 1fr;
  }

  .answer-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .analysis-buttons,
  .period-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .action-row button,
  .secondary,
  .analysis-choice {
    width: 100%;
  }

  .status {
    white-space: normal;
  }
}
