/*
 * Operations dashboard styling.
 *
 * Values come straight from design_handoff_barcode_ops/README.md, which is
 * the visual source of truth. The handoff specifies Tailwind's default scale;
 * this is that same scale written out directly, which keeps the "one
 * committed stylesheet, no build step on the server" constraint without
 * shipping a 3 MB generated file or needing node.
 *
 * Rule from the handoff worth restating: a healthy screen is white and grey.
 * Colour is state, never decoration.
 */

:root {
    --canvas: #eceef1;
    --page: #ffffff;
    --panel: #f9fafb;
    --raised: #f3f4f6;
    --hairline: #eef0f2;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --text-1: #1a1d21;
    --text-2: #5f6670;
    --text-3: #8b929c;

    --money: #b45309;
    --failing: #dc2626;
    --recovered: #15803d;

    --red-bg: #fef2f2;
    --red-text: #b91c1c;
    --red-border: #fecaca;
    --amber-bg: #fffbeb;

    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text-1);
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: inherit; }

/* No radius anywhere, no shadows. */
* { border-radius: 0 !important; box-shadow: none !important; }

.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.t3 { color: var(--text-3); }
.t2 { color: var(--text-2); }
.money { color: var(--money); }
.failing { color: var(--failing); }
.recovered { color: var(--recovered); }
.w500 { font-weight: 500; }

/* ---- top bar, 40px ---- */
.topbar {
    height: 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

.wordmark { font-family: var(--mono); font-weight: 500; font-size: 13px; }
.wordmark span { color: var(--text-3); }

.nav { display: flex; align-items: center; flex: 1; }
.nav a {
    font-size: 13px;
    padding: 0 10px;
    color: var(--text-2);
    line-height: 38px;
    border-bottom: 2px solid transparent;
}
.nav a.active { color: var(--text-1); font-weight: 500; border-bottom-color: var(--text-1); }

.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--text-3); }

