/* Acme Admin styles. Neutral grey surfaces, one green accent (#57b12d). No external fonts. */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #dde1e7;
  --border-strong: #b7bec9;
  --text: #1d2129;
  --muted: #5b6370;
  --accent: #57b12d;
  --accent-ink: #0d1f08;
  --accent-strong: #2f7d12;
  --accent-soft: #e9f6e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

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

a {
  color: var(--accent-strong);
}

h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

h3 {
  font-size: 15px;
  margin: 0 0 4px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Layout */

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  margin: 0 8px 18px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.nav-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.nav-list a:hover {
  background: var(--surface-2);
}

.nav-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.content {
  padding: 24px 32px 48px;
  min-width: 0;
}

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

.page-header p {
  margin: 0;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}

.card.danger {
  border-color: #efb8b2;
}

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

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

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.activity-list li:last-child {
  border-bottom: 0;
}

.activity-when {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.section-intro {
  color: var(--muted);
  margin: -4px 0 14px;
  font-size: 14px;
}

.help-frame {
  width: 100%;
  height: 240px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

/* Forms and buttons */

.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.field label,
.check-label,
.switch-label {
  font-weight: 600;
  font-size: 14px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field input:not([type]) {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
}

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

[aria-invalid="true"] {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.field-error:empty {
  display: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.check-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent-strong);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: #4aa222;
}

.btn-danger {
  color: var(--danger);
  border-color: #e6a29b;
}

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-small {
  padding: 4px 10px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[role="tab"]:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.link-button[aria-pressed="true"] {
  text-decoration: underline;
}

.row-actions {
  white-space: nowrap;
}

.row-actions .btn + .btn {
  margin-left: 6px;
}

/* Tables */

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

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

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}

td.break {
  overflow-wrap: anywhere;
}

td.empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 12px;
}

.toolbar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
}

.toolbar .field {
  margin-bottom: 0;
  min-width: 180px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-on {
  background: var(--accent-soft);
  color: #22600c;
}

.badge-off {
  background: #e7eaf0;
  color: #434b58;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

[role="tab"] {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}

[role="tab"][aria-selected="true"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

[role="tabpanel"][hidden] {
  display: none;
}

.definition {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}

.definition dt {
  color: var(--muted);
}

.definition dd {
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
}

legend {
  font-weight: 600;
  padding: 0 4px;
}

/* Switches */

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

.switch-row:last-child {
  border-bottom: 0;
}

.switch-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

input[type="checkbox"][role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: #c3c9d3;
  cursor: pointer;
  transition: background 0.15s;
}

input[type="checkbox"][role="switch"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}

input[type="checkbox"][role="switch"]:checked {
  background: var(--accent);
}

input[type="checkbox"][role="switch"]:checked::before {
  transform: translateX(18px);
}

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.danger-row:last-child {
  border-bottom: 0;
}

.danger-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Dialogs and toasts */

dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25);
}

dialog::backdrop {
  background: rgba(16, 20, 28, 0.45);
}

.dialog-body {
  padding: 20px 22px;
}

.dialog-body h2 {
  margin-bottom: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
}

.toast {
  background: #1d2129;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.25);
  font-size: 14px;
  min-width: 200px;
}

.toast:empty {
  display: none;
}

/* Help page (inside the iframe) */

.help-body {
  background: var(--surface);
}

.help {
  padding: 14px 18px;
  font-size: 14px;
}

.help h1 {
  font-size: 18px;
}

.help section {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
}

.help section:target {
  background: var(--accent-soft);
}

.help ul.topics {
  padding-left: 18px;
}

/* Small screens */

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

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