:root {
  --bg: #f7f8f4;
  --panel: #ffffff;
  --ink: #20241f;
  --muted: #687066;
  --line: #dfe4da;
  --brand: #029c8f;
  --brand-dark: #04786f;
  --brand-soft: rgba(2, 156, 143, 0.10);
  --accent: #e5b94f;
  --danger: #c75146;
  --danger-soft: rgba(199, 81, 70, 0.18);
  --shadow: 0 18px 45px rgba(36, 45, 34, 0.08);
  --shadow-hover: 0 14px 28px rgba(36, 45, 34, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.auth-card.wide {
  max-width: 560px;
}

.auth-card img {
  height: 48px;
  width: 48px;
}

.auth-card h1 {
  font-size: 28px;
  margin: 18px 0 8px;
}

.auth-card p,
.auth-link {
  color: var(--muted);
}

.auth-link {
  background: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  padding: 10px 0;
  transition: color .16s ease;
}

.auth-link:hover {
  color: var(--ink);
}

.auth-card > .auth-link {
  margin-top: 16px;
}

.auth-logout-form {
  margin: 0;
}

.auth-actions {
  align-items: center;
  display: flex;
  border-top: 1px solid var(--line);
  gap: 18px;
  margin-top: 20px;
  padding-top: 18px;
}

.company-list {
  display: grid;
  gap: 10px;
}

.company-option {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 20px 1fr;
  padding: 14px;
}

.company-option:hover,
.company-option:has(input:checked) {
  border-color: rgba(2, 156, 143, 0.38);
  box-shadow: 0 10px 24px rgba(36, 45, 34, 0.06);
}

.company-option input {
  accent-color: var(--brand);
  min-height: auto;
  width: auto;
}

.company-option strong,
.company-option small {
  display: block;
}

.company-option small {
  color: var(--muted);
  margin-top: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

.table-link {
  color: var(--brand-dark);
  font-weight: 800;
  transition: color .16s ease;
}

.table-link:hover {
  color: var(--brand);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
}

.sidebar {
  background: #16211f;
  color: #f8fbf7;
  padding: 28px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand strong {
  display: block;
  font-size: 20px;
}

.brand span,
.nav small {
  color: rgba(248, 251, 247, 0.64);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav small {
  margin: 18px 12px 4px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav a {
  align-items: center;
  border-radius: 8px;
  color: rgba(248, 251, 247, 0.82);
  display: flex;
  gap: 10px;
  padding: 11px 12px;
}

.nav-icon {
  flex: 0 0 auto;
  height: 19px;
  opacity: .84;
  width: 19px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

.main {
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.topbar p {
  color: var(--muted);
  margin: 0;
}

.actions {
  display: flex;
  gap: 10px;
}

.topbar-tools {
  align-items: center;
  display: flex;
  gap: 18px;
}

.session-actions {
  align-items: center;
  border-left: 1px solid var(--line);
  display: flex;
  gap: 12px;
  padding-left: 18px;
}

.company-switch {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 2px;
  min-width: 190px;
  padding: 9px 14px;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.company-switch span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.company-switch strong {
  font-size: 15px;
}

.company-switch:hover {
  border-color: rgba(2, 156, 143, 0.34);
  box-shadow: 0 10px 24px rgba(36, 45, 34, 0.07);
}

.logout-link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 0;
  transition: color .16s ease;
}

.logout-form {
  margin: 0;
}

.logout-link:hover {
  color: var(--danger);
}

.button {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}

.button:hover {
  background: var(--brand-dark);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.button.secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--brand-soft);
  border-color: rgba(2, 156, 143, 0.34);
  color: var(--brand-dark);
}

.button.danger {
  background: rgba(199, 81, 70, 0.12);
  color: var(--danger);
}

.button.danger:hover {
  background: var(--danger-soft);
  box-shadow: 0 14px 28px rgba(199, 81, 70, 0.12);
  color: #9f382f;
}

.button:disabled {
  background: #eef2eb;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 1;
}

.button:disabled:hover {
  background: #eef2eb;
  box-shadow: none;
  color: var(--muted);
  transform: none;
}

.button:focus-visible,
.auth-link:focus-visible,
.logout-link:focus-visible,
.company-switch:focus-visible,
.table-link:focus-visible {
  outline: 3px solid rgba(2, 156, 143, 0.22);
  outline-offset: 3px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric,
.panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}

.metric small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  line-height: 1.35;
  margin-top: 10px;
}

.report-summary {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) minmax(320px, .9fr);
}

.report-hero {
  min-height: 158px;
}

.report-hero strong {
  font-size: 34px;
  line-height: 1.15;
}

.report-alerts {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.metric.mini {
  box-shadow: none;
  min-height: 73px;
  padding: 14px;
}

.metric.mini strong {
  font-size: 24px;
  margin-top: 5px;
}

.metric.mini.ok {
  border-color: rgba(2, 156, 143, 0.18);
}

.metric.mini.warn {
  border-color: rgba(229, 185, 79, 0.42);
}

.metric.mini.danger {
  border-color: rgba(199, 81, 70, 0.36);
}

.workspace {
  grid-template-columns: 1.35fr .65fr;
  margin-top: 16px;
}

.panel {
  padding: 20px;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 16px;
}

.flow {
  display: grid;
  gap: 12px;
}

.flow-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 4px;
  grid-template-columns: 34px 1fr;
  padding: 13px;
}

a.flow-item:hover {
  border-color: rgba(2, 156, 143, 0.34);
  box-shadow: 0 10px 24px rgba(36, 45, 34, 0.07);
}

.flow-item b {
  align-items: center;
  background: rgba(2, 156, 143, 0.12);
  border-radius: 8px;
  color: var(--brand-dark);
  display: flex;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.flow-item.ok b {
  background: rgba(2, 156, 143, 0.12);
  color: var(--brand-dark);
}

.flow-item.warn b {
  background: rgba(229, 185, 79, 0.20);
  color: #8a6617;
}

.flow-item.danger b {
  background: rgba(199, 81, 70, 0.14);
  color: var(--danger);
}

.flow-item strong {
  display: block;
}

.flow-item span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  margin-top: 16px;
  overflow: hidden;
}

.table-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.table-heading h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

.table-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.muted-table {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: none;
}

.muted-table th {
  background: rgba(247, 248, 244, 0.72);
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
}

.tag.ok {
  background: rgba(2, 156, 143, 0.12);
  color: var(--brand-dark);
}

.tag.warn {
  background: rgba(229, 185, 79, 0.18);
  color: #8a6617;
}

.tag.danger {
  background: rgba(199, 81, 70, 0.12);
  color: var(--danger);
}

.form {
  display: grid;
  gap: 14px;
}

.form > .button {
  align-self: start;
  justify-self: start;
}

.compact-form {
  margin-top: 12px;
  min-width: 360px;
}

.danger-action {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.danger-zone {
  border-color: rgba(199, 81, 70, 0.28);
  margin-top: 16px;
}

.danger-zone h2 {
  color: var(--danger);
}

.status-form {
  margin-top: 14px;
}

.status-toggle {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 13px 14px;
}

.status-toggle strong,
.status-toggle small {
  display: block;
}

.status-toggle strong {
  color: var(--ink);
  font-size: 14px;
}

.status-toggle small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.status-toggle input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.toggle-control {
  background: #cfd8cf;
  border-radius: 999px;
  flex: 0 0 auto;
  height: 24px;
  position: relative;
  transition: background-color .16s ease;
  width: 44px;
}

.toggle-control::after {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(36, 45, 34, 0.18);
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform .16s ease;
  width: 18px;
}

.status-toggle input:checked + .toggle-control {
  background: var(--brand);
}

.status-toggle input:checked + .toggle-control::after {
  transform: translateX(20px);
}

.status-toggle input:focus-visible + .toggle-control {
  outline: 3px solid rgba(2, 156, 143, 0.22);
  outline-offset: 3px;
}

details summary {
  cursor: pointer;
  list-style: none;
  transition: color .16s ease;
}

details summary:hover {
  color: var(--brand);
}

details summary::-webkit-details-marker {
  display: none;
}

.form label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 16px;
  padding: 16px;
}

.filters form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.filters .button {
  align-self: end;
  justify-self: start;
}

.filters label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

input,
select {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form select {
  width: 170px;
}

td input,
td select {
  min-width: 150px;
}

.check-label {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.check-label input {
  min-height: auto;
  width: auto;
}

.detail-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  min-width: 280px;
}

.detail-box p {
  color: var(--muted);
  margin: 0;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(2, 156, 143, 0.12);
  outline: none;
}

.notice {
  border-radius: 8px;
  font-size: 14px;
  padding: 12px;
}

.notice.flash {
  margin-bottom: 16px;
}

.notice.danger {
  background: rgba(199, 81, 70, 0.12);
  color: var(--danger);
}

.notice.ok {
  background: rgba(2, 156, 143, 0.12);
  color: var(--brand-dark);
}

.notice.warn {
  background: rgba(229, 185, 79, 0.18);
  color: #8a6617;
}

.empty-state {
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  max-width: 620px;
  padding: 28px;
}

.empty-state strong {
  color: var(--brand-dark);
  font-size: 13px;
  text-transform: uppercase;
}

.empty-state h2 {
  font-size: 28px;
  margin: 0;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 8px;
}

.manual-page {
  background: #f7f8f4;
  min-height: 100vh;
}

.manual-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 52px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.manual-brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.manual-brand img {
  height: 42px;
  width: 42px;
}

.manual-brand strong,
.manual-brand small {
  display: block;
}

.manual-brand small {
  color: var(--muted);
  font-size: 13px;
}

.manual-shell {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1240px;
  padding: 30px clamp(18px, 4vw, 52px) 64px;
}

.manual-sidebar {
  min-width: 0;
}

.manual-sidebar-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 18px;
  position: sticky;
  top: 92px;
}

.manual-sidebar-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.manual-sidebar-title strong {
  font-size: 18px;
}

.manual-sidebar-title a {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.manual-search {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.manual-search span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.manual-search input {
  min-height: 40px;
}

.manual-toc-nav {
  display: grid;
  gap: 3px;
}

.manual-toc-link {
  border-left: 3px solid transparent;
  border-radius: 0 7px 7px 0;
  color: #3f463d;
  display: block;
  font-size: 14px;
  line-height: 1.35;
  padding: 8px 9px;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}

.manual-toc-link.level-3 {
  color: var(--muted);
  font-size: 13px;
  padding-left: 22px;
}

.manual-toc-link:hover,
.manual-toc-link.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.manual-reader {
  min-width: 0;
}

.manual-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 56px);
}

.manual-content h1 {
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.02;
  margin: 0 0 18px;
}

.manual-content h1,
.manual-content h2,
.manual-content h3,
.manual-content h4 {
  scroll-margin-top: 96px;
}

.manual-content h2 {
  border-top: 1px solid var(--line);
  font-size: 28px;
  margin: 44px 0 14px;
  padding-top: 30px;
}

.manual-content h3 {
  color: var(--brand-dark);
  font-size: 21px;
  margin: 28px 0 10px;
}

.manual-content h4 {
  font-size: 17px;
  margin: 22px 0 8px;
}

.manual-content p,
.manual-content li {
  color: #3f463d;
  font-size: 16px;
  line-height: 1.72;
}

.manual-content p {
  margin: 0 0 14px;
}

.manual-content ul,
.manual-content ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.manual-content li + li {
  margin-top: 6px;
}

.manual-content pre {
  background: #16211f;
  border-radius: 8px;
  color: #f8fbf7;
  overflow-x: auto;
  padding: 16px;
}

.manual-content code {
  background: rgba(2, 156, 143, 0.10);
  border-radius: 5px;
  color: var(--brand-dark);
  font-size: 0.94em;
  padding: 2px 5px;
}

.manual-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.manual-anchor {
  color: rgba(2, 156, 143, 0.42);
  font-size: .72em;
  font-weight: 800;
  margin-left: 8px;
  opacity: 0;
  transition: opacity .16s ease, color .16s ease;
}

.manual-content h1:hover .manual-anchor,
.manual-content h2:hover .manual-anchor,
.manual-content h3:hover .manual-anchor,
.manual-content h4:hover .manual-anchor {
  opacity: 1;
}

.manual-anchor:hover {
  color: var(--brand-dark);
}

.manual-content h2#cozty-by-otbalsoft {
  background: #16211f;
  border-top: 0;
  border-radius: 8px 8px 0 0;
  color: #ffffff;
  font-size: 24px;
  letter-spacing: 0;
  margin: 52px 0 0;
  padding: 24px 26px 6px;
}

.manual-content h2#cozty-by-otbalsoft + p {
  background: #16211f;
  border-radius: 0 0 8px 8px;
  color: rgba(248, 251, 247, 0.72);
  font-size: 14px;
  margin: 0;
  padding: 0 26px 24px;
}

.manual-content h2#cozty-by-otbalsoft + p a {
  color: #ffffff;
  font-weight: 800;
}

.manual-content h2#cozty-by-otbalsoft + p a:hover {
  color: var(--accent);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics,
  .workspace,
  .report-summary,
  .report-alerts {
    grid-template-columns: 1fr;
  }

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

  .topbar-tools,
  .session-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-tools {
    width: 100%;
  }

  .session-actions {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
    width: 100%;
  }

  .company-switch {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters form {
    grid-template-columns: 1fr;
  }

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

  .manual-shell {
    grid-template-columns: 1fr;
    padding-top: 18px;
  }

  .manual-sidebar-card {
    max-height: none;
    position: static;
  }

  .manual-toc-nav {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}
