:root {
  --bg0: #fbf5ef;
  --bg1: #f3e4d6;
  --bg2: #fffaf4;
  --card: rgba(255, 255, 255, 0.96);
  --surface: rgba(255, 248, 241, 0.9);
  --text: #261a10;
  --muted: rgba(38, 26, 16, 0.66);
  --line: rgba(38, 26, 16, 0.11);
  --accent: #8c3f0f;
  --accent-strong: #6f2c08;
  --accent-soft: #fff0e4;
  --green: #1e7d41;
  --red: #b33628;
  --amber: #b67a08;
  --shadow: 0 16px 44px rgba(71, 39, 15, 0.12);
  --shadow-soft: 0 10px 28px rgba(71, 39, 15, 0.09);
  --radius: 20px;
  --radius2: 14px;
  --pad: 16px;
  --font: "Avenir Next", "Poppins", "Trebuchet MS", "Gill Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg0);
}
body {
  margin: 0;
  min-height: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at top left, rgba(255, 208, 168, 0.52), transparent 36%),
    radial-gradient(circle at 85% 15%, rgba(199, 232, 191, 0.52), transparent 30%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 62%, var(--bg2));
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

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

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  border-color: rgba(140, 63, 15, 0.5);
  box-shadow: 0 0 0 3px rgba(140, 63, 15, 0.14);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.app {
  min-height: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  backdrop-filter: blur(12px);
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.96), rgba(255, 248, 241, 0.84));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(71, 39, 15, 0.08);
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.72), transparent 30%),
    linear-gradient(140deg, #8c3f0f, #c55c18 60%, #f1a134);
  display: grid;
  place-items: center;
  color: #fff9f4;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(140, 63, 15, 0.24);
}

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(140, 63, 15, 0.22);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-chip,
.soft-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.role-chip {
  background: rgba(140, 63, 15, 0.12);
  color: var(--accent-strong);
}

.soft-chip {
  background: rgba(30, 125, 65, 0.09);
  color: #165a2f;
}

.topbar-signout {
  padding: 8px 12px;
}

.app-version {
  font-size: 11px;
  color: var(--muted);
}

.content {
  flex: 1;
  max-width: 1160px;
  margin: 0 auto;
  width: 100%;
  padding: 16px 16px 104px 16px;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: var(--pad);
}

.hero-card {
  background:
    radial-gradient(circle at top left, rgba(255, 208, 168, 0.22), transparent 35%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 249, 244, 0.94));
  box-shadow: var(--shadow);
}

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

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.section-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }

