:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #fbfcfe;
  --text: #171a1f;
  --muted: #6b7280;
  --subtle: #9aa3af;
  --line: #dde2ea;
  --line-strong: #cfd6e0;
  --accent: #f47b20;
  --accent-dark: #d96512;
  --accent-soft: #fff0e4;
  --ink: #202734;
  --warn: #b45309;
  --pill-ordered-bg: #eef2ff;
  --pill-ordered-fg: #3446a8;
  --pill-transit-bg: #fff0db;
  --pill-transit-fg: #c75200;
  --pill-delivered-bg: #e8f6ee;
  --pill-delivered-fg: #1f7a45;
  --pill-unknown-bg: #eef0f3;
  --pill-unknown-fg: #616975;
  --pill-direct-bg: #f3eafd;
  --pill-direct-fg: #7a2eb0;
  --shadow: 0 12px 30px rgb(28 35 45 / 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p { margin: 0; }

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

.app-header {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 20px 24px 16px;
}

.header-shell {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  max-width: 1180px;
  margin: 0 auto;
}

.brand-block {
  min-width: 0;
}

.brand-kicker {
  color: var(--accent);
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.app-header h1 {
  color: var(--ink);
  font-size: 28px;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-block p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 5px;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ctrl-icon {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: #303743;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  min-width: 38px;
  padding: 0;
  width: 38px;
}

.ctrl-icon:hover { background: #eef2f7; }

.ctrl-sync {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  height: 38px;
  min-width: 76px;
  padding: 0 14px;
  white-space: nowrap;
}

.ctrl-sync:hover { background: var(--accent-dark); }

.summary-panel {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr));
  margin: 18px auto 0;
  max-width: 1180px;
}

.summary-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 94px;
  padding: 14px 16px;
}

.summary-card.primary {
  background: linear-gradient(135deg, #202734, #3a4352);
  border-color: #202734;
  color: #fff;
  box-shadow: var(--shadow);
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-card.primary span,
.summary-card.primary small { color: rgb(255 255 255 / 0.72); }

.summary-card strong {
  color: var(--ink);
  font-size: 30px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
}

.summary-card.primary strong { color: #fff; }

.summary-card small {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(280px, 1fr) auto;
  margin: 16px auto 0;
  max-width: 1180px;
}

.search-wrap {
  min-width: 0;
  position: relative;
}

.search-wrap .search-icon {
  color: var(--muted);
  left: 14px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.search-wrap input {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  height: 42px;
  outline: none;
  padding: 0 14px 0 38px;
  width: 100%;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(244 123 32 / 0.14);
}

.search-wrap input::placeholder { color: var(--subtle); }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 750;
  height: 36px;
  padding: 0 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.chip:hover { background: #eef2f7; }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.order-list {
  flex: 1;
  margin: 0 auto;
  max-width: 1180px;
  padding: 18px 24px 40px;
  width: 100%;
}

.month-group { margin-top: 20px; }
.month-group:first-child { margin-top: 0; }

.month-label {
  align-items: center;
  color: #4b5563;
  display: flex;
  font-size: 13px;
  font-weight: 850;
  gap: 10px;
  margin-bottom: 8px;
}

.month-label::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

.order-card {
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(28 35 45 / 0.04);
  cursor: default;
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  padding: 16px;
  position: relative;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}

.order-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgb(28 35 45 / 0.07);
  transform: translateY(-1px);
}

.thumb {
  align-items: center;
  background: #eef2f7;
  border: 1px solid #e4e9f0;
  border-radius: 8px;
  color: #8b96a6;
  display: flex;
  flex-shrink: 0;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.order-body {
  flex: 1;
  min-width: 0;
}

.order-topline {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.order-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.35;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  min-width: 0;
}

.order-details span {
  align-items: center;
  background: #f6f8fb;
  border: 1px solid #edf0f4;
  border-radius: 8px;
  color: #4b5563;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  min-height: 28px;
  min-width: 0;
  padding: 4px 8px;
}

.order-details b {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 850;
}

.tracking-code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.tracking-code b {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.order-details .missing {
  color: var(--subtle);
}

.order-status-row {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 7px;
}

.pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.5;
  padding: 3px 9px;
  white-space: nowrap;
}

.pill-ordered { background: var(--pill-ordered-bg); color: var(--pill-ordered-fg); }
.pill-in_transit { background: var(--pill-transit-bg); color: var(--pill-transit-fg); }
.pill-delivered { background: var(--pill-delivered-bg); color: var(--pill-delivered-fg); }
.pill-unknown { background: var(--pill-unknown-bg); color: var(--pill-unknown-fg); }
.pill-direct { background: var(--pill-direct-bg); color: var(--pill-direct-fg); }

.dot {
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(244 123 32 / 0.14);
  flex-shrink: 0;
  height: 7px;
  width: 7px;
}

.empty-state {
  align-items: center;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  margin-top: 28px;
  padding: 48px 20px;
  text-align: center;
}

.empty-icon {
  align-items: center;
  background: #eef2f7;
  border-radius: 8px;
  color: #8b96a6;
  display: flex;
  height: 54px;
  justify-content: center;
  margin-bottom: 16px;
  width: 54px;
}

.empty-state h2 {
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
}

.empty-state p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  max-width: 420px;
}

.empty-action {
  margin-top: 18px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: min(520px, calc(100% - 24px));
  padding: 0;
  width: 520px;
}

dialog::backdrop { background: rgb(23 32 42 / 0.4); }

#settingsForm {
  display: grid;
  gap: 14px;
  padding: 20px;
}

#settingsForm header,
#settingsForm footer {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

#settingsForm footer {
  flex-wrap: wrap;
  justify-content: flex-end;
}

#settingsForm h2 {
  color: var(--ink);
  font-size: 18px;
}

#settingsForm label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

#settingsForm input[type="text"],
#settingsForm input[type="password"],
#settingsForm input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  padding: 10px 12px;
}

.account-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  max-height: 168px;
  overflow: auto;
}

.account-row {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  display: grid;
  font: inherit;
  justify-items: start;
  min-width: 0;
  padding: 10px 12px;
  text-align: left;
}

.account-row:hover { background: #eef2f7; }
.account-row:last-child { border-bottom: 0; }

.account-row small,
.account-empty { color: var(--muted); }

.account-empty {
  font-size: 13px;
  padding: 12px;
}

.inline-check {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
}

.inline-check input { width: auto; }

#settingsStatus {
  color: var(--warn);
  font-size: 13px;
}

.icon-button {
  background: #eef2f7;
  color: var(--text);
  padding: 8px 14px;
}

.icon-button:hover { background: #dde3ea; }

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

#settingsForm button,
.empty-action {
  background: var(--accent);
  color: white;
  padding: 8px 14px;
}

#settingsForm button:hover,
.empty-action:hover {
  background: var(--accent-dark);
}

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

  .header-shell {
    display: grid;
  }

  .header-actions {
    overflow-x: auto;
    padding-bottom: 1px;
  }

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

  .toolbar {
    grid-template-columns: 1fr;
  }

  .order-list {
    padding: 14px 16px 32px;
  }
}

@media (max-width: 560px) {
  .app-header h1 {
    font-size: 24px;
  }

  .brand-block p {
    font-size: 13px;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 82px;
  }

  .order-card {
    gap: 12px;
    padding: 14px;
  }

  .thumb {
    height: 44px;
    width: 44px;
  }

  .order-topline {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .order-title {
    white-space: normal;
  }

  .order-details {
    display: grid;
  }
}
