* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #0e1117;
    color: #e6edf3;
    font-size: 13px;
}

/* ─────────────── header ─────────────── */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 22px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}
header h1 { margin: 0; font-size: 17px; font-weight: 600; }
.status { font-size: 11px; color: #8b949e; font-family: ui-monospace, monospace; }
.status.ok { color: #3fb950; }
.status.err { color: #f85149; }

/* ─────────────── tabs ─────────────── */
.tabs {
    display: flex;
    background: #0d1117;
    border-bottom: 1px solid #30363d;
    padding: 0 22px;
}
.tab {
    background: transparent;
    border: 0;
    color: #8b949e;
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-right: 4px;
}
.tab:hover { color: #e6edf3; }
.tab.active { color: #58a6ff; border-bottom-color: #58a6ff; }

/* ─────────────── panels ─────────────── */
.panel { display: none; padding: 16px 22px 40px; }
.panel.active { display: block; }

/* ─────────────── toolbar ─────────────── */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar label {
    display: flex; flex-direction: column;
    font-size: 11px; color: #8b949e; gap: 4px;
}
.toolbar input, .toolbar select,
.modal-body input, .modal-body select, .modal-body textarea {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    min-width: 180px;
    font-family: inherit;
}
.modal-body textarea { font-family: ui-monospace, monospace; min-width: 100%; min-height: 140px; }

/* ─────────────── buttons ─────────────── */
.btn {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: #30363d; border-color: #58a6ff; }
.btn.primary { background: #238636; border-color: #2ea043; color: #fff; }
.btn.primary:hover { background: #2ea043; }
.btn.danger { background: #21262d; color: #f85149; }
.btn.danger:hover { background: #3a1d1d; border-color: #f85149; }
.btn.small { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.busy {
    opacity: 0.75;
    cursor: progress;
    animation: busy-pulse 1.2s ease-in-out infinite;
}
@keyframes busy-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.5); }
    50%  { box-shadow: 0 0 0 4px rgba(88, 166, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); }
}

/* ─────────────── tables ─────────────── */
.counter, .bulk-counter { font-size: 11px; color: #8b949e; margin-left: auto; align-self: center; }
.table-wrap {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.data-table th, .data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #21262d;
    vertical-align: middle;
}
.data-table th {
    background: #161b22;
    color: #8b949e;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}
.data-table tbody tr:hover { background: #161b22; }
.data-table tbody tr.selected { background: #1a2030; }

/* Token-keeper pause_reason='checkpoint': Meta requires manual selfie/web
   verify on this account. Highlight in red so the operator can spot
   accounts that won't recover via cron retry. Stripe on the left is
   subtler than a full-row tint and survives the .selected/.hover
   states without fighting them. */
.data-table tbody tr.row-checkpoint {
    background: rgba(248, 81, 73, 0.08);
    box-shadow: inset 3px 0 0 #f85149;
}
.data-table tbody tr.row-checkpoint:hover { background: rgba(248, 81, 73, 0.14); }
.data-table tbody tr.row-checkpoint.selected { background: rgba(248, 81, 73, 0.18); }
.data-table tbody tr.flash {
    animation: row-flash 1.2s ease-out;
}
@keyframes row-flash {
    0%   { background: rgba(63, 185, 80, 0.40); }
    40%  { background: rgba(63, 185, 80, 0.20); }
    100% { background: transparent; }
}
.data-table .col-check { width: 32px; }
.data-table .empty {
    text-align: center;
    color: #6e7681;
    padding: 30px;
}
.data-table .actions-cell {
    display: flex; gap: 4px; flex-wrap: wrap;
}
.mono { font-family: ui-monospace, monospace; font-size: 11px; }
.dim { color: #6e7681; }

/* pills / badges */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #21262d;
    color: #8b949e;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pill.ok      { background: #1a3a1a; color: #3fb950; }
.pill.danger  { background: #3a1a1a; color: #f85149; }

/* Compact GPM-status dot, sits inline with the email. Color = state,
   tooltip carries the human label. Open = green pulse so an active
   profile pops out when scrolling 100+ rows. */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: help;
}
.status-dot.status-open    { background: #3fb950; animation: status-pulse 1.6s ease-in-out infinite; }
.status-dot.status-closed  { background: #4d5560; }
.status-dot.status-unknown { background: #d29922; }

@keyframes status-pulse {
    0%, 100% { opacity: 1;    transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.85); }
}
.pill.warn    { background: #3a2a1a; color: #d29922; }
.pill.err     { background: #3a1d1d; color: #f85149; }
.pill.info    { background: #1d2d3a; color: #58a6ff; }
.pill.muted   { background: #21262d; color: #8b949e; }

/* ─────────────── bulk action bar ─────────────── */
.bulk-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    flex-wrap: wrap;
}
.bulk-bar .select-all {
    display: flex; align-items: center; gap: 6px;
    color: #8b949e; font-size: 12px;
    margin-right: 8px;
}

/* ─────────────── queue tab ─────────────── */
.queue-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
    align-items: start;
}
.queue-log h3 {
    margin: 0 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    color: #8b949e;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.output {
    background: #010409;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
    height: 480px;
    overflow-y: auto;
    margin: 0 0 8px;
}

/* ─────────────── modal ─────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(1, 4, 9, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    width: 540px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid #30363d;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 14px; }
.modal-close {
    background: transparent; border: 0; color: #8b949e;
    font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #f85149; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-body .form-row {
    display: flex; flex-direction: column;
    gap: 4px; margin-bottom: 12px;
    font-size: 12px; color: #8b949e;
}
.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    color: #e6edf3;
}
.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #30363d;
    display: flex; gap: 8px; justify-content: flex-end;
}

/* ─────────────── toast ─────────────── */
.toast-container {
    position: fixed;
    bottom: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2000;
}
.toast {
    background: #21262d;
    border-left: 3px solid #58a6ff;
    color: #e6edf3;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    min-width: 240px;
    max-width: 420px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    animation: slidein 0.18s ease;
}
.toast.ok { border-left-color: #3fb950; }
.toast.err { border-left-color: #f85149; }
.toast.warn { border-left-color: #d29922; }
@keyframes slidein {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1100px) {
    .queue-grid { grid-template-columns: 1fr; }
}
