/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark is the hardcoded fallback (also what body.dark re-asserts explicitly) */
  --bg:        #111111;
  --surface:   #1a1a1a;
  --border:    #222222;
  --border-hi: #333333;
  --text:      #f0f0f0;
  --text-mid:  #888888;
  --text-dim:  #555555;
  --red:       #ff5555;
  --green:     #4ade80;
  --radius:    12px;
  --ask-h:     48px;
  --bar-h:     52px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

/* Follow the device's system theme by default — only when the user hasn't
   manually overridden it with the in-app toggle (body.light / body.dark). */
@media (prefers-color-scheme: light) {
  body:not(.dark) {
    --bg:        #ffffff;
    --surface:   #f5f5f5;
    --border:    #eeeeee;
    --border-hi: #dddddd;
    --text:      #111111;
    --text-mid:  #555555;
    --text-dim:  #aaaaaa;
  }
}

/* Manual override via the theme-toggle button — wins over system preference */
body.light {
  --bg:        #ffffff;
  --surface:   #f5f5f5;
  --border:    #eeeeee;
  --border-hi: #dddddd;
  --text:      #111111;
  --text-mid:  #555555;
  --text-dim:  #aaaaaa;
}
body.dark {
  --bg:        #111111;
  --surface:   #1a1a1a;
  --border:    #222222;
  --border-hi: #333333;
  --text:      #f0f0f0;
  --text-mid:  #888888;
  --text-dim:  #555555;
}

html, body, #layout, #app { height: 100%; }
body {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }

/* ── Screen shell ───────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
  background: var(--bg);
}

.screen.has-ask-box .scroll-area {
  padding-bottom: calc(var(--ask-h) + 64px + var(--safe-b));
}

/* ── Top bar ────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--bar-h);
  padding: 0 20px;
  background: var(--bg);
  color: var(--text);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
  margin-right: 8px;
  filter: invert(1);
  display: block;
}
body.light .nav-logo { filter: none; }
.app-name { font-weight: 700; font-size: 17px; flex: 1; letter-spacing: -0.4px; }
.top-title { font-weight: 600; font-size: 15px; flex: 1; }
.top-user      { font-size: 13px; color: var(--text-dim); }
.top-link      { font-size: 14px; color: var(--text-mid); white-space: nowrap; padding: 6px 0 6px 10px; }
.top-back      { font-size: 14px; color: var(--text-mid); padding: 6px 10px 6px 0; flex: 1; }
.sign-out-link { font-size: 16px; color: var(--text-dim); padding: 4px 0 4px 6px; opacity: .6; }
.sign-out-link:hover { opacity: 1; }
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  color: var(--text-dim);
  flex-shrink: 0;
  line-height: 1;
}

/* ── Scroll area ────────────────────────────────────────────── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Login ──────────────────────────────────────────────────── */
.login-screen {
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  background: var(--bg);
  min-height: 100dvh;
}
.login-card {
  width: 100%;
  max-width: 360px;
}
.login-logo {
  width: 44px; height: 44px;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: -1px;
  margin-bottom: 20px;
}
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; }
.login-sub     { font-size: 14px; color: var(--text-dim); margin: 5px 0 28px; }

/* Microsoft sign-in button */
.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  background: #0078d4;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.ms-btn:hover  { background: #006bb8; color: #ffffff; }
.ms-btn:active { opacity: .85; }
.ms-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Error banner for OAuth failures */
.ms-error {
  background: rgba(255, 85, 85, 0.08);
  border: 1px solid rgba(255, 85, 85, 0.3);
  color: var(--red);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* "or" divider between Microsoft button and manual login */
.login-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 18px;
  color: var(--text-dim);
  font-size: 12px;
}
.login-or::before,
.login-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-hi);
}

/* Manual login — de-emphasised fallback section */
.manual-section { opacity: 0.6; transition: opacity .2s; }
.manual-section:focus-within,
.manual-section:hover { opacity: 1; }
.manual-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.field           { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label     { font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-mid); text-transform: uppercase; }
.field select,
.field input     {
  padding: 12px 14px;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  transition: border-color .15s;
}
.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--text);
}
.field select option { background: var(--surface); }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ── Buttons ────────────────────────────────────────────────── */
.primary-btn {
  display: block; width: 100%;
  padding: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px; font-weight: 600;
  font-family: inherit;
  border: none; border-radius: 10px;
  cursor: pointer; margin-top: 8px;
  transition: opacity .15s;
  letter-spacing: -0.1px;
}
.primary-btn:disabled { opacity: .35; cursor: default; }
.primary-btn:active   { opacity: .8; }

