:root {
  --bg: #f7efe4;
  --bg-accent: #f3d4b5;
  --panel: rgba(255, 252, 246, 0.82);
  --panel-strong: #fffaf1;
  --ink: #30241b;
  --muted: #75685b;
  --line: rgba(74, 49, 28, 0.14);
  --brand: #d86b2d;
  --brand-deep: #b84f16;
  --teal: #6f9d9c;
  --gold: #e1b34b;
  --danger: #c46056;
  --success: #4e8d63;
  --shadow: 0 18px 45px rgba(112, 69, 28, 0.14);
  --radius: 24px;
  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  --font-display: "Trebuchet MS", "Avenir Next", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 107, 45, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(111, 157, 156, 0.16), transparent 24%),
    linear-gradient(180deg, #faefe4 0%, #f5ebdd 50%, #f7f1e8 100%);
}

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

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
  gap: 20px;
  margin-bottom: 20px;
}

.hero-copy,
.hero-card,
.panel,
.stat-card {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 34px;
  position: relative;
  overflow: hidden;
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: -50px;
  bottom: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(216, 107, 45, 0.1);
}

.eyebrow,
.section-tag {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--brand-deep);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(36px, 5vw, 58px);
  line-height: 0.98;
  max-width: 11ch;
}

h2 {
  font-size: 28px;
}

.hero-text {
  margin: 18px 0 24px;
  max-width: 62ch;
  font-size: 16px;
  line-height: 1.7;
  color: var(--muted);
}

.hero-actions,
.form-actions,
.calendar-nav,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-card p,
.hero-card li,
.legend-row,
#table-summary {
  color: var(--muted);
}

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

