:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-subtle: #f1f4f8;
  --border: #d8dee8;
  --text: #111827;
  --muted: #667085;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --danger: #b42318;
  --focus: #2563eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
}

button:hover {
  background: var(--surface-subtle);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 1px;
}

button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

button.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 380px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  display: grid;
  gap: 18px;
  box-shadow: 0 16px 50px rgb(17 24 39 / 8%);
}

.app-shell {
  min-height: 100dvh;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
}

body.is-authenticated .auth-shell {
  display: none;
}

body.is-authenticated .app-shell {
  display: grid;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-actions,
.row-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 220px minmax(260px, 330px) minmax(320px, 420px) minmax(360px, 1fr);
}

.pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.detail-pane {
  border-right: 0;
}

.pane-header {
  min-height: 64px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 22px;
}

.group-list,
.item-list {
  overflow: auto;
  padding: 8px;
}

.group-item,
.list-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 4px;
  padding: 10px;
  min-height: 56px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}

.group-item:hover,
.list-item:hover,
.group-item.active,
.list-item.active {
  background: var(--surface-subtle);
}

.group-item.active,
.list-item.active {
  border-color: var(--border);
}

.group-title,
.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 650;
  min-width: 0;
}

.swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 99px;
}

.item-subtitle,
.item-preview {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.badge {
  border-radius: 999px;
  background: #e6f5f3;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
}

.detail-body {
  overflow: auto;
  padding: 18px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.detail-body iframe {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 0;
  background: #fff;
}

.empty-state {
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

dialog {
  width: min(94vw, 440px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgb(17 24 39 / 20%);
}

dialog::backdrop {
  background: rgb(17 24 39 / 45%);
}

.dialog-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.dialog-body.wide {
  width: min(94vw, 620px);
}

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

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.spacer {
  flex: 1;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgb(17 24 39 / 20%);
}

.fatal-error {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: 8px;
  background: #fff7f6;
  color: var(--danger);
  padding: 12px 14px;
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: 190px minmax(250px, 1fr) minmax(320px, 1.2fr);
  }

  .detail-pane {
    grid-column: 1 / -1;
    min-height: 420px;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
  }

  .pane {
    min-height: 330px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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