:root {
  color-scheme: light;
  --bg: #f4efe5;
  --panel: #fffdf8;
  --panel-strong: #f7f0e2;
  --text: #1b1a17;
  --muted: #635e53;
  --line: #d6cab5;
  --accent: #0f6c5c;
  --accent-strong: #0a4f43;
  --danger: #9f3720;
  --warning: #b77d0c;
  --shadow: 0 20px 45px rgba(30, 28, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(15, 108, 92, 0.12), transparent 28%),
    linear-gradient(180deg, #f7f2e8 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

a {
  color: inherit;
}

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

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.app-header,
.app-nav,
.panel,
.alert {
  border: 1px solid rgba(214, 202, 181, 0.9);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-radius: 1.5rem;
  padding: 1.5rem;
}

.header-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.app-title,
.section-title,
.subsection-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.02em;
}

.app-title {
  font-size: clamp(2rem, 2vw + 1rem, 3rem);
}

.section-title {
  font-size: 1.45rem;
}

.subsection-title {
  font-size: 1.1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  border-radius: 1.25rem;
  padding: 0.75rem;
}

.nav-link {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
}

.nav-link-active {
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 700;
}

.app-main,
.page-stack,
.stack-sm,
.stack-md,
.stack-lg,
.timeline {
  display: grid;
  gap: 1rem;
}

.stack-sm {
  gap: 0.65rem;
}

.stack-md {
  gap: 1rem;
}

.stack-lg {
  gap: 1.5rem;
}

.page-grid {
  display: grid;
  gap: 1.25rem;
}

.page-stack {
  gap: 1.25rem;
}

.layout-sidebar,
.layout-halves {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

.page-stack > *,
.layout-sidebar > *,
.layout-halves > * {
  min-width: 0;
}

[data-preserve-scroll="true"] {
  overflow-anchor: none;
}

.panel {
  border-radius: 1.5rem;
  padding: 1.25rem;
  min-width: 0;
}

.panel-header,
.section-heading,
.meta-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.meta-strip,
.muted-copy,
.text-link,
.detail-grid dt {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

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

.data-table th,
.data-table td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.data-table th {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-field {
  display: grid;
  gap: 0.45rem;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--panel);
  padding: 0.8rem 0.9rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

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

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

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.alert {
  border-radius: 1rem;
  padding: 0.9rem 1rem;
}

.alert-success {
  border-left: 4px solid var(--accent);
}

.alert-error,
.alert-danger {
  border-left: 4px solid var(--danger);
}

.alert-warning {
  border-left: 4px solid var(--warning);
}

.counter-pill,
.user-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--panel-strong);
}

.status-fresh {
  background: rgba(15, 108, 92, 0.16);
  color: var(--accent-strong);
}

.status-stale {
  background: rgba(183, 125, 12, 0.18);
  color: #7b5608;
}

.status-unknown {
  background: rgba(99, 94, 83, 0.12);
}

.status-idle,
.status-completed {
  background: rgba(15, 108, 92, 0.16);
  color: var(--accent-strong);
}

.status-busy,
.status-running,
.status-accepted,
.status-dispatched {
  background: rgba(15, 108, 92, 0.12);
  color: var(--text);
}

.status-failed,
.status-rejected {
  background: rgba(159, 55, 32, 0.18);
  color: var(--danger);
}

.status-completed-with-delta,
.status-completed_with_delta,
.status-pending {
  background: rgba(183, 125, 12, 0.18);
  color: #7b5608;
}

.timeline-item {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px dashed var(--line);
}

.pre-box {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(247, 240, 226, 0.5);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.detail-grid dd {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.auth-panel,
.narrow-panel {
  max-width: 32rem;
  width: 100%;
}

@media (min-width: 1100px) {
  .layout-sidebar {
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.95fr);
  }

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

@media (max-width: 800px) {
  .app-shell {
    padding: 1rem 0.85rem 2rem;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
