/* Shared building blocks: buttons, cards, inputs, badges, alerts, tiles, tables. */

/* Buttons. Soft pills. On the login and setup screens the main button is green, inside the app it is deep forest. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 22px;
    border: 1.5px solid transparent; border-radius: var(--radius-pill);
    font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--gradient-primary); color: #FFFFFF; }
/* Hover swaps one gradient for a darker one. Fading a gradient into a flat colour made the button flash white. */
.btn-primary:hover { background: var(--gradient-primary-hover); color: #FFFFFF; }
.app-shell .btn-primary { background: var(--color-ink); }
.app-shell .btn-primary:hover { background: var(--color-ink-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-surface-alt); border-color: var(--color-border-input); color: var(--color-text); }
.btn-danger { background: #C9342A; color: #FFFFFF; }
.btn-danger:hover { background: #A82A21; color: #FFFFFF; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: 14px; }
.btn-lg { min-height: 56px; font-size: 17px; font-weight: 800; }
.btn-block { width: 100%; }

/* Cards: big soft corners, no hard border, a very light shadow. */
.card {
    /* Frosted: a see-through white, so the soft colour glow behind the page shows at the edges. No blur on purpose, it costs speed and a smooth glow looks the same blurred. */
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 10px 34px rgba(16, 35, 27, 0.07);
}
.card-body { padding: 22px 24px; }
/* A table at the bottom of a card follows the card's rounded corners, so a hovered last row never squares them off. */
.card > .table-wrap:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@media (max-width: 900px) { .card { background: rgba(255, 255, 255, 0.84); } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 26px 6px; }
.card-head h2 { font-size: 18px; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 700; }
.input {
    width: 100%; min-height: 52px; padding: 0 18px;
    border: 1.5px solid var(--color-border-input); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-text); font-size: 16px;
}
.input::placeholder { color: var(--color-text-muted); }
.input:focus { border-color: var(--color-primary); }
.validation-message { color: var(--color-danger-ink); font-size: 14px; font-weight: 600; }

/* An input with an icon on the left, and an optional show/hide button on the right. */
.input-wrap { position: relative; }
.input-wrap .input { padding-left: 48px; }
.input-wrap.has-toggle .input { padding-right: 54px; }
.input-icon {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    display: flex; color: var(--color-text-muted); pointer-events: none;
}
.input-wrap:focus-within .input-icon { color: var(--color-primary); }
/* Chrome paints saved or autofilled fields blue. I cover that with the normal surface colour so they look the same as empty ones. */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
    -webkit-text-fill-color: var(--color-text);
    caret-color: var(--color-text);
    transition: background-color 9999s ease-out 0s;
}
.input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset, var(--focus-ring); }

/* A pill shaped search box, for the top of lists. */
.search-pill { position: relative; flex: 1 1 260px; max-width: 360px; }
.search-pill .input { min-height: 44px; padding-left: 44px; border-radius: var(--radius-pill); border-color: var(--color-border); background: var(--color-surface-alt); font-size: 15px; }
.search-pill .input:focus { background: var(--color-surface); border-color: var(--color-primary); }
.search-pill .input-icon { left: 16px; }

/* Small filter pills ("All", "Active" ...). */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
    display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px;
    border: 1.5px solid var(--color-border); border-radius: var(--radius-pill);
    background: var(--color-surface); color: var(--color-text-nav); font-size: 14px; font-weight: 700; cursor: pointer;
}
.pill:hover { border-color: var(--color-border-input); }
.pill.is-on { background: var(--color-ink); border-color: var(--color-ink); color: #FFFFFF; }

/* Badges for status */
.badge {
    display: inline-block; padding: 5px 12px; border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 700; white-space: nowrap;
}
/* A badge that sits on the same line, right after a figure. */
.badge-inline { margin-left: 10px; }
.badge-success { background: var(--color-success-bg); color: var(--color-success-ink); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-ink); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger-ink); }
.badge-info { background: var(--color-info-bg); color: var(--color-info-ink); }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; line-height: 1.5; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger-ink); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-ink); }
.alert-notice { background: var(--color-notice-bg); color: var(--color-notice-ink); border: 1px solid var(--color-notice-border); }