/* ── Capture ────────────────────────────────────────────────── */
.capture-screen { background: var(--bg); }
.capture-body   { padding: 20px; }

.capture-textarea {
  display: block;
  width: 100%;
  height: 200px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.6;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  resize: vertical;
  background: var(--surface);
}
.capture-textarea:focus { outline: none; border-color: var(--text); }
.capture-textarea::placeholder { color: var(--text-dim); }

.save-status       { min-height: 20px; margin-top: 12px; font-size: 14px; text-align: center; }
.save-status.saved { color: var(--green); }
.save-status.error { color: var(--red); }

/* ── Filter bar (dashboard) ─────────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--bar-h);
  z-index: 10;
  flex-shrink: 0;
}
.filter-bar select,
.filter-bar input {
  flex: 1;
  padding: 9px 12px;
  font-size: 14px; font-family: inherit;
  border: 1px solid var(--border-hi); border-radius: 8px;
  background: var(--surface); color: var(--text);
  appearance: none; -webkit-appearance: none;
}
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--text); }
.filter-bar select option { background: var(--surface); }
.filter-bar input::placeholder { color: var(--text-dim); }

/* ── Customer list (dashboard) ──────────────────────────────── */
.cust-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg);
  transition: background .1s;
}
.cust-row:active { background: var(--surface); }
.cust-name       { font-size: 16px; font-weight: 500; color: var(--text); }
.cust-country    { font-size: 13px; color: var(--text-dim); }

.unsorted-row .cust-name { color: var(--text-mid); }

.badge {
  background: var(--red); color: #fff;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; min-width: 22px; text-align: center;
}

.loading-msg { padding: 28px 20px; color: var(--text-dim); font-size: 15px; }
.empty-msg   { padding: 48px 20px; color: var(--text-dim); font-size: 15px; text-align: center; }

/* ── Customer detail ────────────────────────────────────────── */
.cust-header {
  padding: 24px 20px 8px;
  border-bottom: 1px solid var(--border);
}
.cust-header h2 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.5px;
  display: flex; align-items: baseline; gap: 10px;
}
.cust-country-tag {
  display: inline-block; font-size: 13px;
  color: var(--text-dim); margin-top: 4px;
}

.cust-assigned-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
}
.cust-assigned-label {
  font-size: 12px; color: var(--text-dim);
}
.cust-assigned-label strong { color: var(--text-mid); font-weight: 600; }

.cust-stage-actions { display: flex; gap: 6px; margin-left: auto; }
.dead-request-btn:hover { color: var(--red); border-color: var(--red); }
.dead-request-status {
  font-size: 12px; color: var(--text-dim);
  margin-top: -4px; padding-bottom: 20px; min-height: 0;
}
.dead-request-status.dead-request-pending { color: var(--green); }

.cust-section      { padding: 20px 20px 0; }
.section-label     {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim); margin-bottom: 12px;
}
.summary-status {
  font-size: 10px; font-weight: 500; text-transform: none;
  letter-spacing: 0; color: var(--text-dim);
}
.summary-status-warn { color: var(--red); }

.section-edit-btn {
  font-size: 11px; font-weight: 500; text-transform: none;
  letter-spacing: 0; font-family: inherit;
  color: var(--text-mid);
  background: none; border: 1px solid var(--border-hi); border-radius: 4px;
  padding: 2px 8px; cursor: pointer;
  margin-left: auto;
}
.section-edit-btn:hover { color: var(--text); border-color: var(--text-mid); }

.summary-text { padding-bottom: 24px; }
.dim          { color: var(--text-dim); font-size: 14px; }

