/* The app's one button. 30px matches .ctrl and .bld-picker-trigger, so a button
   beside a field lands on the same baseline instead of floating a pixel or two
   off it. Press gives a 1px drop rather than a scale — scaling a monospace
   label resamples the glyphs and reads as a blur at this size. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 30px;
    padding: 0 13px;
    font-size: 12px;
    font-family: var(--mono);
    border: 1px solid var(--border2);
    border-radius: var(--r);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--t-instant) linear,
    border-color var(--t-instant) linear,
    color var(--t-instant) linear,
    transform var(--t-instant) var(--e-out),
    box-shadow var(--t-fast) var(--e-out);
}

.btn:hover:not(:disabled) {
    background: var(--bg3);
    border-color: var(--border3);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

/* A visible keyboard focus state, matching the field ring in forms.css. */
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 95, 168, 0.35);
}

.btn.primary {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.btn.primary:hover:not(:disabled) {
    background: #fff;
    border-color: #fff;
}

/* The shared spinner is drawn for dark grounds; on the light primary fill it
   would otherwise vanish. */
.btn.primary .spinner,
.btn.primary .bld-spinner {
    border-color: rgba(0, 0, 0, 0.22);
    border-top-color: var(--bg);
}

.btn.danger {
    border-color: rgba(168, 58, 58, 0.45);
    color: var(--red-text);
}

.btn.danger:hover:not(:disabled) {
    background: rgba(168, 58, 58, 0.12);
    border-color: var(--red);
}

.btn.amber {
    border-color: var(--amber);
    color: var(--amber-text);
}

.btn.amber:hover:not(:disabled) {
    background: var(--amber-bg);
}

.btn.success {
    border-color: #1f8d4d;
    color: #6fd49a;
}

.btn.success:hover:not(:disabled) {
    background: rgba(31, 141, 77, 0.15);
}

/* Quiet variant for the tertiary action in a row of buttons — no border, so
   "reset" or "cancel" stops competing with the action beside it. */
.btn.ghost {
    border-color: transparent;
    color: var(--text2);
}

.btn.ghost:hover:not(:disabled) {
    background: var(--bg3);
    color: var(--text);
    border-color: transparent;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Size variants keep the shared padding rhythm. */
.btn.btn-sm {
    height: 26px;
    padding: 0 10px;
    font-size: 11.5px;
}

.banner {
    padding: 8px 24px;
    font-size: 11px;
    letter-spacing: 0.02em;
    border-bottom: 1px solid;
}

.banner.demo {
    color: var(--amber-text);
    background: var(--amber-bg);
    border-color: rgba(143, 106, 28, 0.2);
}

.banner.error {
    color: var(--red-text);
    background: var(--red-bg);
    border-color: rgba(168, 58, 58, 0.2);
    display: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.b-done {
    background: var(--green-bg);
    color: var(--green-text);
}

.b-error {
    background: var(--red-bg);
    color: var(--red-text);
}

.b-new {
    background: var(--blue-bg);
    color: var(--blue-text);
}

.b-processing {
    background: var(--amber-bg);
    color: var(--amber-text);
}

.dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.d-done {
    background: var(--green-text);
}

.d-error {
    background: var(--red-text);
}

.d-new {
    background: var(--blue-text);
}

.d-processing {
    background: var(--amber-text);
    animation: pulse 1.4s infinite;
}

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

.ok-cell {
    font-size: 11px;
    color: var(--green-text);
}

.err-cell {
    font-size: 11px;
    color: var(--red-text);
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    cursor: help;
}

.nil-cell {
    color: var(--text3);
}

.toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 21px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg4);
    border-radius: 21px;
    border: 1px solid var(--border2);
    transition: 0.2s;
    cursor: pointer;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--text3);
    top: 2px;
    left: 2px;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: rgba(45, 143, 94, 0.25);
    border-color: var(--green);
}