/* Page header at the top of every screen */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header h1 { letter-spacing: -0.02em; }
.page-header p { margin-top: 6px; color: var(--color-text-muted); }

/* Pastel tiles on the dashboard. Each one is a link with a round arrow button. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
/* A dashboard with only a few tiles keeps them card sized instead of stretching across the screen. */
.kpi-grid.is-compact {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    max-width: calc(var(--cols, 3) * 300px + (var(--cols, 3) - 1) * 16px);
}
/* On a medium window (menu beside a narrow page) the tiles go two by two, and a lonely last tile takes the full row. */
@media (max-width: 1250px) {
    .kpi-grid.is-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-grid.is-compact .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.kpi {
    position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 22px;
    min-height: 152px; padding: 20px 22px; border-radius: var(--radius-lg);
    color: var(--tile-ink); text-decoration: none; transition: transform 0.18s ease, box-shadow 0.18s ease;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(16, 35, 27, 0.10); color: var(--tile-ink); }
.kpi-lime { background: var(--tile-lime); }
.kpi-mint { background: var(--tile-mint); }
.kpi-rose { background: var(--tile-rose); }
.kpi-lavender { background: var(--tile-lavender); }
.kpi-top { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.kpi-chip { width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, 0.65); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.kpi-go { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, 0.65); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.kpi-value { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.kpi-value.kpi-small { font-size: 24px; line-height: 1.2; }
.kpi-note { margin-top: 6px; font-size: 13px; font-weight: 600; opacity: 0.75; }

/* On a phone the tiles sit two by two, and a lonely last tile takes the full row. */
@media (max-width: 700px) {
    .kpi-grid, .kpi-grid.is-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi-grid.is-compact .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .kpi { min-height: 128px; padding: 16px; gap: 14px; }
    .kpi-top { gap: 8px; font-size: 13px; line-height: 1.2; }
    .kpi-chip { width: 32px; height: 32px; }
    .kpi-go { display: none; }
    .kpi-value { font-size: 32px; }
    .kpi-value.kpi-small { font-size: 20px; }
    .kpi-note { font-size: 12.5px; }
}

/* Older stat cards, still used on a few screens. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.stat-top { display: flex; align-items: center; gap: 12px; color: var(--color-text-muted); font-size: 14px; font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-chip { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.chip-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.chip-warning { background: var(--color-warning-bg); color: var(--color-warning-ink); }
.chip-danger { background: var(--color-danger-bg); color: var(--color-danger-ink); }
.chip-info { background: var(--color-info-bg); color: var(--color-info-ink); }
.stat-link { text-decoration: none; color: inherit; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.stat-link:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 35, 27, 0.10); color: inherit; }

/* Getting started: a stepper with a rail on the left. The next step to do is lifted, done steps go quiet. */
.gs { padding-bottom: 8px; }
.gs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 26px 28px 8px; }
.gs-head h2 { margin: 0; font-size: 22px; }
.gs-head p { margin: 4px 0 0; color: var(--color-text-muted); }
.gs-progress { display: flex; flex-direction: column; gap: 8px; min-width: 190px; }
.gs-count { font-size: 13px; color: var(--color-text-muted); }
.gs-count b { color: var(--color-ink); font-size: 15px; }
.gs-bar { display: block; height: 8px; border-radius: 999px; background: rgba(12, 61, 48, 0.09); overflow: hidden; }
.gs-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--gradient-primary); }
.gs-steps { list-style: none; margin: 0; padding: 18px 28px 22px; display: flex; flex-direction: column; gap: 14px; }
.gs-item { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 16px; align-items: center; }
.gs-rail { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: var(--color-text-muted); background: #FFFFFF; border: 2px solid var(--color-border-input); position: relative; z-index: 1; }
.gs-item::before, .gs-item::after { content: ""; position: absolute; left: 16px; width: 2px; background: var(--color-border-soft); }
.gs-item::before { top: -7px; bottom: 50%; }
.gs-item::after { top: 50%; bottom: -7px; }
.gs-item:first-child::before, .gs-item:last-child::after { display: none; }
.gs-item.is-done + .gs-item::before, .gs-item.is-done::after { background: rgba(11, 127, 90, 0.45); }
.gs-item.is-done .gs-rail { background: var(--color-ink); border-color: var(--color-ink); color: #FFFFFF; }
.gs-item.is-next .gs-rail { background: var(--gradient-primary); border-color: transparent; color: #FFFFFF; box-shadow: 0 0 0 5px rgba(11, 127, 90, 0.14); }
.gs-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 18px; text-decoration: none; color: inherit; background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(12, 61, 48, 0.07); transition: box-shadow 0.18s ease, border-color 0.18s ease; }
.gs-row:hover { color: inherit; box-shadow: 0 8px 22px rgba(16, 35, 27, 0.08); border-color: rgba(11, 127, 90, 0.25); }
.gs-item.is-next .gs-row { background: #FFFFFF; border-color: rgba(11, 127, 90, 0.3); box-shadow: 0 12px 30px rgba(11, 127, 90, 0.13); padding-top: 18px; padding-bottom: 18px; }
.gs-icon { width: 46px; height: 46px; border-radius: 14px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: var(--tile-ink); }
.gs-lime { background: var(--tile-lime); }
.gs-mint { background: var(--tile-mint); }
.gs-lav { background: var(--tile-lavender); }
.gs-rose { background: var(--tile-rose); }
.gs-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; }
.gs-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gs-sub { font-size: 13.5px; color: var(--color-text-muted); margin-top: 2px; }
.gs-tag { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary-deep); }
.gs-item.is-done .gs-title { color: var(--color-text-muted); font-weight: 600; }
.gs-item.is-done .gs-icon { opacity: 0.55; }
.gs-go { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: rgba(12, 61, 48, 0.06); color: var(--color-ink); }
.gs-cta { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; padding: 11px 20px; border-radius: 999px; font-weight: 700; color: #FFFFFF; background: var(--gradient-primary); transition: background 0.15s ease; }
.gs-row:hover .gs-cta { background: var(--gradient-primary-hover); }
@media (max-width: 640px) {
    .gs-head { padding: 22px 18px 4px; }
    .gs-progress { width: 100%; }
    .gs-steps { padding: 16px 16px 18px; }
    .gs-item { grid-template-columns: 30px 1fr; gap: 12px; }
    .gs-rail { width: 30px; height: 30px; font-size: 13px; }
    .gs-item::before, .gs-item::after { left: 14px; }
    .gs-row { flex-wrap: wrap; padding: 14px; gap: 12px; }
    .gs-cta { flex-basis: 100%; }
    .gs-icon { width: 40px; height: 40px; border-radius: 12px; }
    .gs-go { display: none; }
    .gs-cta { width: 100%; justify-content: center; }
}

/* Round initials, used in tables */
.avatar-sm { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; background: var(--tile-mint); color: var(--tile-ink); }
.avatar-sm.t1 { background: var(--tile-lime); }
.avatar-sm.t2 { background: var(--tile-mint); }
.avatar-sm.t3 { background: var(--tile-rose); }
.avatar-sm.t4 { background: var(--tile-lavender); }
.cell-person { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* Empty state: plain text for loading, and the EmptyState block (icon, title, line, button) everywhere else. */
.empty-state { padding: 48px 24px; text-align: center; color: var(--color-text-muted); line-height: 1.7; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--color-primary-soft); color: var(--color-primary); box-shadow: 0 0 0 8px rgba(11, 127, 90, 0.07); }
.empty-title { display: block; font-size: 17px; font-weight: 800; color: var(--color-ink); }
.empty-text { display: block; max-width: 440px; margin: 4px auto 0; font-size: 14.5px; line-height: 1.6; }
.empty-action { margin-top: 20px; }
.empty-state.is-compact { padding: 28px 20px; }
.empty-state.is-compact .empty-icon { width: 48px; height: 48px; margin-bottom: 12px; box-shadow: 0 0 0 6px rgba(11, 127, 90, 0.07); }
.empty-state.is-compact .empty-title { font-size: 15px; }
.empty-state.is-compact .empty-text { font-size: 13.5px; }

/* A toolbar above a list: search on the left, pills or buttons on the right. */
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 26px 8px; }

/* Tables. On a wide screen every row is a soft rounded strip, with the main thing (name, quantity, total) in dark bold and the rest quieter.
   On a phone every row turns into a small card, and the data-label of each cell becomes its caption. */
.table-wrap { overflow-x: auto; container-type: inline-size; padding: 0 16px 14px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-variant-numeric: tabular-nums; }
/* The header is a thin tinted band with small capital labels, so it reads as a label and never competes with the data. */
.table th {
    padding: 9px 18px; text-align: left; white-space: nowrap; background: rgba(214, 238, 226, 0.4);
    font-size: 11.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-text-muted);
}
.table th:first-child { padding-left: 22px; border-radius: 12px 0 0 12px; }
.table th:last-child { border-radius: 0 12px 12px 0; }
.table td {
    padding: 14px 18px; vertical-align: middle; color: var(--color-text-nav);
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid rgba(12, 61, 48, 0.07); border-bottom: 1px solid rgba(12, 61, 48, 0.07);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.table td:first-child { padding-left: 22px; border-left: 1px solid rgba(12, 61, 48, 0.07); border-radius: 16px 0 0 16px; }
.table td:last-child { border-right: 1px solid rgba(12, 61, 48, 0.07); border-radius: 0 16px 16px 0; }
/* On hover the strip turns a soft green and a thin bar appears at its start. */
.table tbody tr:hover td { background: rgba(226, 244, 235, 0.95); }
.table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--color-primary); }
.cell-title { display: block; font-weight: 800; color: var(--color-ink); }
.table td:first-child .cell-title { font-size: 15.5px; }
.cell-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--color-text-muted); }
.cell-link { text-decoration: none; color: inherit; }
.table .cell-link { color: var(--color-ink); }
.cell-link:hover, .table .cell-link:hover { color: var(--color-primary); text-decoration: underline; }