/* ── Summary table (two-column compact layout) ──────────────── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.summary-table tr {
  border-top: 1px solid var(--border);
}
.summary-table tr:first-child {
  border-top: none;
}
.summary-cat {
  width: 110px;
  padding: 10px 14px 10px 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  vertical-align: top;
  word-break: break-word;
}
.summary-val {
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  vertical-align: top;
}
.summary-plain {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { padding-bottom: 12px; }

.tp-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.tp-row:last-child { border-bottom: none; }
.tp-icon  { font-size: 14px; line-height: 1; }
.tp-gist  { font-size: 14px; line-height: 1.45; color: var(--text); }
.tp-when  { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.tp-del   {
  font-size: 11px; color: var(--text-dim); background: none; border: none;
  cursor: pointer; padding: 0 0 0 6px; line-height: 1; opacity: .4;
}
.tp-del:hover { color: var(--red); opacity: 1; }

/* Admin-only delete customer button */
.delete-cust-btn {
  font-size: 12px; color: var(--text-dim); background: none; border: none;
  cursor: pointer; padding: 0; opacity: .4; font-family: inherit;
}
.delete-cust-btn:hover { color: var(--red); opacity: 1; }

/* ── Ask box ─────────────────────────────────────────────────── */
.ask-box {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-b));
  z-index: 30;
}
.ask-row {
  display: flex; gap: 8px; align-items: center;
}
#ask-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 15px; font-family: inherit;
  border: 1px solid var(--border-hi); border-radius: 9px;
  background: var(--surface); color: var(--text);
  min-height: var(--ask-h);
}
#ask-input:focus { outline: none; border-color: var(--text); }
#ask-input::placeholder { color: var(--text-dim); }

.ask-submit {
  padding: 10px 18px; height: var(--ask-h);
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: none; border-radius: 9px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: opacity .15s;
}
.ask-submit:disabled { opacity: .35; }
.ask-submit:active   { opacity: .8; }

.ask-answer {
  font-size: 14px; line-height: 1.6; color: var(--text);
  max-height: 180px; overflow-y: auto;
  padding-bottom: 10px;
}
.ask-answer:empty { display: none; }
.ask-thinking { color: var(--text-dim); }
.ask-error    { color: var(--red); }

/* ── Unsorted ────────────────────────────────────────────────── */
.unsorted-entry {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: opacity .25s;
}
.unsorted-entry.assigned { opacity: 0; }
.raw-preview {
  font-size: 13px; color: var(--text-dim);
  margin: 5px 0 12px; line-height: 1.45;
}
.assign-row   { display: flex; gap: 8px; align-items: center; }
.assign-sel {
  flex: 1; padding: 9px 12px;
  font-size: 14px; font-family: inherit;
  border: 1px solid var(--border-hi); border-radius: 8px;
  background: var(--surface); color: var(--text);
  appearance: none; -webkit-appearance: none;
}
.assign-sel:focus { outline: none; border-color: var(--text); }
.assign-sel option { background: var(--surface); }
.assign-btn {
  padding: 9px 16px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: none; border-radius: 8px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: opacity .15s;
}
.assign-btn:disabled { opacity: .35; }
.assign-btn:active   { opacity: .8; }

