/* ==========================================================================
   TEXFLOW ERP — Reusable components
   ========================================================================== */

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.card + .card { margin-top: 16px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.card-head h2,
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .c-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-head-actions { display: flex; align-items: center; gap: 8px; }

.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }

.card-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--r-md) var(--r-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

a.card-link { display: block; color: inherit; transition: box-shadow .12s, transform .12s; }
a.card-link:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    color: inherit;
}

.card.accent-blue   { border-top: 3px solid var(--blue); }
.card.accent-green  { border-top: 3px solid var(--green); }
.card.accent-amber  { border-top: 3px solid var(--amber); }
.card.accent-red    { border-top: 3px solid var(--red); }
.card.accent-purple { border-top: 3px solid var(--purple); }

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 10px;
}
.section-title h2 { font-size: 15px; }
.section-title .st-sub { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ KPI -- */

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
.kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.kpi-value {
    margin-top: 6px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.kpi-value.sm { font-size: 19px; }
.kpi-foot {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}
.delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.delta.up   { color: var(--green); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--muted); }

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.kpi-strip > div {
    padding: 12px 16px;
    border-right: 1px solid var(--border);
    min-width: 0;
}
.kpi-strip > div:last-child { border-right: 0; }

/* --------------------------------------------------------------- Badges -- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    background: var(--surface-sunken);
    color: var(--text-2);
    border: 1px solid transparent;
}
.badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.badge.no-dot::before { display: none; }

.badge.green  { background: var(--green-light);  color: #15803D; }
.badge.blue   { background: var(--blue-light);   color: #1D4ED8; }
.badge.amber  { background: var(--amber-light);  color: #B45309; }
.badge.red    { background: var(--red-light);    color: #B91C1C; }
.badge.purple { background: var(--purple-light); color: #6D28D9; }
.badge.teal   { background: var(--teal-light);   color: #0F766E; }
.badge.gray   { background: var(--surface-sunken); color: var(--muted); }
.badge.solid-red   { background: var(--red);   color: #fff; }
.badge.solid-green { background: var(--green); color: #fff; }
.badge.solid-blue  { background: var(--blue);  color: #fff; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
}
.chip .x { color: var(--muted-2); font-size: 13px; }
.chip:hover { border-color: var(--border-strong); }

.tag-mono {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: -.01em;
    color: var(--text-2);
}

.risk-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    flex: none;
}
.risk-dot.red   { background: var(--red);   box-shadow: 0 0 0 3px var(--red-light); }
.risk-dot.amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-light); }
.risk-dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-light); }

/* -------------------------------------------------------------- Buttons -- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--r);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--surface-sunken);
    color: var(--text);
    transition: background .12s, border-color .12s, color .12s;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary   { background: var(--blue);  color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }

.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-700); color: #fff; }

.btn-outline   { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { background: var(--surface-alt); border-color: var(--muted-2); color: var(--text); }

.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #B91C1C; color: #fff; }

.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803D; color: #fff; }

.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 40px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }

.btn-group {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    overflow: hidden;
    background: var(--surface);
}
.btn-group > * {
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    border-right: 1px solid var(--border);
    background: var(--surface);
}
.btn-group > *:last-child { border-right: 0; }
.btn-group > *:hover { background: var(--surface-alt); color: var(--text); }
.btn-group > .is-on { background: var(--navy); color: #fff; }
.btn-group > .is-on:hover { background: var(--navy); color: #fff; }

/* ----------------------------------------------------------- CSS-only tabs */

.tabs { position: relative; }
.tab-r { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

.tab-bar {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    scrollbar-width: thin;
}
.tab {
    flex: none;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab:hover { color: var(--text); background: var(--surface-alt); }
.tab .tab-n {
    font-size: 10px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.tab-p { display: none; }
.tab-p.is-open { display: block; }

/* map radio N -> label N + panel N (up to 12 tabs) */
.tab-r:nth-of-type(1):checked  ~ .tab-bar > .tab:nth-of-type(1),
.tab-r:nth-of-type(2):checked  ~ .tab-bar > .tab:nth-of-type(2),
.tab-r:nth-of-type(3):checked  ~ .tab-bar > .tab:nth-of-type(3),
.tab-r:nth-of-type(4):checked  ~ .tab-bar > .tab:nth-of-type(4),
.tab-r:nth-of-type(5):checked  ~ .tab-bar > .tab:nth-of-type(5),
.tab-r:nth-of-type(6):checked  ~ .tab-bar > .tab:nth-of-type(6),
.tab-r:nth-of-type(7):checked  ~ .tab-bar > .tab:nth-of-type(7),
.tab-r:nth-of-type(8):checked  ~ .tab-bar > .tab:nth-of-type(8),
.tab-r:nth-of-type(9):checked  ~ .tab-bar > .tab:nth-of-type(9),
.tab-r:nth-of-type(10):checked ~ .tab-bar > .tab:nth-of-type(10),
.tab-r:nth-of-type(11):checked ~ .tab-bar > .tab:nth-of-type(11),
.tab-r:nth-of-type(12):checked ~ .tab-bar > .tab:nth-of-type(12) {
    color: var(--blue);
    font-weight: 600;
    border-bottom-color: var(--blue);
    background: transparent;
}
.tab-r:nth-of-type(1):checked  ~ .tab-body > .tab-p:nth-of-type(1),
.tab-r:nth-of-type(2):checked  ~ .tab-body > .tab-p:nth-of-type(2),
.tab-r:nth-of-type(3):checked  ~ .tab-body > .tab-p:nth-of-type(3),
.tab-r:nth-of-type(4):checked  ~ .tab-body > .tab-p:nth-of-type(4),
.tab-r:nth-of-type(5):checked  ~ .tab-body > .tab-p:nth-of-type(5),
.tab-r:nth-of-type(6):checked  ~ .tab-body > .tab-p:nth-of-type(6),
.tab-r:nth-of-type(7):checked  ~ .tab-body > .tab-p:nth-of-type(7),
.tab-r:nth-of-type(8):checked  ~ .tab-body > .tab-p:nth-of-type(8),
.tab-r:nth-of-type(9):checked  ~ .tab-body > .tab-p:nth-of-type(9),
.tab-r:nth-of-type(10):checked ~ .tab-body > .tab-p:nth-of-type(10),
.tab-r:nth-of-type(11):checked ~ .tab-body > .tab-p:nth-of-type(11),
.tab-r:nth-of-type(12):checked ~ .tab-body > .tab-p:nth-of-type(12) {
    display: block;
}
.tab-r:focus-visible ~ .tab-bar > .tab { outline: none; }
.tab-r:nth-of-type(1):focus-visible  ~ .tab-bar > .tab:nth-of-type(1),
.tab-r:nth-of-type(2):focus-visible  ~ .tab-bar > .tab:nth-of-type(2),
.tab-r:nth-of-type(3):focus-visible  ~ .tab-bar > .tab:nth-of-type(3),
.tab-r:nth-of-type(4):focus-visible  ~ .tab-bar > .tab:nth-of-type(4) {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

/* ------------------------------------------------------------- Progress -- */

.progress {
    position: relative;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    overflow: hidden;
}
.progress > span {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--blue);
}
.progress.lg { height: 10px; }
.progress.xl { height: 16px; }
.progress > span.green  { background: var(--green); }
.progress > span.amber  { background: var(--amber); }
.progress > span.red    { background: var(--red); }
.progress > span.purple { background: var(--purple); }
.progress > span.teal   { background: var(--teal); }
.progress > span.navy   { background: var(--navy-600); }
.progress > span.striped {
    background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%,
        transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%);
    background-size: 12px 12px;
}

.meter-row {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr) 52px;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
}
.meter-row + .meter-row { border-top: 1px dashed var(--border); }
.meter-row .m-name { font-size: 13px; color: var(--text-2); }
.meter-row .m-val { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- Charts -- */

/* horizontal bar chart */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr) 62px;
    align-items: center;
    gap: 12px;
}
.bar-row .b-label { font-size: 12px; color: var(--text-2); }
.bar-row .b-track {
    height: 20px;
    background: var(--surface-sunken);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.bar-row .b-fill {
    height: 100%;
    background: var(--blue);
    border-radius: var(--r-sm);
    display: block;
}
.bar-row .b-fill.green  { background: var(--green); }
.bar-row .b-fill.amber  { background: var(--amber); }
.bar-row .b-fill.red    { background: var(--red); }
.bar-row .b-fill.purple { background: var(--purple); }
.bar-row .b-fill.teal   { background: var(--teal); }
.bar-row .b-val { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* vertical column chart */
.col-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 190px;
    padding-top: 8px;
}
.col-chart .col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    height: 100%;
    min-width: 0;
}
.col-chart .col .stack-bars {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}
.col-chart .bar {
    width: 100%;
    max-width: 44px;
    margin: 0 auto;
    background: var(--blue);
    border-radius: 3px 3px 0 0;
    display: block;
    position: relative;
}
.col-chart .bar.soft   { background: #BFDBFE; }
.col-chart .bar.green  { background: var(--green); }
.col-chart .bar.amber  { background: var(--amber); }
.col-chart .bar.navy   { background: var(--navy-600); }
.col-chart .col em {
    font-style: normal;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}
.col-chart .col b {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}
.chart-legend i {
    width: 9px; height: 9px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 5px;
}

/* donut via conic-gradient */
.donut {
    --p: 70;
    --c: var(--blue);
    width: 132px; height: 132px;
    border-radius: 50%;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-sunken) 0);
    display: grid;
    place-items: center;
    flex: none;
}
.donut::after {
    content: "";
    width: 96px; height: 96px;
    background: var(--surface);
    border-radius: 50%;
    grid-area: 1 / 1;
}
.donut .donut-center {
    grid-area: 1 / 1;
    z-index: 1;
    text-align: center;
}
.donut .d-val { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.donut .d-lab { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

/* segmented stacked bar */
.stackbar {
    display: flex;
    height: 12px;
    border-radius: var(--r-pill);
    overflow: hidden;
    background: var(--surface-sunken);
}
.stackbar > span { display: block; height: 100%; }

/* sparkline made of bars */
.spark {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 30px;
}
.spark i {
    flex: 1;
    background: #BFDBFE;
    border-radius: 1px;
    display: block;
}
.spark i.on { background: var(--blue); }

/* ------------------------------------------------------------- Pipeline -- */

.pipeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    padding: 4px 0 2px;
}
.pipe-step {
    flex: 1 0 auto;
    min-width: 92px;
    text-align: center;
    position: relative;
    padding: 0 4px;
}
.pipe-step::before {
    content: "";
    position: absolute;
    top: 13px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
}
.pipe-step:first-child::before { display: none; }
.pipe-step .dot {
    position: relative;
    z-index: 1;
    width: 28px; height: 28px;
    margin: 0 auto 7px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    color: var(--muted-2);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}
.pipe-step .p-name { font-size: 11px; font-weight: 600; color: var(--muted); display: block; }
.pipe-step .p-sub  { font-size: 10px; color: var(--muted-2); display: block; margin-top: 2px; font-variant-numeric: tabular-nums; }

.pipe-step.done::before { background: var(--green); }
.pipe-step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.pipe-step.done .p-name { color: var(--text); }

.pipe-step.active::before { background: var(--green); }
.pipe-step.active .dot {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .16);
}
.pipe-step.active .p-name { color: var(--blue); }