/* The table decides by its own width, not the window's, so it also copes with a narrow panel next to the menu. */
@container (max-width: 1000px) {
    /* Each row becomes a small rounded card: the title on top, then one tidy line per fact, caption on the left and value on the right. */
    .table thead { display: none; }
    .table, .table tbody { display: block; width: 100%; }
    .table tr {
        display: block; margin-bottom: 10px; padding: 14px 18px; border-radius: 18px;
        background: rgba(255, 255, 255, 0.72); border: 1px solid rgba(12, 61, 48, 0.07);
        transition: background 0.15s ease;
    }
    .table tbody tr:last-child { margin-bottom: 0; }
    .table tbody tr:hover { background: rgba(226, 244, 235, 0.95); }
    .table td, .table td:first-child, .table td:last-child {
        display: block; grid-column: 1 / -1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
    }
    /* Only the card itself changes on hover. If this rule also reset display, padding and border, the card would shrink under the cursor and flicker. */
    .table tbody tr:hover td, .table tbody tr:hover td:first-child { background: none; box-shadow: none; }
    /* The divider lines are a touch darker on the green hover colour, or they fade out of sight. */
    .table tbody tr:hover td[data-label]:not(:first-child) { border-top-color: rgba(12, 61, 48, 0.14); }
    /* The header is hidden, so the first card needs its own space from the edge of the panel. */
    .table tbody { padding-top: 12px; }
    .table td:first-child { padding-bottom: 8px; }
    .table .status-stack { align-items: flex-end; }
    .table td[data-label]:not(:first-child) {
        display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: baseline;
        padding: 6px 0; font-size: 14px; text-align: right; border-top: 1px solid var(--color-border-soft);
    }
    .table td[data-label]:not(:first-child)::before {
        content: attr(data-label); text-align: left; font-size: 13px; font-weight: 600; color: var(--color-text-muted);
    }
    .table td[data-label]:not(:first-child) > * { grid-column: 2; justify-self: end; }
    .table td[data-label]:not(:first-child) .cell-sub { margin-top: 0; }
    /* Buttons at the bottom of a card sit side by side. */
    .table td:not([data-label]) { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
    .dt { display: block; }
    .dt-time { display: inline; margin-left: 6px; }
}
/* When the table is not that narrow, I lay each card out as a grid so the facts sit side by side and the rows do not stretch. */
@container (min-width: 560px) and (max-width: 1000px) {
    .table tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 28px; padding: 18px 22px; }
    .table td:first-child { grid-column: 1 / -1; padding-bottom: 0; }
    .table td[data-label]:not(:first-child) { display: block; grid-column: auto; padding: 0; border-top: 0; text-align: left; }
    .table td[data-label]:not(:first-child)::before { display: block; margin-bottom: 2px; }
    .table td[data-label]:not(:first-child) > * { justify-self: start; }
    .table td:not([data-label]) { grid-column: 1 / -1; }
    .table .status-stack { align-items: flex-start; }
    .dt-time { display: block; margin-left: 0; }
}
@media (max-width: 700px) {
    .list-toolbar { padding: 16px 20px 6px; }
    .card-head { padding: 18px 20px 4px; }
    .todo-list { padding: 4px 20px 16px; }
}