/* ── Add-customer row (dashboard) ───────────────────────────── */
.add-cust-row {
  display: flex; align-items: center;
  width: 100%; padding: 16px 20px;
  border: none; border-bottom: 1px solid var(--border);
  background: var(--bg); cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.add-cust-row:active { background: var(--surface); }
.add-cust-label {
  font-size: 15px; font-weight: 500; font-family: inherit;
  color: var(--text-mid);
}

/* ── Dead page button, mobile (fixed/docked, not a floating FAB) ─────── */
.dead-page-btn {
  position: fixed;
  left: 0;
  bottom: calc(var(--ask-h) + 64px + var(--safe-b));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px 9px 12px;
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border-hi);
  border-left: none;
  border-radius: 0 8px 8px 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.dead-page-btn:hover { color: var(--text); border-color: var(--text-mid); }
.dead-page-btn .badge { font-size: 11px; padding: 1px 6px; }

/* ── Dead button, desktop sidebar (fixed footer of the left panel) ───── */
.dead-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: fixed;
  left: 0;
  bottom: 0;
  width: 380px;
  padding: 14px;
  background: var(--surface);
  color: var(--text-mid);
  border: none;
  border-top: 1px solid var(--border);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 25;
}
.dead-sidebar-btn:hover { color: var(--text); }
.dead-sidebar-btn .badge { font-size: 11px; padding: 1px 6px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.75);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 500px) {
  .modal-overlay { align-items: center; }
}
.modal-card {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 28px 24px calc(28px + var(--safe-b));
}
@media (min-width: 500px) {
  .modal-card { border-radius: var(--radius); padding: 28px 24px; }
}
.modal-title   { font-size: 18px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.3px; }
.modal-message {
  font-size: 14px; line-height: 1.6; color: var(--text-mid);
  white-space: pre-wrap; margin-bottom: 4px;
}
.modal-error   { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .ghost-btn {
  flex: 1; padding: 13px;
  border: 1px solid var(--border-hi); border-radius: 10px;
  font-size: 15px; font-family: inherit;
  background: transparent; color: var(--text);
  cursor: pointer;
}
.modal-save { flex: 2; margin-top: 0; }

/* ── Save row (attach + save button) ───────────────────────── */
.save-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}
.attach-btn {
  flex-shrink: 0;
  width: 46px;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-mid);
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
  padding: 0;
}
.attach-btn:hover { border-color: var(--text-mid); color: var(--text); }
.attach-btn.has-file { border-color: var(--text-mid); color: var(--text); }
.save-row .primary-btn {
  flex: 1;
  width: auto;
  margin-top: 0;
}
.attach-preview {
  font-size: 12px; color: var(--text-mid);
  margin-top: 8px; margin-bottom: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-height: 18px;
}

/* ── Contacts section (customer detail) ─────────────────────── */
.contact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 6px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.contact-row:last-child { border-bottom: none; }
.contact-name { font-size: 14px; font-weight: 500; color: var(--text); }
.contact-role { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.contact-detail {
  font-size: 12px; color: var(--text-mid);
  text-align: right; line-height: 1.6;
}
.contact-detail a { color: var(--text-mid); text-decoration: underline; text-underline-offset: 2px; }

/* ── Inline log bar (customer detail) ───────────────────────── */
.log-bar-wrap {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.log-bar-default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.log-note-trigger {
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-mid);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.log-note-trigger:hover { color: var(--text); }

.log-attach-trigger {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px;
  line-height: 1;
  transition: color .15s;
}
.log-attach-trigger:hover { color: var(--text-mid); }

.log-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  margin-bottom: 10px;
}

.log-bar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.log-cancel-btn {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0 0 0 10px;
  line-height: 1;
  transition: color .15s;
}
.log-cancel-btn:hover { color: var(--text); }

.log-textarea { height: 100px; }

/* ── Dashboard view toggle ───────────────────────────────────── */
.view-toggle-btn {
  flex-shrink: 0;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-mid);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition: color .15s, border-color .15s;
}
.view-toggle-btn:hover  { color: var(--text); border-color: var(--text-mid); }
.view-toggle-btn.active { color: var(--text); border-color: var(--text); }

/* ── Country-grouped view ────────────────────────────────────── */
.country-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.country-group-name {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
}
.country-group-arrow {
  font-size: 11px;
  color: var(--text-dim);
}
.country-group-row { padding-left: 32px; }

/* ── Desktop left panel ─────────────────────────────────────── */
#left-panel { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Responsive: wider screens ───────────────────────────────── */
@media (min-width: 600px) {
  .login-card, .capture-body, .cust-header, .cust-section,
  .filter-bar, .cust-row, .unsorted-entry, .add-cust-row,
  .log-bar-wrap, .country-group-header {
    max-width: 560px; margin-left: auto; margin-right: auto;
  }
  .ask-box {
    max-width: 560px; left: 50%; right: auto;
    transform: translateX(-50%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ── Desktop two-column layout (768px+) ─────────────────────── */
@media (min-width: 768px) {
  #layout { display: flex; flex-direction: row; }

  #left-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    height: 100dvh;
    overflow-y: auto;
    position: sticky;
    top: 0;
  }
  #app {
    flex: 1;
    height: 100dvh;
    overflow: hidden;
  }

  /* Remove the 560px centering within the right column */
  .capture-body, .cust-header, .cust-section,
  .filter-bar, .cust-row, .unsorted-entry, .add-cust-row,
  .log-bar-wrap, .country-group-header {
    max-width: none; margin-left: 0; margin-right: 0;
  }

  /* Room for the fixed .dead-sidebar-btn footer so it never covers the
     capture form's save button */
  #panel-inner { padding-bottom: 56px; }

  /* Ask-box anchored to right column */
  .ask-box {
    left: 380px;
    right: 0;
    max-width: none;
    transform: none;
    border-left: none;
    border-right: none;
  }

  /* Hide elements that duplicate left panel content */
  .mobile-only { display: none !important; }
}

/* desktop-only: hidden on mobile, shown on desktop */
.desktop-only { display: none; }
@media (min-width: 768px) {
  .desktop-only { display: inline !important; }
}

/* ── Shared card styles (used by the Dead page's pending-approval list) ── */
.mr-card {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 10px;
}

.mr-card-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.mr-date { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

.mr-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-mid);
}

