:root {
  color-scheme: light;
  --ink: #101728;
  --muted: #6d7482;
  --line: #e8e9ed;
  --surface: #ffffff;
  --canvas: #f4f5f7;
  --brand: #ff4f1f;
  --brand-dark: #d93612;
  --good: #087b5b;
  --good-soft: #e5f6f0;
  --watch: #9a6300;
  --watch-soft: #fff1cf;
  --stop: #bd2130;
  --stop-soft: #ffe8eb;
  --navy: #14213d;
  --shadow: 0 14px 44px rgba(20, 33, 61, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 2px 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-dark);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.025em; }
h3 { margin-bottom: 0; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .text-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: .86rem;
  font-weight: 700;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  color: var(--muted);
  background: rgba(255,255,255,.66);
  border-radius: 999px;
  font-size: .78rem;
  white-space: nowrap;
}
.sync-state i { width: 8px; height: 8px; border-radius: 50%; background: #aeb3bd; }
.sync-state.live i { background: var(--good); box-shadow: 0 0 0 4px rgba(8,123,91,.12); }

.decision-strip {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  overflow: hidden;
  border-radius: 22px;
  background: var(--navy);
  box-shadow: var(--shadow);
}

.metric { min-height: 142px; padding: 24px; color: #fff; border-left: 1px solid rgba(255,255,255,.12); }
.metric:first-child { border-left: 0; }
.metric span, .metric small { display: block; color: rgba(255,255,255,.64); font-size: .82rem; }
.metric strong { display: block; margin: 14px 0 8px; font-size: 2rem; letter-spacing: -.04em; }
.hero-metric { position: relative; background: var(--brand); }
.hero-metric::after { content: ""; position: absolute; width: 90px; height: 90px; right: -34px; bottom: -34px; border: 18px solid rgba(255,255,255,.12); border-radius: 50%; }
.hero-metric span, .hero-metric small { color: rgba(255,255,255,.82); }

.tabs { display: flex; gap: 24px; margin: 30px 0 0; border-bottom: 1px solid #dedfe4; }
.tab { position: relative; padding: 0 2px 14px; border: 0; background: transparent; color: var(--muted); font-weight: 750; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }
.tab b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: #e3e5e9; font-size: .72rem; }
.tab.active b { background: var(--stop-soft); color: var(--stop); }

.view { padding-top: 28px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.orders-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.order-card { background: var(--surface); border: 1px solid rgba(20,33,61,.07); border-radius: 20px; padding: 20px; box-shadow: 0 8px 30px rgba(20,33,61,.045); }
.order-head { display: flex; align-items: flex-start; gap: 12px; }
.order-index { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--navy); color: white; font-size: .78rem; font-weight: 850; }
.order-title-wrap { min-width: 0; flex: 1; }
.order-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 1rem; }
.media-title { margin: 5px 0 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: .82rem; }
.confidence { color: var(--muted); font-size: .72rem; white-space: nowrap; }

.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.decision { min-height: 88px; border-radius: 14px; padding: 14px; background: #f3f4f6; }
.decision span { display: block; margin-bottom: 10px; color: var(--muted); font-size: .72rem; }
.decision strong { font-size: .96rem; line-height: 1.35; }
.decision.scale, .decision.good { background: var(--good-soft); color: var(--good); }
.decision.watch { background: var(--watch-soft); color: var(--watch); }
.decision.stop, .decision.weak { background: var(--stop-soft); color: var(--stop); }

.numbers-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.numbers-row span { display: block; color: var(--muted); font-size: .7rem; }
.numbers-row strong { display: block; margin-top: 6px; font-size: 1rem; }
.creative-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.creative-row span { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .7rem; }
.evidence-list { margin: 16px 0 0; padding: 13px 0 0 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; line-height: 1.65; }

.empty-state { padding: 70px 20px; text-align: center; background: rgba(255,255,255,.55); border: 1px dashed #cfd2d9; border-radius: 20px; }
.empty-state.compact { padding: 45px 20px; }
.empty-state p { max-width: 480px; margin: 9px auto 0; color: var(--muted); line-height: 1.65; }
.empty-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; margin-bottom: 14px; border-radius: 14px; color: white; background: var(--brand); font-weight: 900; }

.review-list, .session-list { display: grid; gap: 10px; }
.review-item, .session-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 18px; background: var(--surface); border-radius: 15px; }
.review-item strong, .session-item strong { display: block; font-size: .9rem; }
.review-item p, .session-item p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; }
.status-pill { padding: 6px 9px; border-radius: 999px; background: #eef0f3; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.status-pill.complete { color: var(--good); background: var(--good-soft); }
.status-pill.needs_review, .status-pill.failed { color: var(--stop); background: var(--stop-soft); }
.status-pill.processing, .status-pill.queued { color: var(--watch); background: var(--watch-soft); }

.login-panel { display: grid; min-height: calc(100vh - 110px); place-items: center; }
.login-card { width: min(100%, 440px); padding: 32px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.login-symbol { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 22px; border-radius: 14px; background: var(--brand); color: white; font-size: 1.25rem; font-weight: 900; }
.login-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.login-card label { display: block; margin: 22px 0 8px; font-size: .82rem; font-weight: 750; }

.setup-dialog { width: min(92vw, 720px); max-height: 88vh; padding: 0; overflow: hidden; border: 0; border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: 0 28px 90px rgba(22, 17, 13, .24); }
.setup-dialog::backdrop { background: rgba(22, 17, 13, .48); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 3px 0 0; }
.dialog-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); font-size: 1.6rem; cursor: pointer; }
.setup-body { max-height: calc(88vh - 90px); padding: 22px 26px 30px; overflow-y: auto; }
.setup-card { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.setup-card h3, .manual-upload h3 { margin: 0 0 7px; }
.setup-card p, .manual-upload p, .shortcut-steps li { margin: 0; color: var(--muted); line-height: 1.65; }
.setup-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--soft); color: var(--brand); font-size: .78rem; font-weight: 850; }
.primary-button { margin-top: 14px; padding: 11px 16px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; cursor: pointer; }
.primary-button:disabled { opacity: .45; cursor: default; }
#tokenPreview { display: inline-block; margin-left: 10px; padding: 7px 10px; border-radius: 9px; background: var(--soft); color: var(--muted); }
.shortcut-steps { margin: 18px 0; padding: 16px 18px; border-radius: 16px; background: var(--soft); }
.shortcut-steps summary { cursor: pointer; font-weight: 800; }
.shortcut-steps ol { margin: 14px 0 0; padding-left: 20px; }
.shortcut-steps li + li { margin-top: 8px; }
.manual-upload { margin-top: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; }
.file-picker { display: block; margin-top: 14px; padding: 16px; border: 1px dashed var(--muted); border-radius: 13px; text-align: center; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker span { font-weight: 800; }
.setup-status { min-height: 1.5em; margin-top: 10px !important; color: var(--brand) !important; }

@media (max-width: 640px) {
  .setup-dialog { width: 100vw; max-width: none; max-height: 94vh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .setup-body { max-height: calc(94vh - 90px); padding: 18px 20px 28px; }
  .dialog-head { padding: 20px; }
  #tokenPreview { display: block; width: max-content; margin: 10px 0 0; }
}
.password-row { display: flex; gap: 8px; }
.password-row input { min-width: 0; flex: 1; height: 48px; padding: 0 13px; border: 1px solid #d8dae0; border-radius: 12px; background: #fafafa; }
.password-row input:focus { outline: 3px solid rgba(255,79,31,.13); border-color: var(--brand); }
.password-row button { border: 0; border-radius: 12px; padding: 0 18px; color: white; background: var(--navy); font-weight: 750; }
.form-error { min-height: 20px; margin: 8px 0 0 !important; color: var(--stop) !important; font-size: .78rem; }

@media (max-width: 760px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .topbar { align-items: flex-start; }
  .sync-state { display: none; }
  .decision-strip { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 116px; padding: 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
  .metric:nth-child(3) { border-left: 0; }
  .metric strong { margin: 12px 0 6px; font-size: 1.6rem; }
  .orders-list { grid-template-columns: 1fr; }
  .numbers-row { grid-template-columns: 1fr 1fr; row-gap: 14px; }
  .tabs { gap: 18px; overflow-x: auto; }
  .tab { white-space: nowrap; }
}

@media (prefers-reduced-motion: no-preference) {
  .order-card { animation: rise .28s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(7px); } }
}