/* A date with its time under it. The date never breaks, the time sits below in a slightly bolder weight. */
.dt-date { white-space: nowrap; }
.dt-time { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; color: var(--color-text-nav); }

/* Forms: two columns on a wide screen, one on a phone. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 700px) { .search-pill { flex: 1 1 100%; max-width: none; min-width: 0; } .form-grid { grid-template-columns: 1fr; } }
.field-hint { font-size: 13px; color: var(--color-text-muted); }

/* An input with fixed text stuck on its right side, like the .rxlume.com part of a subdomain. */
.input-group { display: flex; align-items: stretch; }
.input-group .input { min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix {
    display: flex; align-items: center; padding: 0 14px; white-space: nowrap;
    border: 1.5px solid var(--color-border-input); border-left: 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: var(--color-bg); color: var(--color-text-muted); font-weight: 600; font-size: 15px;
}

.table td[data-label="Added"], .table td[data-label="Joined"] { white-space: nowrap; }
@media (max-width: 700px) { .table td[data-label="Added"], .table td[data-label="Joined"] { white-space: normal; } }

/* A soft red button for risky actions such as Block. The solid red one stays for the final "Yes" in a confirm dialog. */
.btn-danger-soft { background: #FFF4F3; color: var(--color-danger-ink); border: 1.5px solid #F2BDB8; }
.btn-danger-soft:hover:not(:disabled) { background: var(--color-danger-bg); border-color: #E99A93; color: var(--color-danger-ink); }

/* A big avatar for page headers. */
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; background: var(--tile-mint); color: var(--tile-ink); }
.avatar-lg.t1 { background: var(--tile-lime); }
.avatar-lg.t2 { background: var(--tile-mint); }
.avatar-lg.t3 { background: var(--tile-rose); }
.avatar-lg.t4 { background: var(--tile-lavender); }

/* Buttons that sit at the right of a page header, for example "Add medicine". On a phone they share the row. */
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
@media (max-width: 700px) {
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1 1 0; padding: 0 14px; }
}

/* Previous and next under a long list. */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 26px 20px; border-top: 1px solid var(--color-border-soft); }
.pager-info { font-size: 14px; font-weight: 600; color: var(--color-text-muted); }
.pager-btns { display: flex; gap: 8px; }
@media (max-width: 700px) {
    .pager { padding: 14px 20px 18px; }
    .pager-info { width: 100%; }
    .pager-btns { width: 100%; }
    .pager-btns .btn { flex: 1 1 0; }
}

