:root {
  --bg: #f6f1ea;
  --bg-2: #ead9c6;
  --panel: rgba(255, 251, 245, 0.78);
  --panel-strong: rgba(255, 249, 241, 0.96);
  --line: rgba(109, 83, 49, 0.16);
  --line-strong: rgba(109, 83, 49, 0.28);
  --text: #2f2318;
  --muted: #7d6750;
  --accent: #8d5d16;
  --accent-strong: #70470a;
  --accent-soft: #fff1cc;
  --danger: #a4412a;
  --shadow: 0 20px 60px rgba(79, 49, 14, 0.14);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: "Avenir Next", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 243, 205, 0.8), transparent 34%),
    radial-gradient(circle at 82% 12%, rgba(199, 149, 89, 0.18), transparent 24%),
    linear-gradient(180deg, #f9f4ed 0%, #f1e6d9 100%);
  min-height: 100vh;
}

body.login-page {
  display: grid;
  place-items: center;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(141, 93, 22, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(141, 93, 22, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 78%);
}

.shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.9fr);
  gap: 24px;
  padding: 32px 0 18px;
  align-items: stretch;
}

.hero-copy,
.hero-card,
.panel,
.subpanel,
.form-card,
.data-card {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.hero-copy {
  padding: 34px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(140deg, rgba(255, 251, 245, 0.92), rgba(255, 245, 228, 0.72)),
    linear-gradient(120deg, rgba(145, 104, 39, 0.15), transparent);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(64, 43, 19, 0.95), rgba(92, 62, 27, 0.92));
  color: #fef7ee;
  box-shadow: var(--shadow);
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  color: rgba(255, 248, 239, 0.88);
  font-size: 13px;
  font-weight: 700;
}

.hero-card ul {
  margin: 16px 0 0;
  padding-left: 18px;
  line-height: 1.7;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

.section-kicker {
  margin-bottom: 6px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 3.8vw, 3.6rem);
  line-height: 1.02;
  max-width: 10ch;
}

h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h3 {
  font-size: 1.2rem;
}

.hero-text,
.form-title-row p,
.hero-card p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
  max-width: 64ch;
}

.hero-card p,
.hero-card li {
  color: rgba(255, 248, 239, 0.88);
}

.page {
  display: grid;
  gap: 22px;
  padding: 8px 0 28px;
}

.workspace {
  padding-bottom: 30px;
}

.global-filter-panel {
  margin-bottom: 18px;
}

.erp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 244, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  position: sticky;
  top: 12px;
  z-index: 10;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.tab-button {
  border: 0;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(255, 243, 223, 0.92);
  color: var(--accent-strong);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-button.active {
  background: linear-gradient(135deg, #8f621f, #6a430f);
  color: #fff8ef;
  box-shadow: 0 10px 20px rgba(106, 67, 15, 0.25);
}

.tab-content {
  display: grid;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel {
  padding: 24px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.panel-head,
.subpanel-head,
.form-title-row,
.items-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subpanel-head.lower {
  margin-top: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

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

.summary-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(248, 237, 219, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.75);
}

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

.summary-card .value {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--accent-strong);
}

.summary-card .hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.two-column,
.form-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.35fr);
  gap: 18px;
  margin-top: 18px;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

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

.dashboard-wide {
  margin-top: 18px;
}

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

.subpanel,
.data-card,
.form-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.data-card {
  overflow: hidden;
}

.form-card.wide {
  overflow: hidden;
}

.input-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

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

.input-grid.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-bar {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 249, 241, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.66);
}

.compact-filter-bar {
  margin-top: 12px;
}

.filter-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-actions {
  display: flex;
  align-items: end;
  height: 100%;
}

.filter-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.full-row {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(141, 93, 22, 0.45);
  box-shadow: 0 0 0 4px rgba(141, 93, 22, 0.12);
}

textarea {
  resize: vertical;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.primary-button {
  color: #fff8ef;
  background: linear-gradient(135deg, #8f621f, #6a430f);
  box-shadow: 0 10px 24px rgba(106, 67, 15, 0.28);
}

.ghost-button {
  background: rgba(255, 244, 223, 0.9);
  color: var(--accent-strong);
  border: 1px solid rgba(141, 93, 22, 0.18);
}

.ghost-button-light {
  background: rgba(255, 255, 255, 0.13);
  color: #fff8ef;
  border-color: rgba(255, 255, 255, 0.28);
}

.danger-button {
  border: 1px solid rgba(164, 65, 42, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--danger);
  background: rgba(164, 65, 42, 0.08);
  transition: transform 0.2s ease, background 0.2s ease;
}

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

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
  transform: none;
}

.login-shell {
  width: min(480px, calc(100% - 32px));
  padding: 42px 0;
}

.login-panel {
  display: grid;
  gap: 26px;
  padding: 34px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(140deg, rgba(255, 251, 245, 0.94), rgba(255, 245, 228, 0.82)),
    linear-gradient(120deg, rgba(145, 104, 39, 0.12), transparent);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.login-panel h1 {
  max-width: none;
}

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

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

.login-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 12px 13px;
  outline: none;
}

.login-form input:focus {
  border-color: rgba(141, 93, 22, 0.56);
  box-shadow: 0 0 0 3px rgba(141, 93, 22, 0.12);
}

.login-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.items-block {
  margin-top: 22px;
}

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

.compact-search-input {
  min-width: min(280px, 100%);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  padding: 10px 14px;
}

.hidden-row {
  display: none;
}

.bulk-import-panel {
  margin-top: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.98), rgba(248, 237, 219, 0.92));
  border: 1px solid rgba(109, 83, 49, 0.14);
}

