:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #142033;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --blue: #2563eb;
  --shadow: 0 16px 40px rgba(20, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

main,
.app-header {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.header-actions,
.section-header,
.search-row,
.filter-row,
.form-actions,
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions,
.search-row,
.form-actions {
  flex-wrap: wrap;
}

.button,
.nav-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 700;
}

.button:hover,
.nav-button:hover {
  border-color: #9aa6b6;
}

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

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

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #f3b8b3;
  color: var(--danger);
}

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

.nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-neutral {
  background: var(--surface-2);
  color: #344054;
}

.badge-accent {
  background: #ccfbf1;
  color: #0f766e;
}

.badge-danger {
  background: #fee4e2;
  color: #b42318;
}

.banner {
  margin: 0 0 16px;
  border: 1px solid #fedf89;
  border-radius: 7px;
  background: #fffaeb;
  color: #7a2e0e;
  padding: 12px 14px;
  font-weight: 700;
}

.workspace {
  display: grid;
  gap: 16px;
  padding-bottom: 32px;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 140px);
  place-items: start center;
  padding: 32px 0;
}

.login-form {
  display: grid;
  width: min(100%, 420px);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.view-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.nav-button {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.nav-button.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.sub-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  min-height: 40px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

.sub-nav .nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 132px;
  height: 40px;
  white-space: nowrap;
}

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

.section-header {
  justify-content: space-between;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.compact-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 28px;
  line-height: 1;
}

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

.dashboard-panel {
  display: grid;
  gap: 12px;
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.dashboard-panel h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

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

.dashboard-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

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

.dashboard-list span {
  min-width: 0;
}

.dashboard-list strong,
.dashboard-list small {
  display: block;
  overflow-wrap: anywhere;
}

.dashboard-list small,
.dashboard-empty {
  color: var(--muted);
}

.dashboard-list b {
  white-space: nowrap;
}

.dashboard-store-link {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.dashboard-store-link:hover strong,
.dashboard-store-link:focus-visible strong {
  color: var(--primary);
}

.dashboard-store-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

.risk-panel {
  border-color: #fecaca;
}

.warning-panel {
  grid-column: 1 / -1;
  border-color: #fedf89;
  background: #fffaeb;
}

.store-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.table-panel,
.store-list-panel,
.operations-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.table-panel,
.store-list-panel,
.store-detail-page,
.operations-panel {
  min-width: 0;
}

.store-list-panel {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 150px);
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.filter-row {
  align-items: end;
  gap: 8px;
}

.filter-row label {
  flex: 1 1 96px;
}

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

.filter-row select {
  min-height: 38px;
}

.store-list {
  display: grid;
  gap: 8px;
  max-height: min(680px, calc(100vh - 320px));
  overflow: auto;
  padding-right: 2px;
}

.news-list .store-list-item {
  gap: 6px;
}

.news-editor-panel {
  align-self: stretch;
}

.news-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.news-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.news-status-pill.published {
  background: #dcfce7;
  color: #166534;
}

.news-status-pill.scheduled {
  background: #dbeafe;
  color: #1d4ed8;
}

.news-status-pill.draft {
  background: #f2f4f7;
  color: #475467;
}

.news-status-pill.archived {
  background: #fee2e2;
  color: #991b1b;
}

.store-list-item {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.store-list-item:hover {
  border-color: #9aa6b6;
}

.store-list-item.selected {
  border-color: var(--primary);
  background: #ecfdf5;
}

.store-list-title {
  font-weight: 800;
}

.store-list-meta,
.store-list-status,
.store-list-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.store-list-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.store-list-stats span {
  border-radius: 999px;
  background: var(--surface-2);
  color: #344054;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.edit-panel {
  display: grid;
  gap: 12px;
  max-width: 860px;
}

.operations-panel {
  display: grid;
  grid-template-rows: auto 42px minmax(0, 1fr);
  gap: 14px;
  min-height: 680px;
  align-content: stretch;
}

.archive-delete-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.archive-store-list-panel,
.archive-delete-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.archive-store-list {
  gap: 6px;
  min-height: 0;
  max-height: min(360px, calc(100vh - 360px));
}

.archive-store-list .store-list-item {
  gap: 2px;
  padding: 8px 10px;
  border-radius: 6px;
}

.archive-store-list .store-list-title {
  font-size: 14px;
  line-height: 1.25;
}

.archive-store-list .store-list-meta,
.archive-store-list .store-list-status {
  font-size: 12px;
  line-height: 1.3;
}

.archive-store-list .store-list-stats {
  gap: 6px;
  margin-top: 2px;
}

.archive-store-list .store-list-stats span {
  padding: 2px 6px;
  font-size: 11px;
}

.archive-summary {
  display: grid;
  gap: 12px;
}

.selected-store-summary {
  min-height: 72px;
}

.selected-store-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.selected-store-card strong,
.selected-store-card small {
  display: block;
}

.selected-store-card small {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.query-preview {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #f9fafb;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .archive-delete-layout {
    grid-template-columns: 1fr;
  }
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 32, 51, 0.42);
  animation: sheetFadeIn 140ms ease-out;
}

.side-sheet {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(980px, 94vw);
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 44px rgba(20, 32, 51, 0.18);
  animation: sheetSlideIn 180ms ease-out;
}

.side-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.side-sheet-body {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.side-sheet .operations-panel {
  min-height: calc(100vh - 112px);
  box-shadow: none;
}

.sheet-open {
  overflow: hidden;
}

@keyframes sheetSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes sheetFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#operationTableRegion {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto auto;
  min-height: 520px;
}

.table-scroll {
  min-height: 420px;
  max-height: min(560px, calc(100vh - 360px));
  overflow: auto;
}

.operations-panel > .edit-panel {
  min-height: 520px;
  align-self: stretch;
}

.side-sheet #operationTableRegion {
  min-height: calc(100vh - 230px);
}

.side-sheet .table-scroll {
  min-height: 420px;
  max-height: calc(100vh - 310px);
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding-top: 12px;
}

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

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tr.selected td {
  background: #ecfdf5;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.numeric {
  text-align: right;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  padding: 0;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

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

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

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

.muted,
.empty-state {
  color: var(--muted);
}

.empty-state {
  margin: 18px 0 0;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  main,
  .app-header {
    width: min(100% - 20px, 1440px);
  }

  .app-header,
  .section-header,
  .pagination-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .dashboard-grid,
  .store-workspace {
    grid-template-columns: 1fr;
  }

  .store-list-panel {
    max-height: none;
    position: static;
  }

  .store-list {
    max-height: none;
  }

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