.pipe-step.warn::before { background: var(--amber); }
.pipe-step.warn .dot { background: var(--amber); border-color: var(--amber); color: #fff; }
.pipe-step.warn .p-name { color: var(--amber); }

/* compact arrow flow (process diagrams) */
.flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.flow .f-node {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--r);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}
.flow .f-node.on { background: var(--blue-light); border-color: #BFDBFE; color: var(--blue-dark); }
.flow .f-node.done { background: var(--green-light); border-color: #BBF7D0; color: #15803D; }
.flow .f-arrow { color: var(--muted-2); font-size: 13px; }

/* ------------------------------------------------------------- Timeline -- */

.timeline { position: relative; padding-left: 20px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 5px; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--border);
}
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
    content: "";
    position: absolute;
    left: -19px; top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
}
.tl-item.done::before   { background: var(--green); border-color: var(--green); }
.tl-item.active::before { background: var(--blue);  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.16); }
.tl-item.warn::before   { background: var(--amber); border-color: var(--amber); }
.tl-item.late::before   { background: var(--red);   border-color: var(--red); }

.tl-time { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 13px; font-weight: 600; margin-top: 1px; }
.tl-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* TNA style timeline with planned/actual columns */
.tna-row {
    display: grid;
    grid-template-columns: 24px minmax(140px, 1.6fr) 96px 96px 78px 120px 108px;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.tna-row:last-child { border-bottom: 0; }
.tna-row:hover { background: var(--surface-alt); }
.tna-row .t-node {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface);
    position: relative;
    z-index: 1;
    margin-left: 5px;
}
.tna-row .t-node::after {
    content: "";
    position: absolute;
    left: 3px; top: 12px;
    width: 2px; height: 30px;
    background: var(--border);
    z-index: -1;
}
.tna-row:last-child .t-node::after { display: none; }
.tna-row.done .t-node { background: var(--green); border-color: var(--green); }
.tna-row.warn .t-node { background: var(--amber); border-color: var(--amber); }
.tna-row.late .t-node { background: var(--red); border-color: var(--red); }
.tna-row.active .t-node { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.16); }
.tna-row .t-name { display: block; font-size: 13px; font-weight: 600; }
.tna-row .t-dept { display: block; font-size: 11px; color: var(--muted); }
.tna-row .t-date { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* --------------------------------------------------------------- Alerts -- */

.alert-list { display: flex; flex-direction: column; }
.alert-item {
    display: flex;
    gap: 11px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    color: inherit;
}
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: var(--surface-alt); color: inherit; }
.alert-ico {
    width: 28px; height: 28px;
    flex: none;
    border-radius: var(--r);
    display: grid;
    place-items: center;
    font-size: 13px;
    background: var(--surface-sunken);
}
.alert-ico.red    { background: var(--red-light);    color: var(--red); }
.alert-ico.amber  { background: var(--amber-light);  color: var(--amber); }
.alert-ico.green  { background: var(--green-light);  color: var(--green); }
.alert-ico.blue   { background: var(--blue-light);   color: var(--blue); }
.alert-ico.purple { background: var(--purple-light); color: var(--purple); }
.alert-ico svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.alert-body { min-width: 0; flex: 1; }
.alert-title { display: block; font-size: 13px; font-weight: 600; }
.alert-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.alert-time { font-size: 11px; color: var(--muted-2); white-space: nowrap; }

.banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
}
.banner.red   { background: var(--red-light);   border-color: #FECACA; color: #991B1B; }
.banner.amber { background: var(--amber-light); border-color: #FDE68A; color: #92400E; }
.banner.green { background: var(--green-light); border-color: #BBF7D0; color: #166534; }
.banner.blue  { background: var(--blue-light);  border-color: #BFDBFE; color: #1E40AF; }
.banner strong { font-weight: 700; }
.banner .banner-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

/* ------------------------------------------------------- Definition list -- */

.dl {
    display: grid;
    grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
    gap: 0;
}
.dl dt {
    font-size: 12px;
    color: var(--muted);
    padding: 7px 0;
    border-bottom: 1px dashed var(--border);
}
.dl dd {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    text-align: right;
    padding: 7px 0;
    border-bottom: 1px dashed var(--border);
}
.dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }

.spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
}
.spec-grid > div { background: var(--surface); padding: 10px 12px; }
.spec-grid .s-k {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
}
.spec-grid .s-v { font-size: 13px; font-weight: 600; margin-top: 2px; }

/* ------------------------------------------------------------- Swatches -- */

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { text-align: center; width: 62px; }
.swatch i {
    display: block;
    width: 46px; height: 46px;
    margin: 0 auto 5px;
    border-radius: var(--r);
    border: 1px solid rgba(15, 23, 42, .12);
}
.swatch span { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------- Empty/error -- */

.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--muted);
}
.empty .e-ico {
    width: 46px; height: 46px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--surface-sunken);
    display: grid;
    place-items: center;
    color: var(--muted-2);
}
.empty .e-ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { font-size: 14px; color: var(--text); }
.empty p { font-size: 13px; margin: 5px 0 14px; }