.bulk-import-panel.hidden {
  display: none;
}

.bulk-import-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.bulk-import-head h5 {
  margin: 0;
  font-size: 1rem;
  font-family: var(--font-serif);
}

.bulk-import-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.bulk-import-body {
  margin-top: 14px;
}

.bulk-import-body textarea {
  min-height: 170px;
  font-family: "Consolas", "SFMono-Regular", "Courier New", monospace;
}

.bulk-import-help {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.bulk-import-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  flex-wrap: wrap;
}

.form-state-bar {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 244, 223, 0.85);
  border: 1px solid rgba(141, 93, 22, 0.14);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.form-state-text {
  color: var(--accent-strong);
  font-weight: 700;
}

.line-items-shell,
.table-shell {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-top: 14px;
}

.table-shell.compact {
  margin-top: 12px;
}

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

.line-items-table {
  min-width: 1320px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(109, 83, 49, 0.09);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(247, 238, 224, 0.98);
  color: var(--accent-strong);
  z-index: 1;
}

tbody tr:hover {
  background: rgba(255, 247, 236, 0.72);
}

.table-muted {
  color: var(--muted);
}

.table-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(141, 93, 22, 0.12);
  color: var(--accent-strong);
}

.status-badge.status-closed {
  background: rgba(60, 101, 53, 0.14);
  color: #396636;
}

.status-badge.status-draft {
  background: rgba(104, 90, 72, 0.14);
  color: #6c5d4b;
}

.status-badge.status-partially_received {
  background: rgba(128, 77, 9, 0.14);
  color: #8a5a11;
}

.stat-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 241, 204, 0.9);
  color: var(--accent-strong);
  font-weight: 700;
}

.line-remove {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(164, 65, 42, 0.18);
  background: rgba(164, 65, 42, 0.08);
  color: var(--danger);
  cursor: pointer;
}

.line-subtotal {
  font-weight: 700;
  color: var(--accent-strong);
  white-space: nowrap;
}

.stacked-cell {
  display: grid;
  gap: 8px;
}

.statement-summary {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(248, 237, 219, 0.9));
  border: 1px solid rgba(109, 83, 49, 0.12);
}

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

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

.statement-grid article {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 6px;
}

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

.statement-grid strong {
  color: var(--accent-strong);
  font-family: var(--font-serif);
  font-size: 1.1rem;
}

.movement-amount {
  font-weight: 700;
}

.item-image-cell {
  display: grid;
  gap: 8px;
  min-width: 110px;
}

.item-image-preview-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
}

.item-image-preview {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(109, 83, 49, 0.14);
  background: rgba(255, 255, 255, 0.88);
}

.item-image-input {
  width: 100%;
  font-size: 12px;
}

.empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 14px 18px;
  border-radius: 14px;
  color: #fff8ef;
  background: rgba(48, 34, 18, 0.94);
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: rgba(142, 49, 28, 0.95);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(33, 22, 10, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.hidden,
.hidden {
  display: none !important;
}

.modal-card {
  width: min(560px, 100%);
  padding: 24px;
  border-radius: var(--radius-xl);
  background: rgba(255, 250, 244, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.modal-card-wide {
  width: min(1180px, 100%);
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-body {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.modal-message {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 244, 223, 0.78);
  color: var(--text);
  line-height: 1.7;
}

.modal-blockers {
  display: grid;
  gap: 10px;
}

.modal-blocker {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(164, 65, 42, 0.08);
  border: 1px solid rgba(164, 65, 42, 0.14);
  color: var(--danger);
}

.modal-actions {
  margin-top: 20px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

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

.purchase-record-items {
  margin-top: 18px;
}

.purchase-record-items h4 {
  margin-bottom: 10px;
}

@media (max-width: 1120px) {
  .hero,
  .three-column,
  .dashboard-grid,
  .two-column,
  .form-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .summary-grid-dashboard,
  .filter-toolbar,
  .input-grid.three-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 18px, 100%);
  }

  .hero-copy,
  .hero-card,
  .panel,
  .subpanel,
  .form-card,
  .data-card {
    padding: 18px;
  }

  .summary-grid,
  .summary-grid-dashboard,
  .input-grid.two-up,
  .input-grid.three-up {
    grid-template-columns: 1fr;
  }

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

  .purchase-record-grid {
    grid-template-columns: 1fr;
  }

  .filter-toolbar {
    grid-template-columns: 1fr;
  }

  .erp-tabs {
    top: 8px;
  }

  .panel-head,
  .subpanel-head,
  .bulk-import-head,
  .modal-head,
  .items-head,
  .form-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-actions {
    align-items: stretch;
  }
}
