* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --page: #f6e7c7;
  --page-2: #fbf0db;
  --panel: rgba(255, 250, 241, 0.74);
  --panel-2: rgba(255, 243, 221, 0.82);
  --panel-strong: rgba(255, 248, 232, 0.94);
  --border: rgba(165, 110, 24, 0.16);
  --border-strong: rgba(255, 255, 255, 0.7);
  --ink-1: #1b130d;
  --ink-2: #4d3923;
  --ink-3: #8a6d4b;
  --accent: #d66d11;
  --accent-2: #17130e;
  --accent-soft: rgba(214, 109, 17, 0.12);
  --accent-soft-2: rgba(23, 19, 14, 0.08);
  --on-accent: #fff9f2;
  --success: #2f7a55;
  --danger: #c14e41;
  --warn: #b77a16;
  --shadow: 0 12px 30px rgba(132, 84, 20, 0.08);
  --shadow-lg: 0 42px 96px -56px rgba(132, 84, 20, 0.3);
  --r-sm: 14px;
  --r: 24px;
  --r-lg: 32px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink-1);
  background: linear-gradient(180deg, #f8edd3 0%, #f6e7c7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 4% -10%, rgba(255, 233, 186, 0.7), transparent 58%),
    radial-gradient(680px 420px at 96% 0%, rgba(228, 154, 58, 0.14), transparent 52%),
    radial-gradient(700px 420px at 30% 112%, rgba(255, 242, 216, 0.7), transparent 52%);
  opacity: 0.8;
}

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

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

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(214, 109, 17, 0.26);
  outline-offset: 2px;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  padding: 20px;
  gap: 18px;
}

.sidebar {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 40px);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: rgba(255, 248, 235, 0.55);
  backdrop-filter: blur(24px) saturate(135%);
  -webkit-backdrop-filter: blur(24px) saturate(135%);
  box-shadow: var(--shadow-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  color: var(--on-accent);
  background: #17130e;
  box-shadow: 0 14px 26px rgba(23, 19, 14, 0.14);
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-sub {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 12px;
}

.rail-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 251, 243, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.rail-card-soft {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 232, 188, 0.72));
}

.rail-kicker {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.rail-big {
  margin-top: 8px;
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

.rail-copy {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 16px;
  color: var(--ink-2);
  background: transparent;
  font-weight: 650;
}

.nav-item.active {
  color: var(--on-accent);
  background: #17130e;
  box-shadow: 0 12px 22px rgba(23, 19, 14, 0.12);
}

.nav-ic {
  display: inline-flex;
  width: 24px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  min-width: 0;
  padding: 2px 2px 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.topbar-copy {
  min-width: 0;
}

.breadcrumb {
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 650;
}

.page-title {
  margin: 6px 0 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 750;
  white-space: nowrap;
}

.primary-btn {
  color: var(--on-accent);
  background: #17130e;
  box-shadow: 0 14px 24px rgba(23, 19, 14, 0.16);
}

.secondary-btn {
  color: var(--accent);
  background: rgba(214, 109, 17, 0.12);
}

.ghost-btn {
  color: var(--ink-2);
  border: 1px solid var(--border);
  background: rgba(255, 251, 244, 0.7);
}

.page-shell {
  min-width: 0;
  padding: 4px 0 90px;
}

.page-grid {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.12fr) 340px;
}

.hero-card,
.card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(255, 250, 242, 0.88), rgba(255, 242, 215, 0.7)), var(--panel);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 280px;
  gap: 18px;
  align-items: stretch;
  padding: 22px;
}

.hero-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
  max-width: 11ch;
}