.btn {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

.btn-primary {
  background: linear-gradient(140deg, #8c3f0f, #c55c18 72%, #df8f32);
  color: #fff9f4;
  box-shadow: 0 12px 24px rgba(140, 63, 15, 0.22);
}

.btn-secondary {
  border-color: rgba(140, 63, 15, 0.18);
  background: rgba(255, 248, 241, 0.96);
}

.btn-danger {
  border-color: rgba(179, 54, 40, 0.2);
  color: var(--red);
  background: rgba(255, 241, 239, 0.94);
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.notice {
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 13px;
}

.notice-ok {
  border-color: rgba(30, 125, 65, 0.18);
  background: rgba(234, 251, 240, 0.95);
  color: #165a2f;
}

.notice-warn {
  border-color: rgba(182, 122, 8, 0.18);
  background: rgba(255, 248, 226, 0.95);
  color: #855805;
}

.notice-error {
  border-color: rgba(179, 54, 40, 0.18);
  background: rgba(255, 240, 237, 0.96);
  color: #8f2218;
}

.auth-shell {
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.auth-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.auth-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.stat {
  border: 1px solid rgba(140, 63, 15, 0.12);
  background: rgba(255, 248, 241, 0.85);
  border-radius: 16px;
  padding: 12px;
}

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

.stat-value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
}

.line-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line-card {
  border: 1px solid rgba(140, 63, 15, 0.1);
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.98), rgba(255, 246, 240, 0.94));
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-card-title {
  font-weight: 800;
}

.sku-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.sku-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(140, 63, 15, 0.1);
  color: var(--accent-strong);
}

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

.summary-tile {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(38, 26, 16, 0.08);
  padding: 10px 12px;
}

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

.summary-tile-value {
  margin-top: 5px;
  font-size: 15px;
  font-weight: 800;
}

.checkout-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.cash-shortcut {
  min-width: 90px;
}

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

.sku-entry-card {
  border: 1px dashed rgba(140, 63, 15, 0.24);
  background: rgba(255, 251, 247, 0.96);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.inline-ghost {
  min-height: 0;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sale-row {
  border: 1px solid rgba(38, 26, 16, 0.09);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.sale-row-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.sale-row-title {
  font-size: 15px;
  font-weight: 800;
}

.sale-row-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.sale-row-amount {
  text-align: right;
  min-width: 120px;
}

.sale-row-total {
  font-size: 18px;
  font-weight: 800;
}

.ticket-wrap {
  display: flex;
  justify-content: center;
}

.ticket80-shell {
  width: 100%;
  display: flex;
  justify-content: center;
}

.ticket80 {
  width: min(100%, 360px);
  background: linear-gradient(180deg, #fffefa, #fff8f0);
  border: 1px solid rgba(38, 26, 16, 0.1);
  border-radius: 20px;
  box-shadow: 0 18px 42px rgba(51, 31, 18, 0.15);
  padding: 18px 16px;
  color: #18100a;
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticket80-center {
  text-align: center;
}

.ticket80-brand {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.ticket80-sub {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(24, 16, 10, 0.78);
}

.ticket80-rule {
  border-top: 1px dashed rgba(24, 16, 10, 0.42);
  margin: 2px 0;
}

.ticket80-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.ticket80-row strong {
  text-align: right;
  font-size: 12px;
}

.ticket80-total {
  font-size: 14px;
  font-weight: 800;
}

.ticket80-total strong {
  font-size: 14px;
}

.ticket80-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket80-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ticket80-item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
}

.ticket80-item-name,
.ticket80-item-total {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.ticket80-item-total {
  text-align: right;
}

.ticket80-item-sub,
.ticket80-note {
  font-size: 11px;
  line-height: 1.45;
  color: rgba(24, 16, 10, 0.8);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(38, 26, 16, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  backdrop-filter: blur(12px);
  background: rgba(255, 252, 248, 0.92);
  border-top: 1px solid rgba(38, 26, 16, 0.1);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav-inner {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.nav-item-active {
  color: var(--accent-strong);
  background: rgba(255, 243, 233, 0.98);
  border-color: rgba(140, 63, 15, 0.14);
  box-shadow: 0 10px 24px rgba(140, 63, 15, 0.12);
}

.nav-icon {
  font-size: 14px;
  font-weight: 900;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-item {
  border-radius: 16px;
  border: 1px solid rgba(38, 26, 16, 0.08);
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
}

.help-item-title {
  font-size: 14px;
  font-weight: 800;
}

.help-item-body {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.delta-pos { color: var(--green); }
.delta-neg { color: var(--red); }

@media (max-width: 880px) {
  .grid4,
  .stats-grid,
  .checkout-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .grid2,
  .grid3,
  .grid4,
  .line-summary,
  .stats-grid,
  .checkout-stats-grid {
    grid-template-columns: 1fr;
  }

  .sale-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .sale-row-amount {
    min-width: 0;
    text-align: left;
  }

  .sku-entry-row {
    grid-template-columns: 1fr;
  }

  .topbar-meta {
    align-items: flex-start;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@page {
  size: 80mm auto;
  margin: 4mm;
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .bottom-nav,
  .no-print {
    display: none !important;
  }

  .content {
    max-width: none;
    padding: 0;
  }

  .ticket-wrap,
  .ticket80-shell {
    justify-content: flex-start;
  }

  .ticket80 {
    width: 72mm;
    max-width: none;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0;
  }
}