.hero-card-note {
  margin: 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

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

.app-footer {
  margin-top: 24px;
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.app-footer p {
  margin: 6px 0 0;
}

.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.app-footer-links a {
  color: var(--brand-deep);
  text-decoration: none;
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.filters-grid,
.order-form,
.content-grid,
.stats-grid {
  display: grid;
  gap: 14px;
}

.filters-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

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

.stat-card {
  padding: 20px;
}

.stat-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.stat-value {
  display: block;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-note {
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
}

.sync-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.sync-card,
.auth-form {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.56);
  padding: 18px;
}

.sync-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.sync-user {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-form {
  display: grid;
  gap: 14px;
  align-content: start;
}

.recovery-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(216, 107, 45, 0.24);
  background: rgba(216, 107, 45, 0.08);
}

.turnstile-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(111, 157, 156, 0.28);
  background: rgba(111, 157, 156, 0.08);
}

.turnstile-widget {
  min-height: 66px;
}

.turnstile-widget iframe {
  max-width: 100%;
}

.recovery-title {
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.is-hidden {
  display: none;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

input[list]::-webkit-calendar-picker-indicator {
  opacity: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(216, 107, 45, 0.55);
  box-shadow: 0 0 0 4px rgba(216, 107, 45, 0.12);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  accent-color: var(--brand);
  transform: none;
  box-shadow: none;
}

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

.primary-button,
.ghost-button,
.import-button {
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease,
    opacity 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #ef9a59);
  color: #fff;
  box-shadow: 0 12px 24px rgba(216, 107, 45, 0.22);
}

.ghost-button,
.import-button {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border: 1px solid var(--line);
}

.small-button {
  padding: 8px 12px;
}

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

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

.breakdown-list {
  display: grid;
  gap: 14px;
}

.breakdown-item {
  display: grid;
  gap: 8px;
}

.breakdown-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.breakdown-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(48, 36, 27, 0.08);
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

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

.calendar-weekdays {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.calendar-cell {
  min-height: 132px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(74, 49, 28, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calendar-cell.is-outside {
  opacity: 0.45;
}

.calendar-day {
  font-weight: 700;
}

.calendar-items {
  display: grid;
  gap: 6px;
}

.calendar-item {
  padding: 7px 9px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(216, 107, 45, 0.12);
  border: 1px solid rgba(216, 107, 45, 0.2);
}

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

.batch-actions {
  display: grid;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px dashed rgba(216, 107, 45, 0.26);
  border-radius: 18px;
  background: rgba(216, 107, 45, 0.08);
}

.batch-actions > span {
  color: var(--muted);
  font-size: 14px;
}

.batch-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.batch-select {
  min-width: 148px;
  max-width: 320px;
}

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

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

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

.checkbox-col {
  width: 48px;
  text-align: center;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

button.chip {
  appearance: none;
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button.chip:hover {
  transform: translateY(-1px);
}

button.chip.clickable {
  box-shadow: inset 0 0 0 1px rgba(216, 107, 45, 0.14);
}

button.chip.clickable:hover {
  box-shadow:
    inset 0 0 0 1px rgba(216, 107, 45, 0.24),
    0 8px 18px rgba(112, 69, 28, 0.08);
}

.chip.business {
  background: rgba(111, 157, 156, 0.18);
  color: #295756;
}

.chip.stage {
  background: rgba(99, 110, 165, 0.14);
  color: #4c5688;
}

.chip.source {
  background: rgba(225, 179, 75, 0.18);
  color: #7b5a10;
}

.chip.status {
  background: rgba(216, 107, 45, 0.14);
  color: var(--brand-deep);
}

.chip.status.done {
  background: rgba(78, 141, 99, 0.16);
  color: #2d6d41;
}

.chip.status.waiting {
  background: rgba(196, 96, 86, 0.16);
  color: #8f3f38;
}

.chip.status.handled {
  background: rgba(111, 157, 156, 0.18);
  color: #295756;
}

.chip.exception {
  background: rgba(92, 58, 34, 0.12);
  color: #6b4527;
}

.chip.exception.pending {
  background: rgba(196, 96, 86, 0.16);
  color: #8f3f38;
}

.chip.exception.resolved {
  background: rgba(139, 83, 43, 0.18);
  color: #7a4215;
}

.chip.exception.clickable {
  box-shadow: inset 0 0 0 1px rgba(196, 96, 86, 0.14);
}

.chip.payment {
  background: rgba(48, 36, 27, 0.08);
  color: var(--ink);
}

.chip.payment.partial {
  background: rgba(225, 179, 75, 0.2);
  color: #7b5a10;
}

.chip.payment.paid {
  background: rgba(78, 141, 99, 0.16);
  color: #2d6d41;
}

.chip.overdue {
  background: rgba(196, 96, 86, 0.16);
  color: #8f3f38;
}

.chip.priority {
  background: rgba(48, 36, 27, 0.08);
}

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

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand-deep);
  cursor: pointer;
  white-space: nowrap;
}

.empty-state {
  color: var(--muted);
  padding: 18px 0 4px;
}

.warning-text {
  color: #8f3f38;
}

.exception-dialog {
  width: min(760px, calc(100% - 24px));
  padding: 0;
  border: none;
  border-radius: 28px;
  background: transparent;
  box-shadow: none;
}

.exception-dialog::backdrop {
  background: rgba(48, 36, 27, 0.42);
  backdrop-filter: blur(6px);
}

.exception-dialog-form {
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.exception-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.exception-dialog-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.22fr);
  gap: 18px;
}

.exception-summary-card,
.exception-fields {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
}

.exception-summary-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 18px;
}

.exception-fields {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.exception-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
}

.exception-toggle-group legend {
  width: 100%;
  margin-bottom: 2px;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

.toggle-chip {
  position: relative;
  display: inline-flex;
}

.toggle-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.toggle-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.toggle-chip input:checked + span {
  border-color: rgba(216, 107, 45, 0.4);
  background: rgba(216, 107, 45, 0.14);
  color: var(--brand-deep);
}

.exception-dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-top: 4px;
}

.stage-dialog {
  width: min(700px, calc(100% - 24px));
  padding: 0;
  border: none;
  border-radius: 28px;
  background: transparent;
  box-shadow: none;
}

.stage-dialog::backdrop {
  background: rgba(48, 36, 27, 0.32);
  backdrop-filter: blur(4px);
}

.stage-dialog-form {
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.stage-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.stage-dialog-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
}

.stage-summary-card,
.stage-fields {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
}

.stage-summary-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 18px;
}

.stage-fields {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.stage-option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stage-option {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.stage-option:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 107, 45, 0.32);
}

.stage-option.is-selected {
  border-color: rgba(111, 157, 156, 0.42);
  background: rgba(111, 157, 156, 0.14);
  color: #295756;
}

.stage-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  padding-top: 4px;
}

@media (max-width: 1100px) {
  .hero,
  .content-grid,
  .sync-grid,
  .stats-grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .batch-actions {
    align-items: flex-start;
  }

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

  .exception-dialog-grid {
    grid-template-columns: 1fr;
  }

  .stage-dialog-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 100%);
    padding-top: 16px;
  }

  .hero-copy,
  .hero-card,
  .panel {
    padding: 18px;
    border-radius: 20px;
  }

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

  .calendar-weekdays,
  .calendar-grid {
    gap: 6px;
  }

  .calendar-cell {
    min-height: 104px;
    padding: 9px;
    border-radius: 16px;
  }

  .calendar-item {
    padding: 6px 7px;
    font-size: 11px;
  }

  .exception-dialog-form {
    padding: 18px;
    border-radius: 22px;
  }

  .stage-dialog-form {
    padding: 18px;
    border-radius: 22px;
  }

  .exception-dialog-actions,
  .exception-dialog-header {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-dialog-actions,
  .stage-dialog-header {
    flex-direction: column;
    align-items: stretch;
  }
}
