/* ===== Theme carried over from Order Tracker v28 ===== */
:root {
    --bg: #0f172a;
    --card: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --accent: #4f46e5;
    --accent-dark: #4338ca;
    --green: #16a34a;
    --red: #dc2626;
    --border: #e2e8f0;
    --page-bg: #f1f5f9;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--page-bg);
    color: var(--ink);
}

header.top {
    background: var(--bg);
    color: #fff;
    padding: 20px 24px;
}
.top-inner {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
}
.top-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}
.top-brand-icon {
    font-size: 26px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    flex-shrink: 0;
}
.top-brand h1 { margin: 0; font-size: 19px; }
.top-brand p { margin: 2px 0 0; color: #94a3b8; font-size: 12px; }

.nav-toggle {
    display: none;
    background: transparent;
    color: #fff;
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 6px;
}
.nav-toggle:hover { background: rgba(255,255,255,0.1); }

.top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    flex-wrap: wrap;
}
.nav-group { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 8px;
}
.top-nav a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 8px;
    transition: background .12s ease, color .12s ease;
    white-space: nowrap;
}
.top-nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.top-nav a.nav-active { color: #fff; background: rgba(79,70,229,0.35); font-weight: 600; }

.nav-account { display: flex; align-items: center; gap: 10px; }
.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}
.top-nav .who { color: #fff; font-weight: 600; white-space: nowrap; }
.nav-admin-tag {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.nav-logout { color: #fca5a5 !important; }
.nav-logout:hover { color: #fecaca !important; background: rgba(220,38,38,0.15) !important; }

@media (max-width: 720px) {
    .nav-toggle { display: block; }
    .top-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        background: #1e293b;
        border-radius: 10px;
        padding: 12px;
        gap: 4px;
        margin-top: 8px;
    }
    .top-nav.open { display: flex; }
    .nav-group { flex-direction: column; align-items: stretch; }
    .nav-divider { width: 100%; height: 1px; margin: 6px 0; }
    .nav-account { flex-wrap: wrap; padding: 6px 12px; }
}

/* Auth pages */
.auth-body {
    background: linear-gradient(135deg, #4f46e5 0%, #0f172a 55%, #1e293b 100%);
    min-height: 100vh;
}
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: rgba(255,255,255,0.98);
    border-radius: 16px;
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(15,23,42,0.35), 0 0 0 1px rgba(255,255,255,0.08);
    animation: auth-rise .35s ease;
}
@keyframes auth-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.auth-logo {
    font-size: 34px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 14px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 20px rgba(79,70,229,0.35);
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; text-align: center; }
.auth-card a { color: var(--accent); font-weight: 600; }
.auth-submit { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

.password-field { position: relative; }
.password-field input { padding-right: 42px; }
.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    padding: 6px 8px;
    font-size: 16px;
    line-height: 1;
}
.password-toggle:hover { background: var(--page-bg); border-radius: 6px; }
.btn-delete-order { background: #dc2626; color: #fff; }
.btn-delete-order:hover { background: #b91c1c; }

/* QR scanner modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 420px;
}
.modal-box h3 { margin: 0 0 8px; }
.batch-edit-box { max-width: 560px; max-height: 90vh; overflow-y: auto; }
.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
    animation: card-rise .4s cubic-bezier(.22,.61,.36,1) backwards;
}
.stat-card .num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    animation: card-rise .45s cubic-bezier(.22,.61,.36,1) backwards;
}
@keyframes card-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.card:nth-of-type(1) { animation-delay: .02s; }
.card:nth-of-type(2) { animation-delay: .06s; }
.card:nth-of-type(3) { animation-delay: .10s; }
.card:nth-of-type(4) { animation-delay: .14s; }
.card:nth-of-type(5) { animation-delay: .18s; }
.card h2 {
    margin: 0 0 4px;
    font-size: 16px;
}
.card .sub {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 16px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .two-col { grid-template-columns: 1fr; }
}

.field-group { margin-bottom: 14px; }
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.button-row { display: flex; align-items: center; gap: 12px; }
.btn-clear {
    background: transparent;
    color: var(--muted);
    text-decoration: underline;
    padding: 6px 2px;
    font-weight: 500;
}
.btn-clear:hover { color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s ease;
}
.btn-return { background: #fee2e2; color: var(--red); }
.btn-return:hover { background: #fecaca; }
.btn-dispatch { background: #dcfce7; color: var(--green); }
.btn-dispatch:hover { background: #bbf7d0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #e2e8f0; color: var(--ink); }
.btn-secondary:hover { background: #cbd5e1; }

.checkbox-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
}
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; }

.msg {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    display: none;
}
.msg.success { background: #dcfce7; color: #166534; display: block; }
.msg.error { background: #fee2e2; color: #991b1b; display: block; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 16px 0;
}
.summary-grid .box {
    background: var(--page-bg);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}
.summary-grid .box .n { font-weight: 700; font-size: 18px; }
.summary-grid .box .l { font-size: 11px; color: var(--muted); }

.serial-col { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th { background: var(--page-bg); font-size: 11px; text-transform: uppercase; color: var(--muted); }
.table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.hidden { display: none !important; }
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Collapsible cards */
.card-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.card-chevron {
    display: inline-block;
    transition: transform .2s ease;
    font-size: 13px;
    color: var(--muted);
}
.card.collapsed .card-chevron { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }
.card-body { margin-top: 12px; }
/* ---- v26: summary, range picker, trend, calendar corners, live counts ---- */
.section-title { font-size: 15px; margin: 4px 0 10px; color: var(--ink); }
.summary-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.sum-tile { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--border); background: #fff; border-left-width: 5px; }
.sum-num { font-size: 32px; font-weight: 800; line-height: 1.1; }
.sum-label { font-weight: 700; font-size: 14px; margin-top: 2px; }
.sum-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.sum-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin-top: 14px; background: #f1f5f9; }
.sum-bar span { display: block; min-width: 2px; }

.live-count { font-size: 13px; margin-top: 4px; color: #475569; transition: transform .15s ease; }
.live-count strong { font-size: 16px; color: #4f46e5; }
.lc-pop { transform: scale(1.04); }
.lc-warn { color: #b45309; } .lc-bad { color: #b91c1c; font-weight: 700; }
@media (max-width: 600px) { .sum-num { font-size: 26px; } .rp-pop { right: auto; left: 0; } }
.lc-ok { color: #15803d; font-weight: 700; }
.btn-tidy { margin-left: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.ms-root { position: relative; display: inline-block; }
.ms-pop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 8px; min-width: 220px; max-height: 280px; overflow: auto; }
.ms-pop label { display: flex; gap: 8px; align-items: center; font-weight: 400; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.ms-pop label:hover { background: #eef2ff; }
.filter-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-row .field-group { margin-bottom: 0; }

/* =====================================================================
   Production Manager additions (same palette, same look)
   ===================================================================== */
.top-inner, .container, .container-wide { max-width: 1240px; }
header.top { padding: 16px 24px 0; position: sticky; top: 0; z-index: 900; box-shadow: 0 2px 10px rgba(15,23,42,.25); }
.nav-account-top { margin-left: auto; }
.nav-account-link { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; }
.nav-account-link:hover, .nav-account-link.nav-active { background: rgba(255,255,255,0.08); }
.nav-account .who { color: #fff; font-weight: 600; white-space: nowrap; font-size: 13px; }
.nav-account .nav-logout { color: #fca5a5; text-decoration: none; font-size: 13px; padding: 6px 10px; border-radius: 8px; }

.top-nav { display: block; margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.top-nav-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.top-nav .nav-group { gap: 4px; }
.top-nav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 13px; }
.nav-ic { font-size: 14px; line-height: 1; }
.top-nav a.nav-active { box-shadow: inset 0 -2px 0 #818cf8; }
.nav-badge { background: #f59e0b; color: #1e293b; font-size: 10px; font-weight: 800; border-radius: 999px; padding: 1px 6px; margin-left: 4px; }
.nav-logout-mobile { display: none !important; }

@media (max-width: 860px) {
    header.top { padding: 14px 16px; position: relative; }
    .nav-toggle { display: block; order: 3; }
    .nav-account-top { order: 2; }
    .nav-account-top .who, .nav-account-top .nav-logout { display: none; }
    .top-nav { display: none; border-top: none; margin-top: 10px; background: #1e293b; border-radius: 10px; padding: 8px; }
    .top-nav.open { display: block; }
    .top-nav-inner { flex-direction: column; align-items: stretch; }
    .top-nav .nav-group { flex-direction: column; align-items: stretch; width: 100%; }
    .top-nav a { padding: 10px 12px; }
    .nav-group-right { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 6px; }
    .nav-logout-mobile { display: inline-flex !important; }
    .top-brand p { display: none; }
    .top-inner { flex-wrap: nowrap; }
    .top-brand { flex: 1; min-width: 0; }
    .top-brand-link, .top-brand-link > span:last-child { min-width: 0; }
    .top-brand h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nav-account-top { margin-left: 0; }
}

/* Forms: selects, numbers, compact inputs */
select, input[type="number"], input[type="search"], input[type="tel"] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: #fff; color: var(--ink); font-family: inherit;
}
select:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
textarea.plain { font-family: inherit; min-height: 70px; }
.input-sm, select.input-sm { padding: 6px 8px; font-size: 13px; }
.req { color: var(--red); margin-left: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.form-grid .span-all { grid-column: 1 / -1; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit span { display: flex; align-items: center; padding: 0 10px; background: var(--page-bg); border: 1px solid var(--border); border-left: none; border-radius: 0 8px 8px 0; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Page header with action buttons */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: #eef2ff; }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-warn { background: #fef3c7; color: #92400e; }
.btn-warn:hover { background: #fde68a; }
a.btn-primary, a.btn-secondary, a.btn-ghost, a.btn-danger { display: inline-block; text-decoration: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; }
a.btn-sm { padding: 6px 12px; font-size: 13px; }
a.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.icon-btn { background: transparent; padding: 4px 7px; font-size: 15px; border-radius: 6px; line-height: 1; }
.icon-btn:hover { background: var(--page-bg); }

/* Quick action tiles on the dashboard */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.qa { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); transition: transform .1s ease, box-shadow .15s ease, border-color .15s; }
.qa:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15,23,42,.08); border-color: #c7d2fe; }
.qa-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: linear-gradient(135deg, #eef2ff, #f5f3ff); flex-shrink: 0; }
.qa strong { display: block; font-size: 14px; }
.qa small { color: var(--muted); font-size: 12px; }

/* Summary tiles (dashboard) */
.sum-a { border-left-color: #4f46e5; } .sum-a .sum-num { color: #4f46e5; }
.sum-b { border-left-color: #16a34a; } .sum-b .sum-num { color: #16a34a; }
.sum-c { border-left-color: #dc2626; } .sum-c .sum-num { color: #dc2626; }
.sum-d { border-left-color: #d97706; } .sum-d .sum-num { color: #d97706; }
.sum-e { border-left-color: #0891b2; } .sum-e .sum-num { color: #0891b2; }
.sum-f { border-left-color: #7c3aed; } .sum-f .sum-num { color: #7c3aed; }
a.sum-tile { text-decoration: none; color: inherit; transition: box-shadow .15s ease, transform .1s ease; }
a.sum-tile:hover { box-shadow: 0 4px 14px rgba(15,23,42,.08); transform: translateY(-1px); }

/* Badges */
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0e7ff; color: #3730a3; }
.badge.muted { background: #f1f5f9; color: #64748b; }

/* Toolbar (search / filter / sort) */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--page-bg); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.toolbar .field-group { margin-bottom: 0; min-width: 150px; flex: 1; }
.toolbar .field-group.grow { flex: 3; min-width: 220px; }
.toolbar .field-group.narrow { flex: 0 0 auto; min-width: 0; }
.toolbar label { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 4px; }
.search-input { position: relative; }
.search-input input { padding-left: 34px; }
.search-input::before { content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }
.field-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; width: 100%; }
.field-filters .field-group { margin: 0; }
.range-pair { display: flex; gap: 6px; }
.range-pair input { min-width: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; font-weight: 600; }
.chip button { background: rgba(55,48,163,.12); color: #3730a3; border-radius: 999px; padding: 0 6px; font-size: 12px; line-height: 18px; }
.result-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 6px 0; }

/* Tables */
.table-wrap.tall { max-height: none; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: " ↕"; opacity: .35; font-size: 10px; }
th.sort-asc::after { content: " ▲"; opacity: .9; }
th.sort-desc::after { content: " ▼"; opacity: .9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row-inactive td { color: #94a3b8; }
tr.row-low td { background: #fff7ed; }
tbody tr:hover td { background: #f8fafc; }
tfoot td { font-weight: 700; background: var(--page-bg); border-top: 2px solid var(--border); }
td.wrap { white-space: normal; min-width: 180px; }
.kv-list { display: flex; flex-wrap: wrap; gap: 4px 6px; white-space: normal; }
.kv { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; font-size: 12px; }
.kv b { background: var(--page-bg); color: var(--muted); font-weight: 600; padding: 1px 6px; }
.kv span { padding: 1px 6px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 13px; }
.stock-cell { display: inline-flex; align-items: center; gap: 4px; }
.stock-cell strong { min-width: 40px; text-align: right; }
.empty-row td { text-align: center; color: var(--muted); padding: 30px 10px; white-space: normal; }

/* Template builder */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tpl-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s ease, border-color .15s; }
.tpl-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.07); border-color: #c7d2fe; }
.tpl-card-head { display: flex; gap: 10px; align-items: center; }
.tpl-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: linear-gradient(135deg, #eef2ff, #f5f3ff); flex-shrink: 0; }
.tpl-card h3 { margin: 0; font-size: 15px; }
.tpl-card .meta { font-size: 12px; color: var(--muted); }
.tpl-card .actions { margin-top: auto; }
.field-rows { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.field-row { display: grid; grid-template-columns: 28px 1.6fr 1fr 0.8fr auto auto auto; gap: 8px; align-items: center; background: var(--page-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.field-row.dragging { opacity: .5; }
.field-row .drag { cursor: grab; color: var(--muted); text-align: center; font-size: 16px; }
.field-row input, .field-row select { padding: 7px 9px; font-size: 13px; }
.field-row .opts { grid-column: 2 / -1; }
.field-row label.inline { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; margin: 0; white-space: nowrap; }
.field-row .fixed { font-size: 13px; font-weight: 600; padding: 7px 2px; }
.attr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.attr-chips button { background: #fff; border: 1px dashed #c7d2fe; color: var(--accent); padding: 4px 10px; font-size: 12px; border-radius: 999px; font-weight: 600; }
.attr-chips button:hover { background: #eef2ff; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-pick button { background: var(--page-bg); padding: 4px 7px; font-size: 18px; border-radius: 8px; border: 2px solid transparent; }
.emoji-pick button.sel { border-color: var(--accent); background: #eef2ff; }
.preview-box { border: 1px dashed var(--border); border-radius: 10px; padding: 14px; background: #fcfcfd; }
@media (max-width: 760px) {
    .field-row { grid-template-columns: 24px 1fr 1fr; }
    .field-row .opts { grid-column: 1 / -1; }
}

/* Modal (bigger variant) */
.modal-box.lg { max-width: 760px; max-height: 92vh; overflow-y: auto; }
.modal-box.md { max-width: 560px; max-height: 92vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h3 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: auth-rise .25s ease; max-width: 340px; }
.toast.err { background: #991b1b; }

/* Empty states */
.empty-state { text-align: center; padding: 36px 20px; }
.empty-icon { font-size: 38px; margin-bottom: 6px; }

/* Work log entry rows */
.entry-rows { display: flex; flex-direction: column; gap: 8px; }
.entry-row { display: grid; grid-template-columns: 2fr 110px 110px 120px 36px; gap: 8px; align-items: center; }
.entry-row .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-row .rate { font-size: 12px; color: var(--muted); text-align: right; }
.entry-head { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.entry-total { display: flex; justify-content: flex-end; gap: 24px; font-size: 14px; padding: 10px 44px 0 0; }
@media (max-width: 640px) {
    .entry-row { grid-template-columns: 1fr 80px 36px; }
    .entry-row .rate, .entry-row .amt { display: none; }
    .entry-head { display: none; }
}

/* Week navigator */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { font-weight: 700; font-size: 15px; min-width: 210px; text-align: center; }
.money { font-variant-numeric: tabular-nums; }
.neg { color: var(--red); }
.pos { color: var(--green); }
details.breakdown summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 600; }
details.breakdown table { margin: 6px 0 0; font-size: 12px; }
.mini-bars { display: flex; flex-direction: column; gap: 8px; }
.mini-bar { display: grid; grid-template-columns: 140px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.mini-bar .track { background: #f1f5f9; border-radius: 6px; height: 12px; overflow: hidden; }
.mini-bar .fill { background: linear-gradient(90deg, #4f46e5, #7c3aed); height: 100%; border-radius: 6px; transition: width .6s cubic-bezier(.22,.61,.36,1); }
.mini-bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Profile permission list */
.perm-help { display: block; font-weight: 400; color: var(--muted); font-size: 12px; white-space: normal; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: transparent; border-radius: 8px 8px 0 0; color: var(--muted); padding: 10px 16px; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Print (pay slips) */
.print-only { display: none; }
@media print {
    header.top, .no-print, .toast-wrap { display: none !important; }
    body { background: #fff; }
    .container { padding: 0; max-width: none; }
    .card { border: 1px solid #cbd5e1; animation: none; break-inside: avoid; }
    .print-only { display: block; }
    .slip { page-break-after: always; }
    .slip:last-child { page-break-after: auto; }
    .table-wrap { max-height: none; overflow: visible; }
}
.slip-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 10px; }
.slip-head h2 { font-size: 18px; margin: 0; }
.slip-total { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; max-width: 340px; margin: 14px 0 0 auto; font-size: 14px; }
.slip-total .grand { font-size: 18px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 6px; }
.sign-line { margin-top: 40px; display: flex; justify-content: space-between; gap: 30px; font-size: 12px; color: var(--muted); }
.sign-line div { flex: 1; border-top: 1px solid #94a3b8; padding-top: 4px; }