/* skeleton loading blocks */
.skeleton { display: flex; flex-direction: column; gap: 9px; }
.sk {
    height: 12px;
    border-radius: var(--r-sm);
    background: linear-gradient(90deg, #EEF2F7 0%, #E2E8F0 50%, #EEF2F7 100%);
    background-size: 200% 100%;
    animation: sk 1.4s ease-in-out infinite;
}
.sk.w-40 { width: 40%; }
.sk.w-60 { width: 60%; }
.sk.w-80 { width: 80%; }
.sk.h-24 { height: 24px; }
@keyframes sk {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .sk { animation: none; }
}

/* --------------------------------------------------- CSS-only modal/drawer */

.overlay-toggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(15, 23, 42, .45);
    padding: 24px;
    overflow-y: auto;
}
.overlay-toggle:checked ~ .modal { display: flex; align-items: flex-start; justify-content: center; }
.modal-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    margin: 6vh auto;
    position: relative;
    z-index: 1;
}
.modal-card.wide { max-width: 760px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--surface-alt);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-close-area { position: absolute; inset: 0; cursor: default; }
.x-btn {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: var(--r);
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.x-btn:hover { background: var(--surface-sunken); color: var(--text); }

/* right-side drawer */
.drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(15, 23, 42, .45);
}
.overlay-toggle:checked ~ .drawer { display: block; }
.drawer-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 400px;
    max-width: 92vw;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}
.drawer-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.drawer-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* -------------------------------------------------------------- Tooltip -- */

[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--navy);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    padding: 5px 9px;
    border-radius: var(--r);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s;
    z-index: 90;
    box-shadow: var(--shadow-md);
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; }

.info-i {
    display: inline-grid;
    place-items: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    color: var(--muted-2);
    font-size: 9px;
    font-weight: 700;
    cursor: help;
}