.toggle input:checked + .toggle-slider:before {
    background: var(--green-text);
    transform: translateX(17px);
}

.toggle-label {
    font-size: 11px;
    color: var(--text2);
}

/* @keyframes spin and .spinning moved to motion.css — one rotation for the
   whole app instead of four copies under four names. */

.empty-state {
    padding: 60px 24px;
    text-align: center;
    color: var(--text3);
}

/* User menu — avatar button + dropdown (admin / logout). Shared across the
   main services page and every inner page's topbar. Rendered by user-menu.js. */
.user-menu {
    position: relative;
    display: inline-flex;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: var(--bg3);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, background 0.1s;
}

.user-avatar:hover,
.user-menu.open .user-avatar {
    border-color: var(--blue-text);
    background: var(--bg4);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--r-md);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.user-menu.open .user-menu-dropdown {
    display: flex;
}

.user-menu-head {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.user-menu-name {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.user-menu-role {
    align-self: flex-start;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--blue-text);
    background: var(--blue-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--r);
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    transition: background 0.1s;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: var(--bg3);
    outline: none;
}

.user-menu-item.danger {
    color: var(--red-text);
}

.user-menu-item.danger:hover,
.user-menu-item.danger:focus-visible {
    background: var(--red-bg);
}

.user-menu-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}


/* ── period chips ──────────────────────────────── */
/* Shared by every page that reads a window out of `resolve_period` — the
   adset feed and the statistics service. It lives here rather than in
   either page's own stylesheet because the two must stay visually identical:
   the same chips meaning the same windows is the whole point of sharing the
   period vocabulary. */

.period-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.period-chip {
    padding: 4px 11px;
    font-size: 12px;
    font-family: var(--mono);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg2);
    color: var(--text2);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--t-instant) linear,
                border-color var(--t-instant) linear,
                background var(--t-instant) linear;
}

.period-chip:hover {
    color: var(--text);
    border-color: var(--border2);
}

.period-chip.active {
    color: var(--blue-text);
    border-color: var(--blue);
    background: var(--blue-bg);
}

.period-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
}

.period-custom .finput {
    width: 132px;
}

.period-dash {
    color: var(--text3);
}

/* ── partner / status pills, geo tag ───────────── */
/* The adset feed and the statistics tables speak the same vocabulary for a
   report row. The canonical partner earns the colour because it is what
   decides whether a duplicated ad goes live (only Visymo does); an
   unrecognised partner stays neutral rather than borrowing either signal. */

.ptag,
.stag {
    font-size: 10.5px;
    padding: 1px 7px;
    border: 1px solid var(--border2);
    border-radius: 10px;
    color: var(--text2);
    white-space: nowrap;
}

.ptag.visymo {
    color: var(--green-text);
    border-color: var(--green);
    background: var(--green-bg);
}

.ptag.tonic {
    color: var(--amber-text);
    border-color: var(--amber);
    background: var(--amber-bg);
}

.stag.on {
    color: var(--green-text);
    border-color: var(--green);
}

.stag.off {
    color: var(--text3);
    border-style: dashed;
}

.geo-tag {
    display: inline-block;
    margin-right: 7px;
    padding: 0 5px;
    font-size: 10px;
    border: 1px solid var(--border2);
    border-radius: 3px;
    color: var(--text2);
}

/* ── idle sign-out prompt (static/js/idle-logout.js) ─────────────── */

.idle-warn {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: idle-warn-fade var(--t-base) var(--e-out) both;
}

.idle-warn-card {
    width: 100%;
    max-width: 360px;
    padding: 22px 22px 18px;
    font-family: var(--sans);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.idle-warn-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.idle-warn-text {
    margin-top: 6px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text2);
}

.idle-warn-text b {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.idle-warn-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.idle-warn-actions .btn {
    font-family: var(--sans);
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 10px;
    text-decoration: none;
}

@keyframes idle-warn-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

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