/* Small notes about dates and stock, in warning or danger colours. */
.text-warn { color: var(--color-warning-ink); font-weight: 700; }
.text-bad { color: var(--color-danger-ink); font-weight: 700; }

/* A form made of several cards. A form is not a flex child of the page, so it needs its own gap between the cards and the buttons. */
.form-stack { display: flex; flex-direction: column; gap: 22px; }

/* ---- Parts several screens share ---- */

.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 14px; font-weight: 700; color: var(--color-text-muted); text-decoration: none; }
.back-link:hover { color: var(--color-ink); }
.optional { font-weight: 600; color: var(--color-text-muted); }

/* The last column of a table, holding the row's buttons. On a narrow list the buttons drop under the text. */
.actions-col { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }
@container (max-width: 1000px) {
    .actions-col { width: auto; text-align: left; }
    .row-actions { flex-wrap: wrap; justify-content: flex-start; }
}

/* While the next page, filter or search loads, the list dims a little. The short delay means a quick load never flickers. */
.list-body { transition: opacity 0.15s ease; }
.list-body.is-loading { opacity: 0.55; transition-delay: 0.15s; }

.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* A field that takes the full width of a two-column form. */
.wide { grid-column: 1 / -1; }

/* The white card that holds one form. */
.add-card { padding: 28px; display: flex; flex-direction: column; gap: 20px; max-width: 880px; }
.add-card h2 { font-size: 20px; }

