:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #1d2521;
  --muted: #607068;
  --primary: #256f5b;
  --primary-strong: #174c40;
  --accent: #b98024;
  --danger: #a43b36;
  --border: #d8e0dc;
  --focus: #2f80ed;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
}

.brand-mark.large {
  width: 56px;
  height: 56px;
  font-size: 1.45rem;
}

.topbar-actions,
.toolbar,
.form-actions,
.row-actions,
.offline-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  min-height: calc(100vh - 72px);
  padding: 16px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}

.sidebar a {
  display: block;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 8px;
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--surface);
}

.content {
  width: 100%;
  max-width: 1180px;
  padding: 24px;
}

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

.page-heading h1,
.login-brand h1,
.public-panel h1 {
  margin: 0;
  font-size: 1.8rem;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.panel,
.metric,
.login-panel,
.public-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 2rem;
}

.status-list {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 12px 20px;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary {
  background: #edf4f1;
  color: var(--primary-strong);
  border-color: #bfd4ca;
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.button.danger {
  background: #fff0ee;
  color: var(--danger);
  border-color: #efc5c0;
}

.button.small {
  min-height: 38px;
  padding: 8px 10px;
}

.button.full {
  width: 100%;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #eef0f2;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.status-pill[data-state="online"] {
  background: #e4f5ea;
  color: #146436;
}

.status-pill[data-state="offline"] {
  background: #fff4db;
  color: #7d5200;
}

.status-pill[data-state="syncing"] {
  background: #e8f0ff;
  color: #244f9e;
}

.badge.success {
  background: #e4f5ea;
  color: #146436;
}

.badge.warning {
  background: #fff4db;
  color: #7d5200;
}

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

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.alert.error {
  background: #fff0ee;
  color: var(--danger);
  border: 1px solid #efc5c0;
}

.alert.success {
  background: #e4f5ea;
  color: #146436;
  border: 1px solid #b7dcc4;
}

.alert.warning {
  background: #fff4db;
  color: #7d5200;
  border: 1px solid #efd28c;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-shell,
.public-shell {
  width: min(100%, 460px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.login-brand p,
.public-panel p {
  color: var(--muted);
  margin: 6px 0 0;
}

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

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

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.check-row input {
  width: 20px;
  min-height: 20px;
}

.form-actions {
  justify-content: flex-end;
}

.toolbar {
  justify-content: flex-end;
  margin-bottom: 14px;
}

.compact-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.table-panel {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.92rem;
}

code {
  background: #eef0f2;
  border-radius: 6px;
  padding: 2px 5px;
  word-break: break-word;
}

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

.local-sync-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.admin-card-list {
  display: none;
  gap: 10px;
}

.admin-record-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.admin-record-card strong {
  font-size: 1.05rem;
}

.admin-record-card span {
  color: var(--muted);
}

@media (max-width: 820px) {
  body {
    min-width: 0;
  }

  .topbar,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    padding: 10px 12px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar-actions .button,
  .topbar-actions form,
  .topbar-actions button,
  .topbar-actions .status-pill {
    width: 100%;
  }

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

  .sidebar {
    min-height: auto;
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    gap: 6px;
  }

  .sidebar a {
    white-space: nowrap;
    flex: 0 0 auto;
    min-height: 44px;
  }

  .content {
    padding: 12px;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .row-actions {
    min-width: 190px;
  }

  .page-actions,
  .sync-toolbar,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions .button,
  .sync-toolbar .button,
  .form-actions .button {
    width: 100%;
  }

  .admin-mobile-panel {
    padding: 12px;
  }

  .admin-table-view {
    display: none;
  }

  .admin-card-list {
    display: grid;
  }
}

