:root {
  color-scheme: light;
  --bg: #fff9fd;
  --surface: #ffffff;
  --surface-strong: #fff1f7;
  --ink: #2e2a32;
  --muted: #756d7b;
  --line: #eadfe8;
  --yellow: #ffcf62;
  --mint: #a9e7d5;
  --pink: #ff9fbd;
  --blue: #9ecbff;
  --coral: #ff856f;
  --green: #2f8f73;
  --shadow: 0 12px 28px rgba(80, 54, 77, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 207, 98, 0.24), rgba(255, 249, 253, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    "Pretendard",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    system-ui,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 16px 96px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-row,
.header-actions,
.section-heading,
.panel-title-row,
.item-head,
.item-foot,
.stock-actions,
.button-row {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 12px;
}

.header-actions {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.sunny-visual {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
}

.sun {
  position: absolute;
  inset: 2px auto auto 0;
  width: 34px;
  height: 34px;
  background: var(--yellow);
  border: 3px solid #4f3a2e;
  border-radius: 50%;
}

.cup {
  position: absolute;
  right: 0;
  bottom: 2px;
  width: 34px;
  height: 38px;
}

.cup-lid,
.cup-body,
.cup-sleeve {
  position: absolute;
  display: block;
  border: 3px solid #4f3a2e;
}

.cup-lid {
  top: 0;
  left: 3px;
  width: 28px;
  height: 8px;
  background: #fff;
  border-radius: 8px 8px 2px 2px;
}

.cup-body {
  top: 7px;
  left: 5px;
  width: 24px;
  height: 29px;
  background: #fff;
  border-radius: 4px 4px 8px 8px;
}

.cup-sleeve {
  top: 18px;
  left: 3px;
  width: 28px;
  height: 11px;
  background: var(--pink);
  border-radius: 3px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.header-total {
  display: grid;
  gap: 3px;
  min-width: 124px;
  padding: 10px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.sync-pill[data-tone="saved"] {
  background: rgba(169, 231, 213, 0.45);
  color: #13624f;
}

.sync-pill[data-tone="saving"],
.sync-pill[data-tone="checking"] {
  background: rgba(255, 207, 98, 0.38);
  color: #765000;
}

.sync-pill[data-tone="locked"] {
  background: rgba(255, 159, 189, 0.28);
  color: #9b3151;
}

.sync-pill[data-tone="offline"] {
  background: rgba(255, 133, 111, 0.18);
  color: #a22e22;
}

.lock-button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

.lock-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.header-total span,
.metric-card span,
.meta,
.soft-pill {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.header-total strong {
  font-size: 1.02rem;
}

.top-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tab-button,
.ghost-button,
.primary-button,
.danger-button,
.file-button,
.icon-button,
.stock-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.tab-button {
  flex: 1;
  min-width: 74px;
  padding: 0 12px;
}

.tab-button.is-active,
.mobile-tab.is-active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.tab-panel {
  display: none;
}

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

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 14px;
}

.section-heading time,
#expense-month-total {
  color: var(--muted);
  font-weight: 800;
}

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

.metric-card,
.content-panel,
.filter-panel,
.entry-form,
.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 14px;
}

.metric-card strong {
  font-size: clamp(1.15rem, 3vw, 1.6rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.accent-yellow {
  border-top: 6px solid var(--yellow);
}

.accent-mint {
  border-top: 6px solid var(--mint);
}

.accent-pink {
  border-top: 6px solid var(--pink);
}

.accent-blue {
  border-top: 6px solid var(--blue);
}

.content-panel,
.filter-panel,
.entry-form {
  margin-top: 12px;
  padding: 14px;
}

.brand-panel {
  background:
    linear-gradient(135deg, rgba(255, 207, 98, 0.28), rgba(169, 231, 213, 0.18)),
    var(--surface);
}

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

.brand-point {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid rgba(234, 223, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.brand-point strong {
  font-size: 0.94rem;
}

.brand-point span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.42;
}

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

.profit-strip div {
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.profit-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.profit-strip strong {
  font-size: 1.12rem;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.close-report-panel {
  background:
    linear-gradient(135deg, rgba(255, 159, 189, 0.14), rgba(169, 231, 213, 0.16)),
    var(--surface);
}

.order-draft-panel {
  background:
    linear-gradient(135deg, rgba(255, 207, 98, 0.17), rgba(158, 203, 255, 0.16)),
    var(--surface);
}

.purchase-order-panel {
  background:
    linear-gradient(135deg, rgba(169, 231, 213, 0.15), rgba(255, 159, 189, 0.13)),
    var(--surface);
}

.product-recipe-panel {
  background:
    linear-gradient(135deg, rgba(158, 203, 255, 0.16), rgba(255, 207, 98, 0.16)),
    var(--surface);
}

.inline-entry-form {
  display: grid;
  gap: 12px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr) minmax(90px, 0.55fr));
  gap: 10px;
}

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

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

.order-draft-actions {
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

.order-draft-actions .primary-button {
  width: auto;
  margin-top: 0;
  padding: 0 14px;
}

.purchase-order-list {
  margin-top: 0;
}

.purchase-order-card {
  background: rgba(255, 255, 255, 0.9);
}

.product-card {
  background: rgba(255, 255, 255, 0.9);
}

.recipe-sale-preview {
  margin: 10px 0 0;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.report-stat {
  display: grid;
  gap: 5px;
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.report-stat span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.report-stat strong {
  font-size: 1.02rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.report-preview {
  margin: 12px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.55;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.filter-panel .soft-pill {
  min-height: 42px;
  justify-content: center;
}

.panel-title-row {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.soft-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  background: #f4eef5;
}

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

.form-grid.one-column {
  grid-template-columns: minmax(0, 1fr);
}

.wide-field {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(255, 207, 98, 0.55);
  outline-offset: 2px;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.ghost-button,
.danger-button,
.file-button,
.icon-button,
.stock-button {
  padding: 0 12px;
}

.danger-button {
  border-color: rgba(255, 133, 111, 0.55);
  color: #b03024;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.item-list,
.order-list,
.compact-list,
.expense-summary {
  display: grid;
  gap: 10px;
}

.item-list {
  margin-top: 12px;
}

.item-card {
  padding: 14px;
}

.item-head,
.item-foot {
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  display: grid;
  gap: 3px;
}

.item-title strong {
  font-size: 1rem;
}

.status-pill {
  min-width: 78px;
  padding: 7px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-good {
  background: rgba(169, 231, 213, 0.5);
  color: #13624f;
}

.status-low {
  background: rgba(255, 207, 98, 0.45);
  color: #765000;
}

.status-empty {
  background: rgba(255, 133, 111, 0.2);
  color: #a22e22;
}

.progress-track {
  height: 9px;
  margin: 13px 0;
  overflow: hidden;
  background: #f0e9f1;
  border-radius: 999px;
}

.progress-bar {
  height: 100%;
  width: var(--value);
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--yellow), var(--mint));
}

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

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  background: #fff6d8;
  color: #775302;
  font-size: 0.76rem;
  font-weight: 900;
}

.profile-note {
  margin: 10px 0 0;
  line-height: 1.45;
}

.automation-card.is-done {
  opacity: 0.74;
}

.automation-card.is-done .item-title strong {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.customer-card .status-pill {
  min-width: 64px;
}

.sale-card .mini-pill {
  background: rgba(169, 231, 213, 0.42);
  color: #13624f;
}

.stock-button,
.icon-button {
  width: 42px;
  padding: 0;
}

.receive-button {
  width: auto;
  min-width: 92px;
}

.item-foot {
  flex-wrap: wrap;
  margin-top: 12px;
}

.order-note {
  display: grid;
  gap: 2px;
}

.summary-chip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-state {
  padding: 18px 14px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
}

.action-panel .button-row {
  flex-wrap: wrap;
  gap: 8px;
}

.item-foot .button-row {
  flex-wrap: wrap;
  gap: 8px;
}

.security-panel {
  display: grid;
  gap: 12px;
}

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

.security-form .primary-button {
  grid-column: 1 / -1;
  margin-top: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 30;
  transform: translateX(-50%) translateY(20px);
  min-width: min(320px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(55, 44, 38, 0.42);
  backdrop-filter: blur(12px);
}

.edit-gate {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(55, 44, 38, 0.36);
  backdrop-filter: blur(10px);
}

.auth-gate[hidden],
.edit-gate[hidden] {
  display: none;
}

.auth-panel {
  width: min(100%, 360px);
  display: grid;
  gap: 12px;
  padding: 20px;
  background: #fffaf0;
  border: 1px solid #f1d28e;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.edit-panel {
  width: min(100%, 620px);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.edit-actions {
  justify-content: flex-end;
  gap: 8px;
}

.edit-actions .primary-button {
  width: auto;
  min-width: 120px;
  margin-top: 0;
}

.auth-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 950;
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.48);
}

.auth-panel h2 {
  margin: 0;
  font-size: 1.55rem;
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
}

.mobile-tabs {
  display: none;
}

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

  .app-header {
    align-items: flex-start;
  }

  .header-actions {
    max-width: 190px;
  }

  .header-total {
    min-width: 112px;
  }

  .top-tabs {
    display: none;
  }

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

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

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

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

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

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

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

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

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

  .mobile-tabs {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .mobile-tab {
    display: grid;
    gap: 2px;
    place-items: center;
    min-height: 52px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 0.64rem;
    font-weight: 900;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding: 13px;
  }

  .brand-row {
    gap: 9px;
  }

  .sunny-visual {
    width: 50px;
    height: 50px;
    flex-basis: 50px;
  }

  .header-total {
    padding: 9px;
  }

  .header-actions {
    max-width: 150px;
    gap: 6px;
  }

  .sync-pill,
  .lock-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .header-total span {
    font-size: 0.72rem;
  }

  .metric-grid,
  .brand-grid,
  .profit-strip,
  .close-report-grid,
  .order-draft-grid,
  .filter-panel,
  .recipe-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wide-field {
    grid-column: auto;
  }

  .metric-card {
    min-height: 92px;
  }

  .section-heading {
    align-items: flex-end;
  }

  .order-draft-panel .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .order-draft-actions {
    width: 100%;
  }

  .order-draft-actions .ghost-button,
  .order-draft-actions .primary-button {
    flex: 1;
  }

  .item-head,
  .item-foot {
    align-items: flex-start;
  }

  .stock-actions {
    width: 100%;
  }

  .mobile-tabs {
    left: 8px;
    right: 8px;
    gap: 3px;
    padding: 4px;
  }

  .mobile-tab {
    min-height: 48px;
    font-size: 0.58rem;
  }
}