.livedot {
    display: inline-block; width: 6px; height: 6px;
    background: var(--text-3); margin-right: 6px;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.env-badge {
    font-family: var(--mono); font-size: 11px;
    border: 1px solid var(--border-strong); padding: 1px 6px; color: var(--text-2);
}

/* ---- alert strips ---- */
.alert {
    display: flex; align-items: center; gap: 8px;
    padding: 0 16px; font-size: 12px;
}
.alert-red { height: 36px; background: var(--red-bg); color: var(--red-text); }
.alert-amber { height: 32px; background: var(--amber-bg); color: var(--text-1); }
.alert .label { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.alert .spacer { flex: 1; }
.alert button {
    background: none; border: 1px solid currentColor;
    padding: 2px 8px; font-size: 12px; color: inherit; cursor: pointer;
}

/* ---- page header ---- */
.page-header { padding: 16px 16px 8px; display: flex; align-items: flex-start; gap: 16px; }
.page-title { font-size: 20px; font-weight: 600; margin: 0; }
.page-summary { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.page-header .spacer { flex: 1; }

.btn {
    background: none; border: 1px solid var(--text-1); color: var(--text-1);
    font-weight: 500; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.btn-secondary { border-color: var(--border-strong); color: var(--text-2); font-weight: 400; }
.btn-danger { border-color: var(--failing); color: var(--failing); }

/* ---- filter chips ---- */
.chips { display: flex; align-items: center; gap: 8px; padding: 0 16px 8px; font-size: 12px; }
.chip { border: 1px solid var(--border-strong); padding: 2px 8px; color: var(--text-2); }
.chip.active { border-color: var(--text-1); color: var(--text-1); font-weight: 500; }
.chip.danger { color: var(--failing); border-color: var(--failing); }
.chips .spacer { flex: 1; }

/* ---- tables ---- */
.table-wrap { padding: 0 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: auto; }

thead th {
    height: 30px; font-size: 12px; font-weight: 500; color: var(--text-2);
    text-align: left; padding: 0 8px; border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
thead th.num { text-align: right; }

tbody td {
    height: 32px; padding: 0 8px; font-size: 12px;
    border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
tbody tr.disabled td { color: var(--text-3); }
tbody tr.breaker-open td { background: rgba(220, 38, 38, 0.05); }
tbody tr.editing td { background: var(--panel); }

td.divider, th.divider { border-left: 1px solid var(--border); }

tfoot td {
    height: 32px; padding: 0 8px; font-size: 12px;
    border-top: 1px solid var(--border-strong); font-variant-numeric: tabular-nums;
}
tfoot .label { font-size: 11px; text-transform: uppercase; color: var(--text-2); text-align: right; }

/* ---- tier language: glyph plus T digit, readable without colour ---- */
.tier { font-family: var(--mono); font-size: 12px; }
.tier .glyph { display: inline-block; width: 14px; }
.tier-2 { color: var(--money); }

/* ---- status badges: outline is information, solid fill is an alarm ---- */
.badge {
    font-family: var(--mono); font-size: 11px; padding: 1px 6px;
    border: 1px solid var(--border-strong); color: var(--text-2);
    display: inline-block;
}
.badge-open { background: var(--failing); border-color: var(--failing); color: #fff; font-weight: 500; }
.badge-half { border-color: var(--money); color: var(--money); }
.badge-cap { border-color: var(--failing); color: var(--failing); }
.badge-disabled { border-style: dashed; color: var(--text-3); }
.badge-recovered { border-color: var(--recovered); color: var(--recovered); }
.badge-approved { border-color: var(--recovered); color: var(--recovered); }
.badge-pending { border-color: var(--money); color: var(--money); }
.badge-rejected { border-color: var(--failing); color: var(--failing); }

/* ---- toggle, 26x14 with an 8px knob ---- */
.toggle {
    width: 26px; height: 14px; border: 1px solid var(--border-strong);
    position: relative; display: inline-block; cursor: pointer; background: none; padding: 0;
}
.toggle .knob {
    position: absolute; top: 2px; left: 2px; width: 8px; height: 8px;
    background: var(--text-3);
}
.toggle.on { border-color: var(--text-1); background: var(--text-1); }
.toggle.on .knob { left: 14px; background: #fff; }

/* ---- spend meter, fixed width so the value never moves ---- */
.meter { min-width: 120px; }
.meter .line { display: flex; justify-content: space-between; font-size: 11px; font-variant-numeric: tabular-nums; }
.meter .track { height: 2px; background: var(--border); margin-top: 3px; }
.meter .fill { height: 2px; background: var(--text-2); }
.meter.warn .fill { background: var(--money); }
.meter.warn .line { color: var(--money); }
.meter.over .fill { background: var(--failing); }
.meter.over .line { color: var(--failing); }

/* ---- panels ---- */
.panel { margin: 16px; border: 1px solid var(--border); padding: 8px; }
.panel-title { font-size: 14px; font-weight: 500; }
.panel-meta { font-size: 12px; color: var(--text-3); }

.section { padding: 0 16px 16px; }
.section-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; }

/* ---- cascade strip ---- */
.cascade { display: flex; height: 14px; gap: 1px; margin: 8px 0; }
.cascade .seg-0 { background: var(--text-1); }
.cascade .seg-1 { border: 1px solid var(--text-2); }
.cascade .seg-2 { background: var(--money); }
.cascade .seg-3 { border: 1px dashed var(--text-3); }

.legend { display: flex; gap: 24px; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }

/* ---- empty and error states ---- */
.state { border: 1px solid var(--border); padding: 24px 16px; margin: 16px; }
.state .title { font-weight: 500; }
.state .body { color: var(--text-3); margin-top: 4px; }
.state.error { border-color: var(--red-border); }
.state.error .title { color: var(--red-text); }
.state .request { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-top: 8px; }

/* ---- forms ---- */
.field { display: block; margin-bottom: 12px; }
.field .label { font-size: 12px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 4px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 5px 8px; border: 1px solid var(--border-strong);
    background: var(--raised); color: var(--text-1); font-size: 13px;
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.keyreveal {
    font-family: var(--mono); font-size: 13px; background: var(--raised);
    border: 1px solid var(--border-strong); padding: 8px; word-break: break-all;
}

@media (max-width: 900px) {
    .nav { overflow-x: auto; }
    .table-wrap { overflow-x: auto; }
}
