@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #ece9e3;
    --surface: #f7f5f1;
    --surface-well: #fbfaf7;
    --screen: #221f1a;
    --text: #26231d;
    --text-muted: #837a6c;
    --border: #d9d2c3;
    --accent: #b8791d;
    --accent-strong: #965f13;
    --accent-tint: #f2ddb4;
    --accent-glow: rgba(184, 121, 29, 0.55);
    --led: #5c8a5c;
    --warn: #a8503a;
    --warn-soft: #f3ded8;
    --radius: 5px;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 6px 18px -10px rgba(38, 35, 29, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    margin: 0;
    padding: 32px clamp(20px, 5vw, 56px) 64px;
    line-height: 1.45;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

.num {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
}

h1 {
    font-family: "Big Shoulders Display", sans-serif;
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    margin: 0 0 16px;
    color: var(--text);
}

h1 span {
    color: var(--accent-strong);
}

/* ---------- Masthead / tabs ---------- */

.masthead {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 26px;
}

.masthead h1 {
    margin: 0;
}

.subtitle {
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-well);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow);
}

.tab-btn {
    background: none;
    border: none;
    font-family: inherit;
    padding: 7px 14px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 3px;
}

.tab-btn.active {
    color: #fff;
    background: var(--accent);
    font-weight: 600;
}

.tab-btn:hover:not(.active) {
    background: none;
    color: var(--text);
}

/* ---------- Cards / buttons ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: var(--accent-strong);
}

button.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 500;
}

button.secondary:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent-strong);
}

button.back-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}

button.back-link:hover {
    background: none;
    color: var(--accent-strong);
}

input, select {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 7px 8px;
    background: var(--surface-well);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(38, 35, 29, 0.05) inset;
}

input::placeholder {
    color: #b3aa9b;
}

input:focus, select:focus, button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Segment templates (chips) ---------- */

.templates-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.templates-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-right: 2px;
}

.chip-group {
    display: inline-flex;
    align-items: stretch;
}

.chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px 0 0 999px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.chip-group .chip {
    border-radius: 999px 0 0 999px;
    border-right: none;
}

.chip-delete {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 999px 999px 0;
    color: var(--text-muted);
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1;
    font-weight: 400;
}

.chip:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent-strong);
}

.chip-delete:hover {
    color: var(--warn);
    border-color: var(--warn);
    background: var(--warn-soft);
}

.template-save {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 4px;
}

.template-save input {
    font-size: 12.5px;
    padding: 6px 10px;
    width: 160px;
}

.template-save button {
    padding: 7px 12px;
    font-size: 12.5px;
}

/* ---------- Channel rack ---------- */

.rack {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 8px;
}

.channel {
    padding: 14px 16px 18px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.channel:first-child {
    border-left: none;
}

.channel-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.2s, box-shadow 0.2s;
}

.channel.engaged .led {
    background: var(--led);
    box-shadow: 0 0 6px var(--led);
}

.channel-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    font-weight: 600;
}

.channel.engaged .channel-label {
    color: var(--text);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label {
    font-size: 11px;
    color: var(--text-muted);
}

.field input, .field select {
    width: 100%;
}

.field-pair {
    display: flex;
    gap: 8px;
}

.field-pair .field {
    flex: 1;
    min-width: 0;
}

.field select[multiple] {
    min-height: 76px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .rack { grid-template-columns: repeat(2, 1fr); }
    .channel:nth-child(3) { border-left: none; }
}
@media (max-width: 560px) {
    .rack { grid-template-columns: 1fr; }
    .channel { border-left: none; border-top: 1px solid var(--border); }
    .channel:first-child { border-top: none; }
}

/* ---------- Readout dock ---------- */

.dock {
    margin-top: 16px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.readout {
    display: flex;
    align-items: center;
    gap: 14px;
}

.readout-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--led);
    box-shadow: 0 0 8px var(--led);
    animation: pulse 2.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .readout-led { animation: none; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.readout-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
}

.readout-screen {
    background: var(--screen);
    border-radius: 4px;
    padding: 6px 14px;
    display: inline-block;
}

.readout-count {
    font-size: 24px;
    font-weight: 600;
    color: #e5a94a;
    text-shadow: 0 0 12px rgba(229, 169, 74, 0.5);
}

/* ---------- Step 2: summary + send ---------- */

.summary-card {
    margin-bottom: 16px;
}

.summary-line {
    font-size: 14px;
    margin: 0 0 16px;
    color: var(--text-muted);
}

.summary-line b {
    color: var(--accent-strong);
    font-weight: 600;
}

.send-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.send-row input {
    flex: 1;
    min-width: 200px;
}

.usage-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: 10px 0 0;
}

#result {
    margin-bottom: 12px;
    font-weight: 600;
}

/* ---------- Customer table ---------- */

.customer-table {
    width: 100%;
    margin-top: 0;
    border-collapse: collapse;
    font-size: 13px;
    padding: 0;
}

.customer-table th,
.customer-table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}

.customer-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: var(--surface-well);
}

.customer-table th.sortable-th {
    cursor: pointer;
    user-select: none;
}

.customer-table th.sortable-th:hover {
    color: var(--accent-strong);
}

.sort-indicator {
    font-size: 9px;
}

.customer-table td.money,
.customer-table th.money {
    text-align: right;
}

.customer-table tbody tr:last-child td {
    border-bottom: none;
}

.customer-table tbody tr:nth-child(even) {
    background: rgba(38, 35, 29, 0.02);
}

.customer-table tbody tr:hover {
    background: var(--accent-tint);
}

.table-wrap {
    overflow-x: auto;
}

/* ---------- Campaign / email cards ---------- */

.name {
    font-weight: 600;
    font-size: 14px;
}

.campaign-card {
    display: block;
    margin-bottom: 12px;
}

.campaign-card .contact {
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 10px;
}

.funnel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.funnel-bar {
    height: 26px;
    background: var(--accent);
    border-radius: 4px;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
    min-width: fit-content;
}

.funnel-branch .funnel-bar {
    background: var(--warn-soft);
    color: var(--warn);
}

.funnel-unavailable {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}
