:root {
  --bg: #0f1c33;
  --card: #1a2e52;
  --nav: #1f3864;
  --green: #62d477;
  --red: #ff6b6b;
  --amber: #f0c961;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

/* ---------- login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 32px 28px 40px;
  text-align: center;
}

.login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 10px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-sub { color: var(--muted); margin-bottom: 28px; font-size: 14px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 22px;
  letter-spacing: 6px;
  text-align: center;
  padding: 14px;
}

.login-form button {
  background: var(--green);
  color: #06210f;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
}

.login-error { color: var(--red); font-size: 14px; }

/* ---------- app shell ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
}

.header-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f6fa;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.28);
}

#topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: #0f1c33;
}
#topbar-logo { width: 32px; height: 32px; border-radius: 8px; flex: none; }

.icon-btn {
  background: transparent;
  border: none;
  color: #0f1c33;
  font-size: 21px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
}
.icon-btn:active { background: rgba(15,28,51,.1); }

#app { padding: 14px 14px 32px; max-width: 640px; margin: 0 auto; }

h2.section-title { font-size: 16px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }

/* ---------- buttons / grid ---------- */
.btn-grid { display: grid; gap: 10px; }
.btn-grid.cols-2 { grid-template-columns: 1fr 1fr; }

.btn {
  display: block;
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 12px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.btn:active { background: var(--nav); }
.btn.primary { background: var(--green); color: #06210f; border: none; }
.btn.danger-outline { color: var(--red); border-color: rgba(255,107,107,.4); }
.btn.small { padding: 9px 10px; font-size: 14px; }

.date-range { display: flex; gap: 8px; align-items: center; }
.date-range input[type=date] {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
}

/* ---------- report ---------- */
.report-header { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.period-line { font-size: 14px; color: var(--muted); margin-bottom: 10px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}
.stat-row .label { color: var(--muted); }
.stat-row .value.pos { color: var(--green); font-weight: 700; }
.stat-row .value.neg { color: var(--red); font-weight: 700; }
.stat-row .value.bold { font-weight: 700; }

.emoji-row { display: flex; justify-content: space-between; gap: 6px; margin: 14px 0; }
.emoji-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 4px;
  cursor: pointer;
}
.emoji-btn:active { background: var(--nav); }
.emoji-btn .emoji { font-size: 30px; line-height: 1; }
.emoji-btn .count { font-size: 15px; font-weight: 700; }

.card { background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }

/* ---------- order list ---------- */
.tabs { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 4px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
}
.tab .tab-emoji { font-size: 26px; line-height: 1; }
.tab.active { background: var(--green); }

.search-box {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 15px;
  margin-bottom: 12px;
}

.order-card { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.order-card-top { display: flex; gap: 10px; align-items: flex-start; }
.order-card img.thumb { width: 66px; height: 88px; border-radius: 10px; object-fit: cover; background: #0f1c33; flex: none; }
.order-card .thumb.placeholder { width: 66px; height: 88px; border-radius: 10px; background: #0f1c33; flex: none; }
.order-card-info { flex: 1; min-width: 0; }
.order-id { font-weight: 700; font-size: 15px; }
.order-date { color: var(--muted); font-size: 13px; }
.order-sku { font-size: 14px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.order-name { font-size: 14px; color: var(--text); margin-top: 2px; word-break: break-word; }
.order-status-badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); margin-top: 4px; display: inline-block; }

.fin-table { margin-top: 10px; font-size: 14px; }
.fin-table .row { display: flex; justify-content: space-between; padding: 4px 0; align-items: center; }
.fin-table .row .v.neg { color: var(--red); }
.fin-table .row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 7px; font-weight: 700; font-size: 16px; }
.fin-table .row.total .v.pos { color: var(--green); }
.fin-table .row.total .v.neg { color: var(--red); }

.pkg-value-btn {
  background: transparent;
  border: none;
  color: var(--red);
  font-size: 14px;
  font-weight: inherit;
  padding: 2px 0;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}

.order-link { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--green); text-decoration: none; }

.empty-state { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 15px; }

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.spinner-wrap { display: flex; justify-content: center; padding: 40px 0; color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