/* A numbered heading, so a long form reads as steps. */
.step-title { display: flex; align-items: center; gap: 12px; }
.step-num {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--gradient-primary); color: #FFFFFF; font-size: 14px; font-weight: 800;
}

/* A medicine picked from a search, with a button to change it. */
.chosen { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--color-primary-soft); }
.chosen-icon { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: #FFFFFF; color: var(--color-ink); }
.chosen-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.chosen-name { font-weight: 800; overflow-wrap: anywhere; }
.chosen-sub { font-size: 13px; color: var(--color-primary-ink); overflow-wrap: anywhere; }

/* The list of search results under a search box. */
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; background: var(--color-surface); }
.pick-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 12px 16px;
    border: 0; border-bottom: 1px solid var(--color-border-soft); background: var(--color-surface); color: var(--color-text);
    font: inherit; text-align: left; cursor: pointer;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover:not(:disabled) { background: var(--color-surface-alt); }
.pick-row.is-active { background: var(--color-primary-soft); box-shadow: inset 3px 0 0 var(--color-primary); }
.pick-row.is-out { cursor: not-allowed; opacity: 0.7; }
.pick-main { min-width: 0; display: flex; flex-direction: column; }
.pick-name { font-weight: 700; overflow-wrap: anywhere; }
.pick-sub { font-size: 13px; color: var(--color-text-muted); overflow-wrap: anywhere; }
.pick-stock { flex: 0 0 auto; max-width: 48%; display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 13px; font-weight: 700; color: var(--color-text-nav); }

.pack-summary { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: var(--radius-md); background: var(--color-primary-soft); color: var(--color-primary-ink); font-weight: 700; }
.pack-summary svg { flex: 0 0 auto; }

