/* POS Lead Handler admin — server-rendered UI, no framework (§7.3). */

:root {
    --ink: #1c2733;
    --muted: #6b7a8c;
    --line: #d8dfe6;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --accent: #1f6feb;
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --warn-bg: #fff4e0;
    --ok-bg: #e7f5ec;
    --err-bg: #fdecea;
    --info-bg: #e8f0fe;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}
code { background: #eef1f4; padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
h2:first-child { margin-top: 0; }

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--ink); color: #fff; padding: 0 1.25rem; min-height: 52px;
}
.topbar a { color: #d7e1ec; text-decoration: none; }
.topbar-brand a { color: #fff; font-weight: 600; }
.topbar-nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar-nav a { padding: 0.35rem 0.75rem; border-radius: 6px; }
.topbar-nav a:hover { background: rgba(255, 255, 255, 0.12); }
.topbar-nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.role-badge {
    background: rgba(255, 255, 255, 0.18); border-radius: 10px;
    padding: 1px 8px; font-size: 0.78em; margin-left: 4px;
}

.container { max-width: 1100px; margin: 1.5rem auto 3rem; padding: 0 1.25rem; }

/* Panels & layout */
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px; padding: 1.25rem; margin-bottom: 1.25rem;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card {
    display: block; background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px; padding: 1rem 1.25rem; text-decoration: none; color: inherit;
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 0.35rem; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 0.92em; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Forms */
label { display: block; font-weight: 600; margin: 0.9rem 0 0.25rem; }
label small { font-weight: 400; color: var(--muted); }
label:first-of-type { margin-top: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--line);
    border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input.readonly, input[readonly] { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
.check-label { display: flex; align-items: baseline; gap: 0.5rem; font-weight: 400; margin-top: 0.9rem; }
.form-narrow { max-width: 460px; }
.stacked-form { margin-top: 0.75rem; }
.inline-form { display: inline; }

/* Buttons */
.btn {
    display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--line);
    border-radius: 6px; background: #fff; color: var(--ink); font: inherit;
    cursor: pointer; text-decoration: none; margin-top: 0.75rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1a5fd0; color: var(--accent-ink); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-small { padding: 0.2rem 0.6rem; font-size: 0.85em; margin-top: 0; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: #d7e1ec; cursor: pointer; padding: 0; font: inherit; }
.btn-link:hover { text-decoration: underline; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--panel); }
.data-table th, .data-table td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); }
.data-table th { font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.data-table input[type="email"] { min-width: 220px; }
.detail-table th { text-align: left; padding-right: 1rem; color: var(--muted); font-weight: 600; }
.detail-table td, .detail-table th { padding-bottom: 0.4rem; vertical-align: top; }
.row-inactive td { color: var(--muted); }

/* Flash messages */
.flash { padding: 0.65rem 1rem; border-radius: 6px; margin-bottom: 0.9rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); border-color: #b3d9c0; }
.flash-error { background: var(--err-bg); border-color: #eab7b2; }
.flash-warning { background: var(--warn-bg); border-color: #eccf9c; }
.flash-info { background: var(--info-bg); border-color: #b7ccf0; }

.muted { color: var(--muted); }
.text-error { color: var(--danger); }
.lead { font-size: 1.05em; }
.cascade-note { background: var(--warn-bg); border: 1px solid #eccf9c; border-radius: 6px; padding: 0.5rem 0.75rem; }

/* Auth pages */
body.bare { display: grid; place-items: center; min-height: 100vh; }
.auth-card {
    width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line);
    border-radius: 10px; padding: 2rem;
}
.auth-brand { font-size: 1.15rem; text-align: center; margin: 0 0 1.25rem; }
.release-card { width: min(680px, 94vw); }
.auth-links { text-align: center; margin-top: 1rem; font-size: 0.92em; }

/* Validation editor workspace (§6A.4.1) */
.validation-workspace { display: flex; gap: 0.75rem; align-items: stretch; min-height: 420px; }
.vw-editor { flex: 1 1 65%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: flex; flex-direction: column; }
.vw-scaffold { padding: 0.35rem 0.75rem 0.35rem 2.6rem; font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: var(--bg); }
#cm-host { flex: 1; overflow: auto; }
#cm-host .cm-editor { height: 100%; font-size: 0.92em; }
.vw-col { flex: 0 0 17%; min-width: 140px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
.vw-col.vw-collapsed { flex: 0 0 2rem; min-width: 2rem; }
.vw-col.vw-collapsed .vw-list, .vw-col.vw-collapsed .vw-empty { display: none; }
.vw-col-head { font-size: 0.78em; letter-spacing: 0.05em; color: var(--muted); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.vw-list { list-style: none; margin: 0; padding: 0.25rem 0; overflow-y: auto; flex: 1; }
.vw-item { position: relative; padding: 0.3rem 0.75rem; cursor: pointer; font-family: ui-monospace, Consolas, monospace; font-size: 0.85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-item:hover, .vw-item:focus { background: var(--info-bg); outline: none; }
.vw-custom { font-style: italic; }
.vw-divider { border-top: 1px solid var(--line); margin: 0.25rem 0; }
.vw-tooltip { display: none; position: absolute; right: 100%; top: 0; z-index: 30; width: 260px; background: var(--ink); color: #fff; border-radius: 6px; padding: 0.6rem 0.8rem; font-family: system-ui, sans-serif; white-space: normal; }
.vw-tooltip code { background: rgba(255,255,255,0.15); color: #fff; display: block; margin-bottom: 0.3rem; }
.vw-tooltip p { margin: 0.25rem 0; font-size: 0.9em; }
.vw-item:hover .vw-tooltip { display: block; }
.vw-empty { padding: 0.5rem 0.75rem; position: relative; }
.vw-empty-label { font-style: italic; cursor: help; }
.info-i { color: var(--accent); }
.vw-popover { position: absolute; right: 0.5rem; top: 2rem; z-index: 40; width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); padding: 0.9rem 1rem; font-size: 0.9em; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 38, 0.55); display: grid; place-items: center; z-index: 100; }

/* Spam lists (§6.7) */
.override-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.override-grid label { margin-top: 0; font-weight: 400; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
    padding: 0.15rem 0.3rem 0.15rem 0.7rem; font-size: 0.88em;
}
.tag-remove {
    background: none; border: none; cursor: pointer; color: var(--muted);
    font-size: 1.1em; line-height: 1; padding: 0 0.3rem;
}
.tag-remove:hover { color: var(--danger); }

/* Submission log (§6.5.2) */
.status-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.badge {
    display: inline-block; padding: 0.25rem 0.7rem; border: 1px solid var(--line);
    border-radius: 14px; background: var(--panel); text-decoration: none;
    color: var(--ink); font-size: 0.88em;
}
.badge:hover { border-color: var(--accent); }
.badge-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge-failed { border-color: var(--danger); color: var(--danger); }
.badge-failed.badge-active { background: var(--danger); color: #fff; }
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filter-bar select, .filter-bar input { width: auto; }
.filter-bar .btn { margin-top: 0; }
.status-pill {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 0.8em; background: var(--bg); border: 1px solid var(--line);
}
.status-sent { background: var(--ok-bg); }
.status-failed { background: var(--err-bg); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.status-spam, .status-review { background: var(--warn-bg); }
.status-pending { background: var(--info-bg); }
.row-status-failed td { background: #fff7f6; }
.bulk-bar { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.bulk-bar select { width: auto; }
.bulk-bar .btn { margin-top: 0; }
.pagination { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.pagination .btn { margin-top: 0; }
pre.wrap { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 0.5rem; border-radius: 6px; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table th.group-head { text-align: center; border-bottom: none; padding-bottom: 0; }
.data-table th select { width: auto; font-weight: normal; }
.tab-nav { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; }
.tab-nav .tab-link {
    padding: 0.5rem 1rem; text-decoration: none; color: inherit;
    border: 1px solid transparent; border-bottom: none;
    border-radius: 8px 8px 0 0; margin-bottom: -2px;
}
.tab-nav .tab-link:hover { background: var(--bg); }
.tab-nav .tab-link.active {
    background: #fff; border-color: var(--line);
    border-bottom: 2px solid #fff; font-weight: 600;
}
.copy-row { display: flex; gap: 0.5rem; align-items: center; }
.copy-row input[readonly] { flex: 1; background: var(--bg); font-family: ui-monospace, monospace; font-size: 0.9em; }
.copy-row .btn { margin-top: 0; white-space: nowrap; }
.btn-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.status-test { background: var(--info-bg); }

/* Profile action boxes (§4.2) */
.action-box {
    border: 1px solid var(--line); border-radius: 8px;
    padding: 0.75rem 1rem 1rem; margin: 1rem 0 0;
}
.action-toggle { margin-top: 0; }
.action-toggle small { display: block; }
.action-body { margin-left: 1.6rem; }
.label-line { display: block; font-weight: 600; margin: 0.9rem 0 0.25rem; }
.label-line small { font-weight: 400; color: var(--muted); }

/* Password show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 2.4rem; }
.pw-toggle {
    position: absolute; top: 50%; right: 0.35rem; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.8rem; height: 1.8rem; padding: 0;
    background: none; border: none; border-radius: 4px;
    color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); }

/* Session expiry warning (§7.2.2) */
.session-warning {
    position: fixed; bottom: 1rem; right: 1rem; max-width: 320px;
    background: var(--warn-bg); border: 1px solid #eccf9c; border-radius: 8px;
    padding: 0.8rem 1rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
