* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #1f2933; background: #f5f7fa; }
#app { min-height: 100vh; display: grid; grid-template-columns: 360px 1fr; }
#app.locked { display: none; }
.login-screen { position: fixed; inset: 0; display: grid; place-items: center; background: #f5f7fa; z-index: 10; }
.login-screen.hidden { display: none; }
.login-box { width: min(420px, calc(100vw - 32px)); background: #fff; border: 1px solid #d9e2ec; border-radius: 8px; padding: 22px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); }
.login-box h1 { margin-bottom: 18px; }
#loginStatus { min-height: 20px; color: #b42318; font-size: 13px; margin-top: 8px; }
.setup-only { display: none; }
.setup-mode .setup-only { display: block; }
aside { background: #ffffff; border-right: 1px solid #d9e2ec; padding: 18px; overflow: auto; height: 100vh; }
h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 24px 0 12px; font-size: 15px; color: #52606d; }
label { display: block; font-size: 12px; color: #52606d; margin: 10px 0; }
input, select, textarea { width: 100%; margin-top: 5px; border: 1px solid #bcccdc; border-radius: 6px; padding: 8px 10px; font: inherit; background: #fff; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
button { width: 100%; border: 0; border-radius: 6px; background: #2563eb; color: #fff; padding: 9px 12px; margin: 6px 0; font-weight: 600; cursor: pointer; }
button.secondary { background: #52606d; }
button.danger { background: #b42318; }
.current-user { border: 1px solid #d9e2ec; background: #f8fafc; border-radius: 6px; padding: 10px; margin-bottom: 14px; }
.current-user strong, .current-user span { display: block; font-size: 13px; }
.current-user span { color: #52606d; margin-top: 3px; }
.current-user button { margin-bottom: 0; }
.user-list { display: grid; gap: 8px; margin-top: 10px; }
.user-row { border: 1px solid #e4e7eb; border-radius: 6px; padding: 9px; background: #fbfdff; font-size: 12px; }
.user-row strong { display: block; font-size: 13px; }
.hidden { display: none !important; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0 12px; }
.segmented button { margin: 0; padding: 8px 4px; border: 1px solid #d9e2ec; background: #f8fafc; color: #334e68; font-size: 12px; }
.segmented button.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.merchant-cards { display: grid; gap: 8px; }
.merchant-card { text-align: left; margin: 0; background: #f8fafc; color: #1f2933; border: 1px solid #d9e2ec; padding: 10px; }
.merchant-card.active { border-color: #2563eb; background: #eff6ff; }
.merchant-card strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merchant-card span { display: block; margin-top: 4px; color: #52606d; font-size: 12px; }
main { min-width: 0; }
header { height: 58px; border-bottom: 1px solid #d9e2ec; background: #fff; display: flex; justify-content: space-between; align-items: center; padding: 0 18px; }
#status { font-size: 13px; color: #52606d; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: flex; align-items: center; gap: 18px; }
.stats div { display: flex; align-items: baseline; gap: 5px; }
.stats strong { font-size: 20px; color: #102a43; }
.stats span { color: #52606d; font-size: 12px; }
.layout { display: grid; grid-template-columns: 420px 1fr; height: calc(100vh - 58px); }
.list { overflow: auto; border-right: 1px solid #d9e2ec; background: #f8fafc; }
.item { padding: 14px 16px; border-bottom: 1px solid #d9e2ec; cursor: pointer; background: #fff; }
.item:hover { background: #eff6ff; }
.item.active { border-left: 4px solid #2563eb; padding-left: 12px; }
.item-title { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item-id { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.badge { border-radius: 999px; padding: 3px 7px; font-size: 12px; background: #e0e8f9; color: #1d4ed8; white-space: nowrap; }
.badge.warn { background: #fff4d6; color: #9a6700; }
.badge.done { background: #d1fadf; color: #067647; }
.flags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.flags span { display: inline-flex; border-radius: 4px; padding: 2px 6px; background: #fee4e2; color: #b42318; font-size: 12px; font-weight: 600; }
.meta { margin-top: 8px; color: #52606d; font-size: 12px; line-height: 1.5; }
.detail { padding: 18px; overflow: auto; }
.panel { background: #fff; border: 1px solid #d9e2ec; border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 14px; }
.kv div:nth-child(odd) { color: #52606d; }
.subcard { border: 1px solid #e4e7eb; border-radius: 6px; padding: 12px; margin: 10px 0; background: #fbfdff; }
.subcard strong { display: block; margin-bottom: 8px; font-size: 13px; }
.media-link { display: block; margin: 6px 0; color: #1d4ed8; overflow-wrap: anywhere; font-size: 13px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.media-preview { min-width: 0; }
.media-frame { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; border: 1px solid #d9e2ec; border-radius: 6px; background: #f8fafc; overflow: hidden; color: #829ab1; font-size: 13px; }
.media-frame img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.json-raw, .json-mini { margin: 10px 0 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: #0f172a; color: #dbeafe; border-radius: 6px; padding: 12px; font-size: 12px; line-height: 1.5; }
.json-mini { background: #f1f5f9; color: #334155; }
.empty { color: #829ab1; padding: 32px; text-align: center; }
.history { border-top: 1px solid #e4e7eb; padding: 10px 0; }
.history:first-child { border-top: 0; }
.history strong { font-size: 13px; }
.history p { margin: 6px 0 0; color: #334e68; white-space: pre-wrap; }
.actions textarea { min-height: 96px; }
@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  aside { height: auto; border-right: 0; border-bottom: 1px solid #d9e2ec; }
  header { height: auto; min-height: 58px; align-items: flex-start; gap: 10px; padding: 12px; flex-direction: column; }
  #status { max-width: 100%; }
  .stats { flex-wrap: wrap; gap: 10px; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .list { max-height: 420px; border-right: 0; }
}