/* Fix stock: one soft strip per batch. On a phone each strip becomes a small card with a caption on every line. */
.fix-wrap { container-type: inline-size; }
.fix-list { display: flex; flex-direction: column; gap: 10px; }
.fix-head { display: none; }
.fix-row {
    display: flex; flex-direction: column; padding: 14px 18px; border-radius: 18px;
    background: var(--color-surface-alt); border: 1px solid var(--color-border-soft);
    transition: background 0.15s ease, border-color 0.15s ease;
}
/* A batch the person has changed turns soft green, so they can see what will be saved. */
.fix-row.is-changed { background: var(--color-primary-soft); border-color: rgba(11, 127, 90, 0.25); }
.fix-batch { padding-bottom: 8px; }
.fix-batch-name { font-size: 15.5px; font-weight: 800; color: var(--color-ink); overflow-wrap: anywhere; }
.fix-cell[data-label] {
    display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 16px; align-items: center;
    padding: 8px 0; border-top: 1px solid var(--color-border-soft); font-size: 14px; text-align: right;
}
.fix-cell[data-label]::before { content: attr(data-label); text-align: left; font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.fix-cell[data-label] > * { grid-column: 2; justify-self: end; }
.fix-cell .cell-sub { margin-top: 0; }
/* The count is typed as boxes, strips and loose pieces. On a phone the caption sits above the boxes, because three boxes do not fit beside it. */
.fix-cell.fix-count[data-label] { display: block; text-align: left; }
.fix-cell.fix-count[data-label]::before { display: block; margin-bottom: 8px; }
.fix-cell.fix-count[data-label] > * { justify-self: start; }
.count-parts { display: flex; flex-wrap: wrap; gap: 8px; }
.count-part { display: flex; flex-direction: column; gap: 4px; width: 76px; text-align: left; }
.count-part span { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.count-part .input { padding: 0 10px; font-weight: 700; -moz-appearance: textfield; appearance: textfield; }
.count-part .input::-webkit-outer-spin-button, .count-part .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fix-count .badge { margin-top: 10px; }

@container (min-width: 640px) {
    .fix-head, .fix-row {
        display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(260px, 1.3fr);
        column-gap: 20px; align-items: center;
    }
    .fix-head {
        padding: 0 20px 10px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-text-muted);
    }
    .fix-row { padding: 14px 20px; }
    .fix-batch { padding-bottom: 0; }
    .fix-cell[data-label] { display: block; padding: 0; border-top: 0; text-align: left; }
    .fix-cell[data-label]::before { display: none; }
    .fix-cell[data-label] > * { justify-self: auto; }
    .fix-cell.fix-count[data-label] { display: flex; flex-direction: column; align-items: flex-start; }
    .fix-cell.fix-count[data-label]::before { display: none; }
}

/* A short list of facts, such as a login name and password. */
.credentials { display: flex; flex-direction: column; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.credential { display: flex; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--color-border-soft); }
.credential:last-child { border-bottom: 0; }
.credential-label { width: 90px; flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--color-text-muted); }
.credential-value { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.credential-value.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 18px; letter-spacing: 0.06em; }

/* A short line of totals above a list, such as "6 sales, sold Rs. 288.60". */
.list-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 6px 26px 14px; font-size: 14px; color: var(--color-text-muted); }
.list-summary b { color: var(--color-ink); }

/* Big numbers side by side, for example what was bought, paid and still owed. */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.figure { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; border-radius: var(--radius-md); background: var(--color-surface-alt); border: 1px solid var(--color-border-soft); }
.figure-label { font-size: 13px; font-weight: 700; color: var(--color-text-muted); }
.figure-value { font-size: 22px; font-weight: 800; color: var(--color-ink); overflow-wrap: anywhere; }
.figure.is-owed .figure-value { color: var(--color-danger-ink); }
.figure.is-clear .figure-value { color: var(--color-success-ink); }

/* The totals of a bill: a row for each amount and a bigger one for the final total. */
.sum-row { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; color: var(--color-text-nav); }
.sum-total {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px;
    border-radius: var(--radius-md); background: var(--color-primary-soft); color: var(--color-ink); font-weight: 800; font-size: 22px;
}
.sum-total span:first-child { font-size: 15px; }

/* The return screens: one card for each line that can come back, and the total under them. */
.ret-lines { display: flex; flex-direction: column; gap: 16px; }
.ret-line { display: flex; flex-direction: column; gap: 16px; padding: 18px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-alt); }
.ret-line.is-done { opacity: 0.6; }
.ret-line .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.ret-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ret-name { min-width: 0; display: flex; flex-direction: column; }
.ret-name .cell-title, .ret-name .cell-sub { overflow-wrap: anywhere; }
.ret-amount { flex: 0 0 auto; font-size: 18px; font-weight: 800; color: var(--color-ink); }
.ret-sum { display: flex; flex-direction: column; gap: 12px; max-width: 460px; }

@media (max-width: 700px) {
    .add-card { padding: 20px; }
    .chosen { flex-wrap: wrap; }
    .chosen .btn { width: 100%; }
    .form-actions .btn { flex: 1 1 100%; }
    .credential { flex-wrap: wrap; gap: 6px 12px; }
    .credential-label { width: 100%; }
    .list-summary { padding: 4px 20px 12px; }
    .ret-line { padding: 14px; }
    .ret-line .form-grid { grid-template-columns: minmax(0, 1fr); }
    .ret-sum { max-width: none; }
}
