:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66756f;
  --line: #dce3df;
  --panel: #ffffff;
  --paper: #f7f8f5;
  --brand: #12312b;
  --brand-2: #1d6b5a;
  --accent: #e7f36a;
  --warn: #c77819;
  --danger: #b43b35;
  --ok: #16815f;
  --info: #2f6690;
  --shadow: 0 18px 42px rgba(19, 36, 31, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--brand);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 22px;
  color: var(--ink);
}

.login-brand small {
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 14px;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: var(--brand);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.brand strong,
.page-title h1,
.panel h2,
.section-title h2 {
  letter-spacing: 0;
}

.brand small {
  color: rgba(255, 255, 255, 0.72);
  display: block;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  text-align: left;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-meta {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.main {
  min-width: 0;
  width: 100%;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.page-title h1 {
  margin: 0 0 6px;
  font-size: clamp(26px, 3vw, 38px);
}

.page-title p {
  margin: 0;
  color: var(--muted);
  max-width: 780px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn.ghost {
  background: transparent;
}

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

.grid > *,
.topbar > *,
.main > * {
  min-width: 0;
}

.grid.kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.panel,
.metric,
.control-item,
.action-item,
.mobile-audit {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(18, 49, 43, 0.04);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel h2,
.section-title h2 {
  font-size: 18px;
  margin: 0;
}

.panel-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.metric {
  padding: 16px;
  min-height: 112px;
}

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

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

.metric small {
  color: var(--muted);
}

.score-ring {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ok) var(--score), #edf1ee 0);
  margin: 8px auto 18px;
}

.score-ring div {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  text-align: center;
}

.score-ring strong {
  font-size: 26px;
}

.filters {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 84px;
}

.control-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
  padding-right: 4px;
}

.control-item {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.control-top,
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.control-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eef3f0;
  color: var(--brand);
}

.badge.ok {
  background: #dcf3e9;
  color: var(--ok);
}

.badge.warn {
  background: #fff1d8;
  color: var(--warn);
}

.badge.danger {
  background: #ffe2df;
  color: var(--danger);
}

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

.status-buttons button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.status-buttons button.active {
  color: #fff;
  background: var(--brand-2);
  border-color: var(--brand-2);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
}

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

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

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

td {
  font-size: 14px;
}

.domain-bars {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1.5fr) 52px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf1ee;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--brand-2);
}

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

.action-item {
  padding: 13px;
  display: grid;
  gap: 8px;
}

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

.admin-layout {
  margin-top: 16px;
}

.admin-kpis .metric strong {
  font-size: 24px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.admin-message {
  margin: 16px 0 0;
}

.admin-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.role-list,
.admin-list,
.check-list {
  display: grid;
  gap: 8px;
}

.role-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfa;
}

.role-list p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 13px;
}

.admin-list {
  max-height: 300px;
  overflow: auto;
  padding-right: 2px;
}

.admin-list button {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.admin-list button.active,
.admin-list button:hover {
  border-color: var(--brand-2);
  background: #f1f8f5;
}

.admin-list small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.admin-user-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mini-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand);
  color: white;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.check-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
}

.check-list label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
}

.company-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.company-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.company-summary strong,
.company-summary span {
  display: block;
}

.company-summary span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.company-sites {
  max-height: 260px;
}

.company-note {
  margin-top: 14px;
}

.matrix-list {
  display: grid;
  gap: 8px;
}

.matrix-head,
.matrix-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 0.9fr) minmax(180px, 0.9fr) minmax(260px, 1.2fr) auto;
  gap: 10px;
  align-items: center;
}

.matrix-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0 10px;
}

.matrix-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.matrix-row select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.matrix-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.matrix-user small,
.matrix-establishments small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.matrix-establishments {
  display: grid;
  gap: 6px;
}

.matrix-establishments label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
}

.profile-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.profile-photo-row.compact {
  align-items: flex-start;
}

.profile-photo-row.compact .avatar-preview {
  width: 72px;
  height: 72px;
  font-size: 22px;
}

.muted-text {
  color: var(--muted);
  margin: 4px 0 10px;
  line-height: 1.4;
}

.avatar-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand);
  color: white;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 28px;
  font-weight: 900;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.form-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef3f0;
  color: var(--brand);
  font-weight: 700;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.offline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
}

.dot.off {
  background: var(--warn);
}

.mobile-audit {
  padding: 14px;
  display: none;
  position: sticky;
  bottom: 12px;
  z-index: 10;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .sidebar-meta {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
    width: 100%;
  }

  .actions .btn,
  .btn.primary {
    flex: 1 1 calc(50% - 10px);
  }

  .actions .offline {
    flex: 1 1 100%;
  }

  .grid.kpis,
  .grid.two,
  .filters,
  .split-fields,
  .check-list,
  .company-summary,
  .matrix-head,
  .matrix-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .matrix-head {
    display: none;
  }

  .mobile-audit {
    display: grid;
    gap: 10px;
  }

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

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }

  .page-title h1 {
    font-size: 26px;
  }

  .metric strong {
    font-size: 25px;
  }

  .status-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-top,
  .row,
  .profile-photo-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
