:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --panel-strong: #fffdfa;
  --text: #1f2933;
  --muted: #5b6470;
  --line: rgba(31, 41, 51, 0.12);
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 34, 45, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.hero,
.card,
.flash {
  backdrop-filter: blur(12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar h1,
.hero h2,
.card h2,
.card h3 {
  margin: 0;
}

.brand-block {
  display: flex;
  align-items: center;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 14px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 20px;
}

.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 28px;
}

.card {
  padding: 28px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading p {
  margin: 10px 0 0;
  color: var(--muted);
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.flash-success {
  background: rgba(15, 118, 110, 0.12);
}

.flash-error {
  background: rgba(180, 35, 24, 0.12);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.form-grid input,
.form-grid select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
}

button,
.primary-link,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

button,
.primary-link {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

button:hover,
.primary-link:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

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

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

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

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

.mode-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

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

.actions form {
  margin: 0;
}

.result-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  flex-wrap: wrap;
}

.result-actions form {
  margin: 0;
}

.result-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.preview-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
}

.preview-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
}

.preview-table th,
.preview-table td {
  min-width: 140px;
  max-width: 280px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  word-break: break-word;
  white-space: normal;
  background: rgba(255, 255, 255, 0.82);
}

.preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e9edf0;
  color: var(--text);
}

.preview-table tr:last-child td {
  border-bottom: 0;
}

.preview-table th:last-child,
.preview-table td:last-child {
  border-right: 0;
}

.preview-table-wrapper::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.preview-table-wrapper::-webkit-scrollbar-track {
  background: rgba(31, 41, 51, 0.08);
  border-radius: 999px;
}

.preview-table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(15, 118, 110, 0.45);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.75);
}

.preview-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 118, 110, 0.65);
}

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

.plain-list {
  margin: 0;
  padding-left: 18px;
}

.auth-card {
  max-width: 480px;
  margin: 8vh auto 0;
}

@media (max-width: 768px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 12px;
  }

  .topbar,
  .hero,
  .card {
    padding: 20px;
    border-radius: 24px;
  }

  .topbar,
  .hero,
  .user-panel,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}
