:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.972 0.004 210);
  --surface-strong: oklch(0.94 0.009 210);
  --ink: oklch(0.19 0.024 232);
  --muted: oklch(0.43 0.025 232);
  --line: oklch(0.88 0.012 220);
  --primary: oklch(0.48 0.105 210);
  --primary-hover: oklch(0.42 0.112 210);
  --primary-soft: oklch(0.93 0.035 210);
  --accent: oklch(0.62 0.14 42);
  --success: oklch(0.52 0.13 152);
  --warning: oklch(0.66 0.16 67);
  --danger: oklch(0.55 0.16 25);
  --radius: 10px;
  --shadow: 0 8px 24px oklch(0.19 0.024 232 / 0.08);
  --focus: 0 0 0 3px oklch(0.48 0.105 210 / 0.22);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html,
body {
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.caption {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar-actions {
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.tab-button,
.secondary-button,
.primary-button,
.small-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  transition:
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.tab-button {
  min-width: 0;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.tab-button:hover,
.tab-button.is-active {
  color: var(--ink);
  background: var(--bg);
}

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

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

.secondary-button,
.small-button {
  color: var(--ink);
  background: var(--surface-strong);
}

.secondary-button:hover,
.small-button:hover {
  background: var(--line);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.summary-strip article {
  min-height: 96px;
  padding: 18px;
  background: var(--surface);
}

.summary-strip span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-strip strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

.section-head.compact {
  align-items: start;
}

.filter-row {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 108px;
  resize: vertical;
  padding: 11px;
  line-height: 1.5;
}

::placeholder {
  color: oklch(0.48 0.024 232);
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: var(--bg);
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.need-cell {
  max-width: 320px;
  font-weight: 700;
}

.status-pill,
.price-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.open {
  color: white;
  background: var(--danger);
}

.status-pill.done {
  color: white;
  background: var(--success);
}

.price-pill {
  color: oklch(0.24 0.044 42);
  background: oklch(0.91 0.08 73);
}

.tag-pill {
  color: oklch(0.24 0.04 210);
  background: var(--primary-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  padding: 24px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 16px;
}

.empty-state.inline {
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-panel,
.admin-list,
.login-panel,
.admin-users {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 18px;
}

.login-panel {
  display: none;
  width: min(460px, 100%);
  gap: 16px;
  margin: 0 auto;
}

.login-panel.is-active {
  display: grid;
}

.admin-layout,
.admin-users {
  display: none;
}

.admin-layout.is-active {
  display: grid;
}

.admin-users.is-active {
  display: block;
  margin-top: 18px;
}

.editor-panel {
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}

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

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

.form-grid.three,
.usage-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.usage-editor {
  grid-template-columns: minmax(140px, 0.8fr) minmax(0, 1.2fr);
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.admin-rows {
  display: grid;
  gap: 10px;
}

.admin-rows.users {
  margin-top: 12px;
}

.admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-item h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.admin-actions {
  display: flex;
  gap: 8px;
  align-items: start;
}

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

.user-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.form-error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1440px);
    padding-top: 18px;
  }

  h1 {
    font-size: 24px;
  }

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

  .tab-button,
  .primary-button,
  .secondary-button {
    min-width: 0;
    flex: 1;
    padding-right: 10px;
    padding-left: 10px;
  }

  .summary-strip,
  .filter-row,
  .form-grid,
  .form-grid.two,
  .form-grid.three,
  .usage-editor {
    grid-template-columns: 1fr;
  }

  .admin-item {
    grid-template-columns: 1fr;
  }

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

  .admin-actions {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
