:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #fbfaf7;
  --panel: #ffffff;
  --panel-muted: #f7f5f0;
  --text: #1b1f23;
  --muted: #626a70;
  --quiet: #8a9298;
  --line: #d7d3c9;
  --line-strong: #bbb5a8;
  --accent: #2f6f63;
  --accent-strong: #24564d;
  --accent-soft: #e6f0ed;
  --warn: #986a1a;
  --warn-soft: #fff4d8;
  --danger: #a13d36;
  --ok: #3f7251;
  --shadow: 0 1px 2px rgba(27, 31, 35, 0.08), 0 8px 18px rgba(27, 31, 35, 0.045);
  --shadow-tight: 0 1px 2px rgba(27, 31, 35, 0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.48 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
}

h2 {
  font-size: 21px;
  font-weight: 700;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) 138px minmax(330px, 470px);
  gap: 18px;
  align-items: center;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.topbar > div:first-child {
  padding-left: 11px;
  border-left: 3px solid var(--accent);
}

.topbar p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
  padding: 2px;
  overflow-x: auto;
  background: #ece8df;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-tight) inset;
}

.tabs button {
  flex: 0 0 auto;
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: #3d444a;
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.tabs button.active {
  background: #fffefa;
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow-tight);
}

#language {
  background: #fffefa;
}

.auth-panel {
  min-width: 0;
}

.login-form {
  display: grid;
  grid-template-columns: minmax(86px, 0.8fr) minmax(130px, 1.1fr) minmax(104px, 0.9fr) auto;
  gap: 6px;
  align-items: center;
}

.login-form input,
.login-form button,
.session-panel button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.session-panel {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.session-panel[hidden] {
  display: none;
}

#session-user {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-status {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  width: min(420px, calc(100% - 44px));
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #fffefa;
  box-shadow: var(--shadow);
}

.app-status[data-tone="error"] {
  border-left-color: var(--danger);
  color: #6f2722;
}

.app-status[data-tone="success"] {
  border-left-color: var(--ok);
}

.app-status[data-tone="pending"] {
  border-left-color: var(--warn);
}

.auth-required {
  margin: 12px 22px 0;
  padding: 10px 12px;
  border: 1px solid #ead59d;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: #6f5b22;
  font-weight: 650;
}

.auth-required[hidden] {
  display: none;
}

body[data-auth="signed-out"] main {
  opacity: 0.72;
}

body[data-auth="signed-out"] main input,
body[data-auth="signed-out"] main select,
body[data-auth="signed-out"] main textarea,
body[data-auth="signed-out"] main button,
body[data-auth="signed-out"] main .button {
  filter: saturate(0.72);
}

button,
.button,
select,
input,
textarea {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 650;
}

button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

button:hover,
.button:hover,
select:hover,
input:hover,
textarea:hover {
  border-color: #9f998c;
}

button:focus-visible,
.button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 111, 99, 0.18);
  outline-offset: 2px;
  border-color: var(--accent);
}

button[type="submit"],
.button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button[type="submit"]:hover,
.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:not([type="submit"]):not(.active):not(.list-row) {
  background: #f4f2ed;
}

main {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 26px 22px 44px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view > h2,
.toolbar {
  margin-bottom: 16px;
}

.view > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view > h2::before {
  content: "";
  width: 5px;
  height: 22px;
  background: var(--accent);
  border-radius: 2px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.inline-toolbar {
  justify-content: flex-start;
  margin: 12px 0 0;
}

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

.metric {
  position: relative;
  overflow: hidden;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: #dad4c7;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 760;
}

.readiness-grid {
  margin: 12px 0 18px;
}

.readiness-card {
  min-height: 124px;
}

.readiness-card[data-state="ok"]::before {
  background: var(--ok);
}

.readiness-card[data-state="attention"]::before {
  background: var(--warn);
}

.readiness-card[data-state="pending"]::before {
  background: var(--quiet);
}

.readiness-card em {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.notice,
#form-status {
  color: var(--muted);
}

.notice {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid #ead59d;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
}

.subtle {
  border-color: #c9ddd8;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.auth-empty {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.split > div,
.list-row,
.dashboard-widget {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.split > div {
  padding: 0;
  box-shadow: var(--shadow);
}

.split > div > h3 {
  margin: 0;
  padding: 12px 14px;
  background: var(--panel-muted);
  border-bottom: 1px solid var(--line);
}

.split > div > form,
.split > div > .list,
.split > div > .toolbar,
.split > div > .notice,
.split > div > .dashboard-widget-list {
  margin-left: 14px;
  margin-right: 14px;
}

.split > div > .list:last-child,
.split > div > .notice:last-child,
.split > div > .dashboard-widget-list:last-child {
  margin-bottom: 14px;
}

.split > div > h3 + .list {
  margin-top: 12px;
}

.dashboard-editor {
  grid-column: 1 / -1;
  background: var(--panel);
}

.list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.list-row {
  display: block;
  width: 100%;
  padding: 10px 11px 10px 13px;
  color: var(--muted);
  text-align: left;
  border-left: 3px solid #d8d2c6;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.list-row strong {
  color: var(--text);
  font-weight: 720;
}

button.list-row {
  cursor: pointer;
}

button.list-row:hover,
.list-row:hover {
  border-color: #aaa396;
  border-left-color: var(--accent);
  background: #fbfaf7;
}

.dashboard-widget-list {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.dashboard-widget {
  grid-column: span 4;
  min-height: 96px;
  padding: 12px;
  border-top: 3px solid #d8d2c6;
}

.dashboard-widget[draggable="true"] {
  cursor: grab;
}

.dashboard-widget.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-widget-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.dashboard-widget-actions button {
  min-width: 34px;
  min-height: 30px;
  padding: 4px 8px;
}

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

.form-grid + .form-grid {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.form-grid label {
  min-width: 0;
}

label span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

label:has(input[type="checkbox"]) {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  background: #fffefa;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

label:has(input[type="checkbox"]) span {
  margin: 0;
  order: 2;
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
}

input,
textarea {
  background: #fffefa;
}

select {
  background-color: #fffefa;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.compact-form {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}

.compact-form textarea {
  min-height: 96px;
}

.search-form {
  grid-template-columns: minmax(240px, 1fr) auto;
}

.kiosk {
  min-height: calc(100vh - 132px);
  padding: 28px;
  background: #17201d;
  color: #f7f4ea;
  border: 1px solid #2f3b37;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kiosk h2 {
  font-size: 42px;
}

.kiosk-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.kiosk-panel .metric {
  background: #202c28;
  border-color: #394a44;
  color: #f7f4ea;
}

.kiosk-panel .metric span,
.kiosk .list-row {
  color: #c4cbc5;
}

.kiosk .list-row {
  background: #202c28;
  border-color: #394a44;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .tabs {
    order: 3;
  }

  .auth-panel {
    order: 4;
  }

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

@media (max-width: 720px) {
  main {
    padding: 14px 12px 28px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .dashboard-widget-list {
    grid-template-columns: 1fr;
  }

  .dashboard-widget {
    grid-column: 1 / -1;
  }

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

  .kiosk {
    padding: 18px;
  }

  .kiosk h2 {
    font-size: 34px;
  }
}