/* --------------------------------------------------- CSS-only disclosure -- */

.acc { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.acc + .acc { margin-top: 8px; }
.acc-toggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.acc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
}
.acc-head:hover { background: var(--surface-alt); }
.acc-head .caret { color: var(--muted-2); font-size: 11px; transition: transform .15s; }
.acc-panel { display: none; padding: 0 14px 14px; border-top: 1px solid var(--border); }
.acc-toggle:checked ~ .acc-panel { display: block; }
.acc-toggle:checked ~ .acc-head .caret { transform: rotate(90deg); }

/* ------------------------------------------------------------ Documents -- */

.doc {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 34px 38px;
    max-width: 860px;
    margin: 0 auto;
    box-shadow: var(--shadow-sm);
}
.doc-head {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    border-bottom: 2px solid var(--navy);
}
.doc-co-name { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.doc-co-line { font-size: 11px; color: var(--muted); line-height: 1.6; }
.doc-type {
    text-align: right;
}
.doc-type h2 {
    font-size: 15px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--navy);
}
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
}
.doc-grid .d-k {
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 3px;
}
.doc-grid .d-v { font-size: 13px; line-height: 1.6; }
.doc-total-box {
    margin-left: auto;
    width: min(320px, 100%);
    margin-top: 14px;
}
.doc-total-box .t-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px dashed var(--border);
}
.doc-total-box .t-row.grand {
    border-top: 2px solid var(--navy);
    border-bottom: 0;
    margin-top: 6px;
    padding-top: 10px;
    font-size: 16px;
    font-weight: 700;
}
.doc-sign {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-top: 44px;
    flex-wrap: wrap;
}
.doc-sign div {
    border-top: 1px solid var(--border-strong);
    padding-top: 6px;
    font-size: 11px;
    color: var(--muted);
    min-width: 180px;
}
.doc-note { font-size: 11px; color: var(--muted); line-height: 1.7; margin-top: 20px; }

/* ------------------------------------------------------- Misc list items -- */

.list-plain > li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.list-plain > li:last-child { border-bottom: 0; }

.lift-list > a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    color: inherit;
}
.lift-list > a:last-child { border-bottom: 0; }
.lift-list > a:hover { background: var(--surface-alt); color: inherit; }

.t-sub {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.mini-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 7px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.xs    { font-size: 11px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.t-green { color: var(--green); }
.t-red   { color: var(--red); }
.t-amber { color: var(--amber); }
.t-blue  { color: var(--blue); }
.center { text-align: center; }
.right  { text-align: right; }
.nowrap { white-space: nowrap; }

/* machine / shop-floor cards */
.machine {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    padding: 12px 14px;
    border-left: 3px solid var(--border-strong);
}
.machine.run   { border-left-color: var(--green); }
.machine.idle  { border-left-color: var(--muted-2); }
.machine.maint { border-left-color: var(--amber); }
.machine.down  { border-left-color: var(--red); }
.machine .m-id { font-size: 13px; font-weight: 700; }
.machine .m-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.machine .m-stat { margin-top: 9px; display: flex; justify-content: space-between; font-size: 12px; }

/* bundle chips (cutting → sewing traceability) */
.bundle {
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 9px 11px;
    background: var(--surface);
    font-size: 12px;
}
.bundle .b-id { font-family: var(--mono); font-weight: 600; font-size: 12px; }
.bundle .b-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.bundle.done { background: var(--green-light); border-color: #BBF7D0; }
.bundle.wip  { background: var(--blue-light);  border-color: #BFDBFE; }
.bundle.hold { background: var(--amber-light); border-color: #FDE68A; }

/* size matrix */
.matrix { overflow-x: auto; }
.matrix table { min-width: 480px; }
.matrix th, .matrix td {
    border: 1px solid var(--border);
    padding: 7px 10px;
    text-align: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.matrix thead th {
    background: var(--surface-sunken);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}
.matrix tbody th {
    background: var(--surface-alt);
    text-align: left;
    font-weight: 600;
}
.matrix tfoot td, .matrix tfoot th {
    background: var(--surface-alt);
    font-weight: 700;
}
.matrix td.zero { color: var(--muted-2); }

/* garment thumbnail */
.thumb {
    width: 40px; height: 48px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--surface-alt);
    display: grid;
    place-items: center;
    flex: none;
    overflow: hidden;
}
.thumb img, .thumb svg { width: 100%; height: 100%; object-fit: contain; }
.thumb.lg { width: 96px; height: 116px; }
.thumb.xl { width: 100%; height: 220px; }
