/* Brand Scanner — manager UI redesign (base 2A). Light theme is default; dark kept behind data-theme="dark". */

:root, :root[data-theme="light"] {
  --bg: #F6F3EC;
  --rail: #EDE8DB;
  --surface: #FBF9F3;
  --surface-2: #FFFFFF;
  --border: #D9D0BA;
  --border-soft: #E6DFCC;
  --text: #211C10;
  --text-2: #3A3325;
  --muted: #7A7059;
  --placeholder: #A89E85;
  --signal: #C15A0E;
  --signal-ink: #FFFFFF;
  --signal-dim: rgba(193, 90, 14, 0.12);
  --ink: #211C10;
  --ink-fg: #FBF9F3;
  --free: #227A5E;
  --free-ink: #1B6A50;
  --free-bg: rgba(34, 122, 94, 0.14);
  --taken: #B0264A;
  --taken-bg: rgba(176, 38, 74, 0.16);
  --error: #93650E;
  --error-bg: rgba(147, 101, 14, 0.12);
  --font-display: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #06090C; --rail: #0A0F14; --surface: #0D1319; --surface-2: #121A22;
  --border: #1D2830; --border-soft: #182129; --text: #E4ECF1; --text-2: #C7D3DB; --muted: #9FB0BD; --placeholder: #63788A;
  --signal: #FF8A34; --signal-ink: #1A0D02; --signal-dim: rgba(255,138,52,.14);
  --ink: #E4ECF1; --ink-fg: #06090C;
  --free: #4FD1A5; --free-ink: #4FD1A5; --free-bg: rgba(79,209,165,.14);
  --taken: #FF5470; --taken-bg: rgba(255,84,112,.16);
  --error: #E8C468; --error-bg: rgba(232,196,104,.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--signal); }
button { font-family: inherit; }
.mono { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sub { color: var(--muted); font-size: 13px; }

/* ---- Theme toggle (kept from kit) ---- */
.theme-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.theme-toggle button { width: auto; background: transparent; border: none; color: var(--muted); padding: 7px 11px; font-size: 11px; cursor: pointer; min-height: 32px; font-family: var(--font-display); }
.theme-toggle button[aria-pressed="true"] { background: var(--rail); color: var(--text); }
.theme-toggle-float { position: fixed; bottom: 14px; right: 14px; z-index: 40; }
.theme-toggle-rail { width: 100%; }
.theme-toggle-rail button { flex: 1; }

/* ---- Auth ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.login-shell { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login-shell h1 { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 0; }
.login-shell p { margin: 0; }
.field-stack { display: flex; flex-direction: column; gap: 14px; }
.login-actions { display: flex; flex-direction: column; gap: 10px; }
.auth-link { display: block; text-align: center; font-size: 13px; color: var(--text); text-decoration: underline; background: none; border: 0; width: 100%; min-height: 36px; padding: 6px; font-weight: 400; cursor: pointer; }
.auth-link:hover:not(:disabled) { background: none; color: var(--signal); }
.credit { font-size: 12.5px; color: var(--muted); text-align: center; margin: 0; }
.notice { border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.notice.is-ok { background: var(--free-bg); border: 1px solid rgba(34,122,94,.3); color: var(--free-ink); }
.notice.is-warn { background: var(--error-bg); border: 1px solid rgba(147,101,14,.3); color: #7A5208; }
.notice a { color: inherit; }
.check-badge { width: 40px; height: 40px; border-radius: 50%; background: var(--free-bg); color: var(--free-ink); display: grid; place-items: center; font-size: 18px; font-weight: 600; }
.field-error { margin-top: 6px; font-size: 12.5px; color: var(--taken); }
.field-hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
input.is-invalid { border-color: var(--taken); }
.input-row { position: relative; }
.input-row .show { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: auto; min-height: 0; padding: 0; background: none; border: 0; color: var(--muted); font-size: 12.5px; font-weight: 400; }

/* ---- Shell ---- */
.shell { min-height: 100vh; display: flex; }
.rail { width: 250px; flex-shrink: 0; background: var(--rail); border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
.rail-brand { display: flex; align-items: center; gap: 10px; }
.rail-brand h1 { font-family: var(--font-display); font-size: 14px; font-weight: 600; margin: 0; }
.rail-brand .sub { font-size: 11px; font-family: var(--font-display); margin: 0; }
.brand-logo { display: block; width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; border-radius: 8px; }
.login-wrap .brand-logo { width: 32px; height: 32px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.rail-new { background: var(--ink); color: var(--ink-fg); border-radius: 8px; min-height: 44px; font-size: 13.5px; }
.rail-mobile { display: none; }
.history-mobile { min-height: 40px; padding: 8px 12px; font-family: var(--font-display); font-size: 12px; }
.rail-new:hover:not(:disabled) { filter: brightness(1.15); }
.rail-footer { margin-top: auto; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); padding-top: 14px; }
.rail-user { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; }
.rail-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user button { width: auto; min-height: 0; background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; font-weight: 400; }
.rail-user button:hover { color: var(--text); }

/* History lives in the rail */
.history { display: flex; flex-direction: column; gap: 6px; }
.history-head { display: flex; justify-content: space-between; padding: 0 4px 4px; font-family: var(--font-display); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.history-item { display: block; text-decoration: none; color: var(--text-2); padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; }
.history-item:hover { background: var(--surface); }
.history-item[aria-current="true"] { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 2px rgba(33,28,16,.06); color: var(--text); }
.history-item .name { font-family: var(--font-display); font-size: 12.5px; }
.history-item[aria-current="true"] .name { font-weight: 600; }
.history-item .meta { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.history-empty { padding: 14px 12px; border-radius: 8px; border: 1px dashed #C9BE9F; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.t-taken { color: var(--taken); font-weight: 600; }
.t-free { color: var(--free); }
.t-error { color: var(--error); }
.t-signal { color: var(--signal); font-weight: 600; }

.main { flex: 1; min-width: 0; padding: 28px 36px 40px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs .cur { color: var(--text); }

/* ---- Panels & forms ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-family: var(--font-display); font-size: 12.5px; font-weight: 600; margin: 0; }
.panel-head .left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-body { padding: 18px 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.scan-form { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 18px; align-items: end; }
.scan-form .side { display: flex; flex-direction: column; gap: 10px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.label-row label { margin: 0; }
.validation { font-family: var(--font-display); font-size: 11.5px; color: var(--muted); }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .04em; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input[readonly] { background: var(--bg); color: var(--text-2); font-family: var(--font-display); font-size: 12.5px; }
textarea { min-height: 120px; resize: vertical; font-family: var(--font-display); font-size: 12.5px; line-height: 1.7; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
textarea.is-active { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-dim); }
.dropzone { border: 1px dashed #C9BE9F; border-radius: 8px; padding: 12px; text-align: center; color: var(--muted); font-size: 12.5px; background: var(--surface-2); cursor: pointer; }
.dropzone strong { color: var(--text); }
.file-chip { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.file-chip span { font-family: var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { width: auto; min-height: 0; padding: 0 4px; background: none; border: 0; color: var(--muted); font-weight: 400; }
.alias-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.alias-line .mono { color: var(--text); }

button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 44px; padding: 10px 20px; border-radius: 7px; border: 1px solid transparent; font-size: 13.5px; font-weight: 600; cursor: pointer; background: var(--signal); color: var(--signal-ink); transition: filter 150ms ease, transform 120ms ease; user-select: none; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
button:disabled { cursor: not-allowed; background: #E3C7B0; color: #fff; }
:root[data-theme="dark"] button:disabled { opacity: .4; background: var(--signal); }
button.secondary, a.secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--text); text-decoration: none; cursor: pointer; width: auto; }
button.secondary:hover:not(:disabled), a.secondary:hover { background: var(--rail); filter: none; }
.btn-inline { width: auto; }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* ---- Empty state ---- */
.empty { border: 1px dashed #C9BE9F; border-radius: 10px; padding: 40px 24px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty h4 { margin: 0; font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.empty p { margin: 0; max-width: 440px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

/* ---- Progress ---- */
.progress { height: 6px; border-radius: 3px; background: var(--border-soft); overflow: hidden; position: relative; }
.progress .fill { position: absolute; inset: 0; width: 58%; background: var(--signal); border-radius: 3px; }
.progress .sweep { position: absolute; top: 0; bottom: 0; width: 40%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: sweep 1.6s linear infinite; }
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .progress .sweep { display: none; } }

/* ---- Status pills. Codes stay distinct: is-taken (Matched), is-free (Clear), is-error (Error), is-unavail (Unavailable). ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 5px; font-size: 11px; font-weight: 600; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .03em; border: 1px solid var(--border); color: var(--text); background: var(--surface-2); text-decoration: none; }
.pill.is-taken, .pill.is-matched { background: var(--taken); color: #fff; border-color: transparent; }
.pill.is-free, .pill.is-clear { background: var(--free); color: #fff; border-color: transparent; }
.pill.is-error, .pill.is-unavail { background: var(--error); color: #fff; border-color: transparent; }
.pill.is-unavail { background: transparent; color: var(--error); border-color: var(--error); }
.pill.is-done { background: var(--free-bg); color: var(--free-ink); border-color: transparent; }
.pill.is-running { background: transparent; color: var(--signal); border-color: var(--border); }
.pill.is-queued { color: var(--placeholder); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
a.pill:hover { filter: brightness(1.08); }

/* ---- Summary tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.tile { padding: 12px 18px; border-right: 1px solid var(--border); }
.tile:last-child { border-right: 0; }
.tile .n { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.tile .d { font-size: 12px; color: var(--muted); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--bg); }
th { font-family: var(--font-display); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; text-align: left; padding: 9px 10px; position: sticky; top: 0; z-index: 2; background: var(--bg); }
td { padding: 11px 10px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 18px; width: 36px; }
th:last-child, td:last-child { padding-right: 18px; }
td.idx { color: var(--muted); font-family: var(--font-display); font-size: 12px; }
td.res a { font-family: var(--font-display); font-size: 12.5px; color: var(--signal); text-decoration: none; }
td.res a:hover { text-decoration: underline; }
td.plat, td.note { color: var(--muted); }
td.note.t-error { color: var(--error); }
tr.is-pending td { color: var(--placeholder); }
tr.is-pending td.res a { color: var(--placeholder); }
.table-foot { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); font-family: var(--font-display); }
.hidden-cols { display: none; } /* Check date, Brand, Period, Mode, Data source — hidden for manager, kept in markup */

/* ---- Mention details ---- */
.mentions { display: flex; flex-direction: column; gap: 10px; }
.mention-block { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.mention-block .type label { margin-bottom: 4px; }
.mention-block .type strong { font-weight: 600; }
.mention-block .quote { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.mention-block mark { background: var(--taken-bg); color: var(--text); padding: 0 3px; border-radius: 3px; }
.mention-block .where { margin-top: 8px; font-family: var(--font-display); font-size: 12px; color: var(--muted); }
.mention-block .open { font-size: 13px; white-space: nowrap; }

/* ---- Kit chrome (not product) ---- */
.kit-banner { position: sticky; top: 0; z-index: 80; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; background: #211C10; color: #FBF9F3; border-bottom: 1px solid #C15A0E; font-size: 12px; font-family: var(--font-display); }
.kit-banner strong { color: #FF8A34; font-weight: 600; }
.kit-banner nav { display: flex; flex-wrap: wrap; gap: 8px; }
.kit-banner a { color: #F3EFE6; text-decoration: none; padding: 4px 8px; border-radius: 4px; }
.kit-banner a:hover, .kit-banner a[aria-current="page"] { background: rgba(255,138,52,.25); color: #FF8A34; }
.kit-annotate { font-size: 12px; color: var(--muted); border-left: 3px solid var(--signal); padding: 8px 12px; margin: 0; background: var(--signal-dim); border-radius: 0 8px 8px 0; }
.hub { max-width: 820px; margin: 0 auto; padding: 40px 24px 80px; }
.hub h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 8px; }
.hub .lead { color: var(--muted); margin: 0 0 28px; }
.hub-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 16px; }
.hub-card h2 { font-family: var(--font-display); font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.hub-card ul, .hub-card ol { margin: 0; padding-left: 18px; }
.hub-card li { margin: 6px 0; }
.screen-grid { display: grid; gap: 8px; }
.screen-grid a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); background: var(--surface-2); }
.screen-grid a:hover { border-color: var(--signal); }
.screen-grid span { color: var(--muted); font-size: 12px; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; padding: 14px 18px; gap: 12px; }
  .rail-new { width: auto; min-height: 40px; padding: 8px 12px; font-size: 13px; }
    .history, .theme-toggle-rail { display: none; }
  .rail-footer { margin: 0; border: 0; padding: 0; flex-direction: row; align-items: center; gap: 8px; }
  .rail-user { font-size: 12px; }
  .rail-user span { display: none; }
  .rail-mobile { display: inline-flex; align-items: center; gap: 8px; }
  .main { padding: 18px; gap: 14px; }
  .scan-form { grid-template-columns: 1fr; }
  .scan-form .side { flex-direction: row; }
  .scan-form .side .dropzone { flex: 0 0 auto; padding: 0 14px; display: flex; align-items: center; }
  .scan-form .side button { flex: 1; min-height: 48px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile { padding: 10px 12px; }
  .tile .n { font-size: 18px; }
  .tile .d { font-size: 11px; }
  .table-wrap { overflow-x: visible; }
  table, thead, tbody, tr, td { display: block; }
  thead, .table-foot, td.idx, td.plat { display: none; }
  tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 12px; margin: 0 12px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
  tbody { display: block; padding-top: 12px; }
  td { padding: 0; border: 0; }
  td.res { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  td.stat { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  td.men, td.note { grid-column: 1; font-size: 12px; }
  td.men:empty { display: none; }
  .mention-block { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .mention-block .open { justify-self: end; }
  #appThemeFloat { display: inline-flex; }
}
@media (min-width: 901px) { #appThemeFloat { display: none !important; } }