.hero-copy {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.65;
  max-width: 54ch;
  overflow-wrap: anywhere;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-side {
  display: grid;
  gap: 12px;
}

.glass-tile {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.glass-kicker {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.glass-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0;
}

.glass-sub {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}

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

.kpi {
  padding: 16px;
  border-radius: 24px;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(214, 109, 17, 0.12);
  font-size: 14px;
  font-weight: 800;
}

.kpi-label {
  margin-top: 16px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}

.kpi-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.kpi-note {
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.kpi-tone-danger .icon-chip {
  color: var(--danger);
  background: rgba(193, 78, 65, 0.12);
}

.kpi-tone-success .icon-chip {
  color: var(--success);
  background: rgba(47, 122, 85, 0.12);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-sub {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.mini-stack {
  display: grid;
  gap: 14px;
}

.queue-card,
.recent-card,
.form-card,
.template-card,
.customer-card,
.invoice-card,
.filter-card {
  padding: 18px;
  border-radius: 26px;
}

.queue-item,
.recent-item,
.customer-item,
.invoice-item {
  display: grid;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid rgba(165, 110, 24, 0.1);
}

.queue-item:first-child,
.recent-item:first-child,
.customer-item:first-child,
.invoice-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.row-copy {
  min-width: 0;
}

.row-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.row-meta,
.row-note {
  margin-top: 5px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.row-amount {
  text-align: right;
}

.money {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-open {
  color: var(--accent);
  background: rgba(214, 109, 17, 0.12);
}

.status-overdue {
  color: var(--danger);
  background: rgba(193, 78, 65, 0.12);
}

.status-paid {
  color: var(--success);
  background: rgba(47, 122, 85, 0.12);
}

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

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.form-stack {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.step-card {
  padding: 18px;
}

.step-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--on-accent);
  background: #17130e;
  font-size: 13px;
  font-weight: 800;
}

.step-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.step-desc {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

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

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

.field {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}

.required {
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  color: var(--ink-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.textarea {
  min-height: 120px;
  padding-top: 12px;
  padding-bottom: 12px;
  resize: vertical;
  line-height: 1.55;
}

.helper,
.error-text {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.helper {
  color: var(--ink-3);
}

.error-text {
  color: var(--danger);
}

.check-card {
  padding: 18px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.check-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid rgba(165, 110, 24, 0.1);
}

.check-row:first-child {
  border-top: 0;
}

.check-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.check-ok .check-mark {
  color: var(--success);
  background: rgba(47, 122, 85, 0.12);
}

.check-fail .check-mark {
  color: var(--danger);
  background: rgba(193, 78, 65, 0.12);
}

.check-label {
  font-size: 13px;
  font-weight: 750;
}

.check-value {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.check-target {
  align-self: center;
}

.preview-card {
  position: sticky;
  top: 20px;
  padding: 18px;
}

.preview-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 800;
}

.preview-grid {
  display: grid;
  gap: 10px;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid rgba(165, 110, 24, 0.1);
  color: var(--ink-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.preview-row:first-of-type {
  border-top: 0;
}

.preview-row strong {
  color: var(--ink-1);
  text-align: right;
}

.preview-total {
  margin-top: 10px;
  padding: 14px;
  border-radius: 18px;
  color: var(--accent);
  background: rgba(214, 109, 17, 0.12);
}

.preview-total span {
  display: block;
  color: var(--ink-3);
  font-size: 12px;
}

.preview-total strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  letter-spacing: 0;
}

.commit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 249, 240, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.draft-state {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.filter-card {
  display: grid;
  gap: 14px;
}

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

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--ink-2);
  background: rgba(255, 250, 243, 0.72);
  border: 1px solid transparent;
  font-weight: 700;
}

.tab.active {
  color: var(--on-accent);
  background: #17130e;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.search {
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--ink-1);
  background: var(--panel-2);
}

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

.invoice-card,
.customer-card {
  padding: 18px;
}

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

.token-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.token {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(214, 109, 17, 0.12);
  font-size: 12px;
  font-weight: 750;
}

.template-stack {
  display: grid;
  gap: 14px;
}

.template-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.template-name {
  font-size: 16px;
  font-weight: 850;
}

.template-scene {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 12px;
}

.template-footer {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.mobile-nav {
  display: none;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 220px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast strong {
  display: block;
  margin-bottom: 3px;
}

.empty-state {
  padding: 36px 20px;
  border-radius: 28px;
  text-align: center;
}

.empty-title {
  font-size: 18px;
  font-weight: 850;
}

.empty-copy {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.dashboard-aside {
  display: grid;
  gap: 14px;
  align-content: start;
}

.aside-mini {
  padding: 16px;
}

.aside-mini-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid rgba(165, 110, 24, 0.1);
  color: var(--ink-2);
  font-size: 13px;
}

.aside-mini-row:first-child {
  border-top: 0;
}

.aside-mini-row strong {
  color: var(--ink-1);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(214, 109, 17, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.muted {
  color: var(--ink-3);
}

.mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.nowrap {
  white-space: nowrap;
}

.mobile-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  border-radius: 16px;
  color: var(--ink-2);
  font-weight: 750;
  white-space: nowrap;
}

.mobile-nav-item.active {
  color: var(--on-accent);
  background: #17130e;
}

.mobile-nav-primary {
  color: var(--on-accent);
  background: rgba(23, 19, 14, 0.95);
}

.invoice-head,
.customer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.stack-note {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
}

.spacer-8 {
  height: 8px;
}

@media (max-width: 1160px) {
  .dashboard-grid,
  .form-layout {
    grid-template-columns: 1fr;
  }

  .preview-card {
    position: static;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    position: sticky;
    bottom: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: rgba(255, 248, 236, 0.78);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: var(--shadow);
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .field-row,
  .search-row {
    grid-template-columns: 1fr;
  }

  .row-main,
  .invoice-head,
  .customer-head {
    grid-template-columns: 1fr;
  }

  .row-amount {
    text-align: left;
  }

  .topbar-actions,
  .commit-actions,
  .item-actions,
  .hero-actions,
  .tabs,
  .token-bar,
  .template-footer {
    width: 100%;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 12px;
    padding-left: 12px;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .tab,
  .mobile-nav-item {
    white-space: normal;
    text-align: center;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .money {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .commit-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: 88px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding: 12px;
  }

  .page-title {
    font-size: 26px;
  }

  .hero-title {
    font-size: 26px;
  }

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

  .mobile-nav-item:nth-child(n + 4) {
    display: none;
  }

  .mobile-nav-primary {
    order: -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