.mr-cust-name { font-size: 13px; color: var(--text); font-weight: 500; }

.mr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.btn-approve {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
}
.btn-approve:disabled { opacity: .5; cursor: default; }

.btn-reject {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
}
.btn-reject:disabled { opacity: .5; cursor: default; }

/* Customer group headers */
.mr-group-header {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
}
.mr-group-count {
  background: var(--border-hi);
  border-radius: 99px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
}

/* Mailbox label in card header */
.mr-mailbox {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface);
  border-radius: 3px;
  padding: 0 4px;
}

/* Blocked notice */
.mr-blocked-notice {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border-left: 2px solid var(--border-hi);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

/* Preview lines */
.mr-new    { color: var(--green); }
.mr-resolve { color: var(--text-mid); }
.mr-dossier { color: var(--text-dim); }
.mr-dup-note { font-size: 11px; color: var(--red); }
.mr-preview-line { font-size: 12px; padding: 1px 0; }

/* Reviewer info on Reviewed tab */
.mr-reviewer {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.mr-review-notes {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
  margin-bottom: 4px;
}

/* Correction form enhancements */
.mr-cf-section {
  margin-bottom: 10px;
}
.mr-cf-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 600;
}
.mr-cf-check {
  display: block;
  font-size: 13px;
  color: var(--text-mid);
  padding: 2px 0;
  cursor: pointer;
}
.mr-cf-check input { margin-right: 6px; }
.mr-cf-cust-list {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  padding: 4px;
}
.mr-cf-cust-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  margin-bottom: 4px;
  box-sizing: border-box;
}
.mr-cf-new-cust-btn { margin-top: 4px; }
.mr-cf-notes {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  box-sizing: border-box;
  resize: vertical;
}
.mr-required { color: var(--red); }
.mr-cf-change-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.mr-cf-change-label {
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  padding-top: 2px;
  color: var(--text-dim);
}
.mr-cf-change-desc {
  flex: 1;
  font-size: 12px;
  color: var(--text-mid);
  min-width: 0;
}
.mr-cf-desc-edit {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  min-width: 0;
}
.mr-cf-change-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.mr-cf-keep-btn,
.mr-cf-edit-btn,
.mr-cf-remove-btn {
  background: none;
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
}
.mr-cf-keep-btn.active   { background: var(--green); border-color: var(--green); color: #fff; }
.mr-cf-edit-btn.active   { background: var(--text-mid); border-color: var(--text-mid); color: var(--bg); }
.mr-cf-remove-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.mr-cf-nochanges { font-size: 12px; color: var(--text-dim); font-style: italic; }
.mr-cf-extra-item {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.mr-cf-extra-desc {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
  min-width: 120px;
}
.mr-cf-extra-type {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  padding: 4px;
}
.mr-cf-remove-extra {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

/* Modal */
.mr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.mr-modal {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80dvh;
  overflow-y: auto;
}
.mr-modal h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}
.mr-modal-sub {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 10px;
}
.mr-modal-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.mr-lo-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
}
.mr-lo-row input { margin-top: 2px; flex-shrink: 0; }

/* Person name on manual touchpoint */
.tp-user { font-size: 11px; color: var(--text-dim); margin-left: 4px; }

/* ── Customer detail tabs ────────────────────────────────────── */
.cust-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  margin: 4px 0 0;
}
.cust-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  padding: 12px 8px;
  cursor: pointer;
  transition: color .15s;
}
.cust-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}
