/* Review requests admin — compact light theme, system fonts. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2530;
  --muted: #677385;
  --border: #dde3ea;
  --border-strong: #c4ccd6;
  --primary: #1f5fbf;
  --primary-hover: #184d9c;
  --primary-soft: #e8f0fc;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fff6e0;
  --success: #2e7d4f;
  --success-soft: #e7f5ec;
  --star: #e5a50a;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.4; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .9rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .7rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 0 0 .5rem; font-weight: 650; }
code { font-family: var(--mono); font-size: .9em; background: #eef1f5; padding: 0 .3em; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error-text { color: var(--danger); }
.hint { color: var(--muted); font-size: .85rem; }
[hidden] { display: none !important; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 50px; display: flex; align-items: center; gap: 20px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 6px 10px; border-radius: var(--radius); color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.badge { display: inline-block; background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: 0 7px; font-size: .75rem; font-weight: 600; vertical-align: middle; }

/* Layout */
.main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.card.narrow { max-width: 680px; }
.card.narrow-wide { max-width: 860px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.row-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: #f7f9fb; text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-danger-outline { color: var(--danger); border-color: #e4b4ae; }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 9px; font-size: .85rem; }

/* Forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input:disabled, textarea:disabled, select:disabled { background: #f3f5f8; color: var(--muted); }
textarea { resize: vertical; min-height: 2.6em; }
label { display: block; font-weight: 500; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.form-error { color: var(--danger); font-size: .9rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 500; font-size: .9rem; padding: 0; margin-bottom: 4px; }
.radios { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.radios legend { width: 100%; }
.radios label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.radios.stacked label { display: flex; margin: 4px 0; }
.radios input { width: auto; margin: 0; }
.radios label.disabled { color: var(--muted); cursor: not-allowed; }
.radios label.disabled input { cursor: not-allowed; }

/* Notices */
.notice { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; background: #fafbfc; }
.notice-success { border-left-color: var(--success); background: var(--success-soft); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.notice-error { border-left-color: var(--danger); background: var(--danger-soft); }
.notice-info { border-left-color: var(--primary); background: var(--primary-soft); }
.notice p { margin: .3rem 0; }
.linkbox { margin-top: 8px; }
.linkbox-row { display: flex; gap: 6px; margin-top: 4px; }
.linkbox-row input { font-family: var(--mono); font-size: .85rem; }

/* Pills and tags */
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; line-height: 1.5; vertical-align: middle; background: #e9edf2; color: #4a5565; }
.pill-created { background: #e9edf2; color: #4a5565; }
.pill-sent { background: #e3ecfb; color: #1f4f9e; }
.pill-delivered { background: #dff3f1; color: #126e63; }
.pill-clicked { background: #e9e4fb; color: #4f3ba6; }
.pill-rated { background: #e7f5ec; color: #236d43; }
.pill-closed { background: #d4ecda; color: #17502f; }
.pill-failed { background: #fdecea; color: #a93226; }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: .74rem; font-weight: 600; background: #eef1f5; color: var(--muted); vertical-align: middle; }
.tag-feedback { background: var(--warn-soft); color: var(--warn); }
.tag-callback { background: var(--danger-soft); color: var(--danger); }
.tag-error { background: var(--danger-soft); color: var(--danger); }
.stars { color: var(--star); letter-spacing: .05em; white-space: nowrap; }
.stars.big { font-size: 1.1rem; vertical-align: middle; }
.star-glyph { color: var(--star); }
.google { font-weight: 700; }
.google.clicked { color: var(--primary); }
.google.confirmed { color: var(--success); }

/* Filters */
.filters { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.filters input[type=search] { width: 240px; }
.filters select { width: auto; }
.date-filter { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--muted); font-size: .85rem; }
.date-filter input { width: auto; margin: 0; }
.presets { display: inline-flex; gap: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table.compact th, .table.compact td { padding: 6px 8px; }
.table .num { text-align: right; }
#req-table tbody tr[data-id] { cursor: pointer; }
#req-table tbody tr[data-id]:hover { background: #f6f8fb; }
#req-table tbody tr[data-id]:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.td-name { font-weight: 500; white-space: nowrap; }
.td-contact { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.td-sent { white-space: nowrap; }
.td-google { text-align: center; }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn { visibility: hidden; }
tr:hover .td-actions .btn, tr:focus-within .td-actions .btn { visibility: visible; }
td.empty { text-align: center; padding: 30px; }
.list-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* Detail */
.crumbs { margin: 0 0 6px; font-size: .9rem; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.detail-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head .actions { margin-top: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 0; }
.field dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.field dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.feedback { background: var(--warn-soft); border-color: #f0dba3; }
.feedback blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid var(--warn); background: #fff; border-radius: 4px; white-space: pre-wrap; }
.notes { list-style: none; padding: 0; margin: 0 0 12px; }
.notes li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.notes li:last-child { border-bottom: 0; }
.note-text { white-space: pre-wrap; }
.note-form textarea { margin-bottom: 6px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #b9c2cc; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); }
.tl-sent .tl-dot, .tl-resent .tl-dot { background: var(--primary); }
.tl-clicked .tl-dot, .tl-google_clicked .tl-dot { background: #6f5bd1; }
.tl-rated .tl-dot, .tl-google_confirmed .tl-dot { background: var(--success); }
.tl-feedback .tl-dot { background: var(--warn); }
.tl-send_failed .tl-dot, .tl-purged .tl-dot { background: var(--danger); }
.tl-title { font-weight: 500; }
.tl-detail { color: var(--text); font-size: .9rem; white-space: pre-wrap; }

/* Stats */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 12px 0 18px; }
.kpi { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: #fafbfc; }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; margin: 2px 0; }
.kpi-sub { font-size: .8rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chart { width: 100%; max-width: 480px; height: auto; display: block; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-value { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart-label { font-size: 12px; fill: var(--text); font-family: var(--font); font-weight: 600; }

/* Settings */
.settings-section { border-top: 1px solid var(--border); padding: 14px 0 6px; margin-top: 6px; }
.settings-section legend { font-size: 1rem; font-weight: 650; padding: 0 0 4px; float: left; width: 100%; }
.setting { margin: 0 0 12px; clear: both; }
.setting .help { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.sms-count { font-size: .82rem; color: var(--muted); margin-top: 4px; padding: 6px 8px; background: #f7f9fb; border-radius: 4px; }
.sms-count.warn { background: var(--warn-soft); color: #7a5213; }
.sms-preview { color: var(--text); }
.form-actions.sticky { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0; border-top: 1px solid var(--border); margin-top: 10px; }

/* Modal */
.modal { border: 0; border-radius: 10px; padding: 0; max-width: 480px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(16, 24, 40, .25); color: var(--text); }
.modal::backdrop { background: rgba(16, 24, 40, .4); }
.modal-form { padding: 18px 20px; }
.modal-title { font-size: 1.1rem; margin: 0 0 10px; }
.modal-body label { margin: 8px 0; }
.modal-body p { margin: .4rem 0; }
.modal-error { color: var(--danger); margin: 8px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: #1c2530; color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; max-width: 360px; font-size: .92rem; }
.toast.show { opacity: 1; transform: none; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: #37475a; }

/* Responsive (down to tablet) */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .td-actions .btn { visibility: visible; }
}
@media (max-width: 800px) {
  .topbar-inner { height: auto; padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .user-email { display: none; }
  .main { padding: 12px; }
  .card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .filters input[type=search] { width: 100%; }
}

/* Users page */
.form-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-top: 12px; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; min-width: 160px; }
.form-row label:first-child { flex: 1 1 260px; }
.card > .help { color: var(--muted); font-size: .9rem; margin: 4px 0 8px; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
