/* Simba Group Asset Management - interface stylesheet (light only) */
:root, [data-theme] {
    --bg:          #f5f6f8;
    --bg-2:        #ffffff;
    --bg-3:        #f0f2f5;
    --border:      #e2e5ea;
    --border-2:    #cfd4db;
    --text:        #1a1f27;
    --text-dim:    #5d6775;
    --sidebar-bg:  #5e0f1b;
    --thead-bg:    #f7f8fa;
    --input-bg:    #ffffff;
    --row-hover:   #f7f8fa;
    --shadow:      none;
    --accent:      #9b1c25;
    --accent-2:    #7d141c;
    --blue:        #9b1c25;
    --blue-2:      #9b1c25;
    --blue-soft:   #f6e9ea;
    --red:         #b42318;
    --red-2:       #b42318;
    --red-soft:    #fdecea;
    --green:       #1f7a4d;
    --amber:       #a8620a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }

/* ---- Layout ---- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar-bg); border-right: 0; padding: 0 0 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.menu-toggle { display: none; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
               width: 36px; height: 36px; border-radius: 6px; cursor: pointer; align-items: center; justify-content: center; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,20,28,.45); z-index: 150; opacity: 0; pointer-events: none; }

.sidebar .brand { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255,255,255,.14); }
.sidebar .brand-logo { display: block; background: none; padding: 0; border-radius: 0; box-shadow: none; }
.sidebar .brand-logo img { display: block; height: 52px; width: auto; max-width: 100%; filter: brightness(0) invert(1); }
.sidebar .brand-sub { display: none; }
.sidebar nav { padding: 10px 12px; }
.sidebar nav a { display: block; padding: 8px 12px; margin: 1px 0; color: #ecd2d6; border-radius: 6px; font-weight: 500; border-left: 0; }
.sidebar nav a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; box-shadow: none; }
.sidebar .nav-group { padding: 18px 12px 6px; color: #d99aa2; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }

.main { padding: 0 32px 60px; max-width: 1440px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin: 0 -32px 26px; padding: 12px 32px; gap: 16px; background: var(--bg-2); border-bottom: 1px solid var(--border); min-height: 60px; }
.topbar .who { color: var(--text-dim); font-size: .86rem; }
.topbar .who b { color: var(--text); font-weight: 600; }

@media (max-width: 880px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; top: 0; left: 0; width: 80%; max-width: 280px; height: 100vh; z-index: 200; transform: translateX(-100%); box-shadow: 8px 0 24px rgba(15,20,28,.35); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { display: block; }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
    .menu-toggle { display: inline-flex; }
    .main { padding: 0 14px 60px; }
    .topbar { margin: 0 -14px 18px; padding: 10px 14px; flex-wrap: wrap; }
    .topbar form input[type=search] { width: 140px !important; }
    .page-actions { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-actions h1 { font-size: 1.25rem; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr !important; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar select, .filter-bar input { max-width: none; }
    .table th, .table td { padding: 8px 8px; }
}

/* ---- Cards ---- */
.card { background: var(--bg-2); border: 0; border-radius: 8px; padding: 20px 22px; margin-bottom: 20px; box-shadow: none; }
.card h2, .card h3 { margin: 0 0 14px; font-size: 1rem; font-weight: 600; color: var(--text); border: 0; padding: 0; }
.card h2 { font-size: 1.05rem; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; } .grid-2 { grid-template-columns: 1fr; } }

.stat { background: var(--bg-2); border: 0; border-radius: 8px; padding: 16px 18px; }
.stat .label { color: var(--text-dim); font-size: .76rem; font-weight: 500; text-transform: none; letter-spacing: 0; }
.stat .value { font-size: 1.65rem; font-weight: 600; margin-top: 4px; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.red .value { color: var(--red); }
a.stat { display: block; text-decoration: none; color: inherit; }
a.stat:hover { text-decoration: none; background: var(--row-hover); }

/* ---- Forms ---- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--text); font-size: .82rem; font-weight: 500; }
.form-row .req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=tel], input[type=url], select, textarea {
    width: 100%; padding: 8px 12px; min-height: 36px; background: var(--input-bg); color: var(--text);
    border: 1px solid var(--border-2); border-radius: 6px; font-size: .9rem; font-family: inherit; box-shadow: none;
}
input::placeholder, textarea::placeholder { color: #9aa2ae; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); box-shadow: none; }
textarea { min-height: 84px; resize: vertical; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0 14px; min-height: 36px; border-radius: 6px; border: 1px solid var(--accent);
    background: var(--accent); color: #fff; cursor: pointer; font-size: .86rem; font-weight: 500; font-family: inherit; text-decoration: none; box-shadow: none; }
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--bg-3); border-color: var(--border-2); color: var(--text); }
.btn-danger { background: #fff; color: var(--red); border-color: #f0c4c0; }
.btn-danger:hover { background: var(--red-soft); border-color: #f0c4c0; color: var(--red); }
.btn-small { padding: 0 10px; min-height: 30px; font-size: .8rem; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-2); border: 0; border-radius: 8px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .86rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th { background: var(--thead-bg); color: var(--text-dim); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr:hover td { background: var(--row-hover); }
.table .actions a { margin-right: 10px; }
.table .empty { text-align: center; padding: 32px; color: var(--text-dim); }
.card .table { border: 0; border-radius: 0; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: .72rem; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.badge-in-stock, .badge-new               { background: #e7f4ec; color: #1f7a4d; }
.badge-signed-by-manager                  { background: #e8eef9; color: #274c9a; }
.badge-assigned-to-staff, .badge-refurbished, .badge-warning { background: #fbf0dd; color: #8a5208; }
.badge-returned, .badge-old               { background: #eceef1; color: #4b5563; }
.badge-written-off, .badge-disposed, .badge-danger { background: var(--red-soft); color: #a3231a; }

/* ---- Auth pages (forgot / reset / 2FA) ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: radial-gradient(circle at 15% 10%, #c1272d 0%, #8b1220 38%, #4a0610 100%) fixed; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 40px 36px 30px; box-shadow: 0 30px 80px rgba(20,0,4,.5); text-align: center; }
.login-card .logo-card { display: block; margin: 0 auto 22px; background: none; padding: 0; box-shadow: none; border-radius: 0; }
.login-card .logo-card img { display: block; margin: 0 auto; height: auto; width: 200px; max-width: 100%; }
.login-card .logo-sub { display: none; }
.login-card h1 { margin: 0 0 6px; font-size: 1.25rem; font-weight: 600; }
.login-card .sub { color: var(--text-dim); font-size: .86rem; margin-bottom: 24px; }
.login-card form { text-align: left; }
.login-card .field { position: relative; margin-bottom: 16px; }
.login-card .field label { display: block; font-size: .8rem; font-weight: 500; color: var(--text); margin-bottom: 6px; text-transform: none; letter-spacing: 0; }
.login-card .field .input-wrap { position: relative; }
.login-card .field .input-wrap .ico { display: none; }
.login-card .field input { width: 100%; height: 42px; padding: 0 14px; background: #fff; border: 1px solid var(--border-2); border-radius: 8px; color: var(--text); font-size: .9rem; box-shadow: none; transition: none; }
.login-card .field input:focus { outline: none; border-color: var(--text); box-shadow: none; }
.login-card .row { display: flex; align-items: center; margin: 4px 0 20px; font-size: .82rem; color: var(--text-dim); }
.login-card .row label { cursor: pointer; }
.login-card .btn-primary { width: 100%; height: 42px; border: 0; border-radius: 8px; background: #18181b; color: #fff; font-weight: 500; font-size: .9rem; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: none; }
.login-card .btn-primary:hover { background: #18181b; filter: none; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.login-card .divider { display: none; }
.login-card .help { color: var(--text-dim); font-size: .82rem; text-align: center; line-height: 1.6; }
.login-card .help code { background: var(--bg-3); padding: 2px 6px; border-radius: 4px; color: var(--text); }
.login-card .error { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; padding: 10px 12px; border-radius: 8px; font-size: .84rem; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start; text-align: left; }
.login-card .error svg { flex: 0 0 16px; margin-top: 2px; }
.login-card .footer-note { margin-top: 24px; text-align: center; color: var(--text-dim); font-size: .78rem; }
.login-card .footer-note a { color: var(--text-dim); text-decoration: underline; }

/* ---- Flash ---- */
.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; font-size: .86rem; border: 1px solid; }
.flash-success { background: #effaf4; color: #1f6b44; border-color: #c4e6d3; }
.flash-error   { background: #fef3f2; color: #a3231a; border-color: #fecdca; }
.flash-info    { background: #f1f5fb; color: #274c9a; border-color: #cfdcf2; }

/* ---- Misc ---- */
.muted { color: var(--text-dim); }
.right { text-align: right; }
.page-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-actions h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { max-width: 220px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.error-text { color: var(--red); font-size: .82rem; margin-top: 4px; }
code { background: var(--bg-3); color: var(--text); padding: 1px 6px; border-radius: 4px; font-size: .85em; }

/* topbar icon button (notifications) */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 6px; cursor: pointer; background: #fff; border: 1px solid var(--border-2); color: var(--text-dim); }
.theme-toggle:hover { color: var(--text); background: var(--bg-3); text-decoration: none; }
.topbar input[type=search] { background: var(--bg-3); border-color: transparent; }
.topbar input[type=search]:focus { background: #fff; border-color: var(--text); }

/* ---- Accessibility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- Empty state ---- */
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-dim); }
.empty-state h3 { margin: 0 0 6px; color: var(--text); }
.empty-state p { margin: 0 0 14px; font-size: .9rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.table-scroll .table { min-width: 720px; }

/* ---- Timeline ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 8px 0 8px 22px; border-left: 2px solid var(--border); margin-left: 4px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); border: 2px solid var(--bg-2); }
.timeline .when { color: var(--text-dim); font-size: .8rem; }
.timeline .what { font-weight: 600; }

/* inline icons */
.btn .i, a .i, button .i { margin-right: 6px; }
.sidebar nav a .i { margin-right: 0; }

/* ---- Print ---- */
@media print {
    .sidebar, .sidebar-backdrop, .topbar, .page-actions, .filter-bar, .btn, .menu-toggle, .theme-toggle, form, .actions { display: none !important; }
    .app { display: block; }
    .main { margin: 0; padding: 0; max-width: none; }
    .card, .stat { border: 0; page-break-inside: avoid; margin-bottom: 12px; background: #fff !important; color: #000 !important; }
    .table { font-size: 10pt; }
    a { color: #000; text-decoration: none; }
    .badge { border: 1px solid #999; color: #000 !important; background: transparent !important; }
}

/* tiles: no borders */
.card, .stat, .table, a.stat, a.stat:hover { border: 0 !important; outline: 0; }

/* select: custom chevron with breathing room from the right edge */
select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6775' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    cursor: pointer;
}
select[multiple] { background-image: none; padding-right: 12px; }

/* photo picker */
.photo-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.photo-actions { display: flex; gap: 8px; }
.form-row .pick-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin: 0; min-height: 36px; padding: 0 12px;
    background: #fff; border: 1px solid var(--border-2); border-radius: 6px; color: var(--text); font-size: .82rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.form-row .pick-btn:hover { background: var(--bg-3); }
.pick-btn .i { margin: 0; }
.photo-state { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.photo-state img { height: 40px; width: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.photo-meta { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: .8rem; }
.photo-meta #photo_name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .8rem; cursor: pointer; text-decoration: underline; }

/* ---- searchable select ---- */
.ss { position: relative; width: 100%; }
.filter-bar .ss { max-width: 220px; }
.ss-native { position: absolute !important; left: 0; bottom: 0; width: 100% !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; opacity: 0; pointer-events: none; border: 0 !important; }
.ss-btn { width: 100%; min-height: 36px; padding: 8px 38px 8px 12px; text-align: left; font: inherit; font-size: .9rem; color: var(--text);
    background-color: var(--input-bg); border: 1px solid var(--border-2); border-radius: 6px; cursor: pointer; display: block;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6775' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; background-size: 12px; box-shadow: none; }
.ss-btn:focus, .ss.ss-open .ss-btn { outline: none; border-color: var(--text); }
.ss-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-placeholder { color: #9aa2ae; }
.ss-disabled .ss-btn { background-color: var(--bg-3); color: var(--text-dim); cursor: not-allowed; }
.ss-panel { position: absolute; z-index: 300; left: 0; right: 0; top: calc(100% + 4px); min-width: 200px; background: #fff; border: 1px solid var(--border-2); border-radius: 8px; box-shadow: 0 10px 30px rgba(15,20,28,.14); padding: 6px; }
.ss-up .ss-panel { top: auto; bottom: calc(100% + 4px); }
.ss-search { width: 100%; margin: 0 0 6px; min-height: 34px !important; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.ss-list li { padding: 8px 10px; border-radius: 5px; font-size: .88rem; cursor: pointer; color: var(--text); }
.ss-list li.ss-act { background: var(--bg-3); }
.ss-list li.ss-sel { font-weight: 600; color: var(--accent); }
.ss-list li.ss-special { color: var(--text-dim); }
.ss-list li.ss-off { color: #b3b9c2; cursor: not-allowed; }
.ss-list li.ss-empty { color: var(--text-dim); cursor: default; }
.ss-list li[hidden] { display: none; }

/* impersonation banner */
.imp-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 -32px 0; padding: 10px 32px; background: #fff4d6; color: #6b4a00; font-size: .84rem; border-bottom: 1px solid #f0dca0; }
.imp-bar .btn { background: #6b4a00; border-color: #6b4a00; }
@media (max-width: 880px) { .imp-bar { margin: 0 -14px; padding: 10px 14px; } }

/* sticky table headers */
.table th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
.table thead th:first-child { border-top-left-radius: 8px; }
.table thead th:last-child  { border-top-right-radius: 8px; }
.table-scroll.tall { max-height: calc(100vh - 150px); overflow: auto; }
.table-scroll.tall .table { min-width: 960px; }
.badge-good { background: #e7f4ec; color: #1f7a4d; }
.badge-fair { background: #fbf0dd; color: #8a5208; }
.badge-poor, .badge-damaged, .badge-lost { background: var(--red-soft); color: #a3231a; }
.badge-obsolete { background: #eceef1; color: #4b5563; }

/* ---- assets list on phones: cards, no filters ---- */
.asset-cards { display: none; }
@media (max-width: 880px) {
    .desk-only { display: none !important; }
    .filter-bar { display: none !important; }
    .table-scroll.tall { display: none; }
    .card:has(> .asset-cards) { background: transparent; padding: 0; margin-bottom: 0; }
    .asset-cards { display: flex; flex-direction: column; gap: 10px; }
    .acard { display: block; background: #fff; border-radius: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; }
    .acard:hover { text-decoration: none; background: #fff; color: var(--text); }
    .acard:active { background: var(--row-hover); }
    .acard-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
    .acard-tag { font-weight: 700; font-size: .82rem; letter-spacing: .03em; color: var(--accent); white-space: nowrap; }
    .acard-name { margin: 6px 0 10px; font-size: 1rem; font-weight: 600; line-height: 1.3; }
    .acard-meta { margin: 0; display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
    .acard-meta > div { display: flex; justify-content: space-between; gap: 14px; font-size: .84rem; }
    .acard-meta dt { color: var(--text-dim); flex: none; }
    .acard-meta dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
    .page-actions { flex-direction: row !important; align-items: center !important; }
    .page-actions .btn { min-height: 40px; }
}

/* ---- bottom menu (phones) ---- */
.tabbar { display: none; }
@media (max-width: 880px) {
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 120; background: #fff; border-top: 1px solid var(--border);
              padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
    .tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 52px; background: none; border: 0;
                   font: inherit; font-size: .68rem; font-weight: 500; color: var(--text-dim); text-decoration: none; cursor: pointer; border-radius: 8px; }
    .tabbar .tab .i { margin: 0; vertical-align: 0; }
    .tabbar .tab:hover { text-decoration: none; color: var(--text); }
    .tabbar .tab.on { color: var(--accent); font-weight: 600; }
    .tabbar .tab-scan { color: #fff; }
    .tabbar .tab-scan .i { background: var(--accent); color: #fff; width: 44px; height: 44px; padding: 11px; border-radius: 14px; margin-top: -20px; box-shadow: 0 4px 12px rgba(155,28,37,.35); }
    .tabbar .tab-scan span { color: var(--text-dim); }
    .tabbar .tab-scan.on span { color: var(--accent); font-weight: 600; }
    .main { padding-bottom: 96px; }
}

/* mobile asset search */
.m-search { display: none; }
@media (max-width: 880px) {
    .m-search { display: flex; position: relative; margin: 0 0 14px; }
    .m-search input { width: 100%; min-height: 46px; padding: 0 48px 0 14px; border-radius: 12px; border: 1px solid var(--border-2); background: #fff; font-size: 1rem; }
    .m-search button { position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
    .m-search button .i { margin: 0; vertical-align: 0; }
    .topbar { min-height: 56px; }
}

@media (max-width: 880px) {
    .topbar { flex-wrap: nowrap !important; }
    .topbar-date { display: none; }
    .topbar .who { flex: 1; text-align: right; font-size: .8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- phone app chrome: floating circle buttons, no top bar ---- */
.fab { display: none; }
.m-home { display: none; }
@media (max-width: 880px) {
    .topbar { display: none !important; }
    .main { padding-top: 72px; }
    .fab { display: flex; position: fixed; top: calc(12px + env(safe-area-inset-top)); width: 46px; height: 46px; border-radius: 50%; background: #fff; color: var(--text);
           align-items: center; justify-content: center; border: 0; padding: 0; z-index: 130; box-shadow: 0 2px 12px rgba(15,20,28,.2); cursor: pointer; text-decoration: none; }
    .fab:hover { text-decoration: none; color: var(--text); }
    .fab .i { margin: 0; vertical-align: 0; }
    .fab-menu { left: 14px; }
    .fab-bell { right: 14px; }
    .fab-dot { position: absolute; top: -3px; right: -3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: .65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
    .imp-bar { margin: -72px -14px 12px; padding-top: 14px; }

    .d-home { display: none; }
    .m-home { display: block; }
    .m-home a { text-decoration: none; color: inherit; }
    .mh-hello { display: flex; justify-content: space-between; align-items: flex-end; margin: 4px 2px 16px; }
    .mh-hello small { color: var(--text-dim); font-size: .85rem; }
    .mh-hello h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
    .mh-date { color: var(--text-dim); font-size: .82rem; padding-bottom: 4px; }
    .mh-hero { margin-bottom: 14px; display: block; background: var(--accent); color: #fff !important; border-radius: 18px; padding: 18px 20px; }
    .mh-hero span { display: block; font-size: .82rem; opacity: .85; }
    .mh-hero b { display: block; font-size: 2.3rem; line-height: 1.15; letter-spacing: -.02em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
    .mh-hero em { font-style: normal; font-size: .82rem; opacity: .85; }
    .mh-actions { display: flex; justify-content: space-between; gap: 8px; margin: 18px 4px; }
    .mh-actions a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .74rem; font-weight: 500; color: var(--text); }
    .mh-actions i { width: 54px; height: 54px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--accent); box-shadow: 0 1px 4px rgba(15,20,28,.08); }
    .mh-actions .i { margin: 0; vertical-align: 0; }
    .mh-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .mh-tiles a { background: #fff; border-radius: 14px; padding: 12px 14px; }
    .mh-tiles b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
    .mh-tiles span { font-size: .78rem; color: var(--text-dim); }
    .mh-tiles .warn b { color: var(--red); }
    .mh-card { background: #fff; border-radius: 16px; padding: 14px 16px; margin-top: 12px; }
    .mh-card h3 { margin: 0 0 10px; font-size: .95rem; }
    .mh-head { display: flex; justify-content: space-between; align-items: baseline; }
    .mh-head a { font-size: .82rem; color: var(--accent) !important; }
    .mh-pie { display: flex; align-items: center; gap: 16px; }
    .mh-pie svg { width: 112px; height: 112px; flex: none; }
    .mh-pie ul { list-style: none; margin: 0; padding: 0; flex: 1; font-size: .82rem; }
    .mh-pie li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
    .mh-pie li i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
    .mh-pie li b { margin-left: auto; font-variant-numeric: tabular-nums; }
    .mh-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-top: 1px solid var(--border); font-size: .9rem; }
    .mh-row:first-of-type { border-top: 0; }
    .mh-row b { min-width: 28px; text-align: center; background: var(--bg-3); border-radius: 8px; padding: 2px 8px; font-size: .82rem; }
    .mh-row b.red { background: var(--red-soft); color: var(--red); }
    .mh-asset { display: flex; flex-direction: column; padding: 10px 0; border-top: 1px solid var(--border); }
    .mh-head + .mh-asset { border-top: 0; }
    .mh-asset .n { font-size: .92rem; font-weight: 600; }
    .mh-asset .t { font-size: .76rem; color: var(--accent); letter-spacing: .03em; margin-top: 1px; }
}

/* ---- reports ---- */
.rep-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.rep-card { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 12px; padding: 16px 18px; color: var(--text); text-decoration: none; }
.rep-card:hover { text-decoration: none; background: var(--row-hover); color: var(--text); }
.rep-ic { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--blue-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.rep-ic .i, .rep-go .i { margin: 0; vertical-align: 0; }
.rep-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rep-tx b { font-size: .95rem; }
.rep-tx small { color: var(--text-dim); font-size: .8rem; line-height: 1.35; }
.rep-go { color: var(--text-dim); flex: none; }
.rep-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: .85rem; margin-bottom: 6px; }
.rep-back .i { margin: 0; vertical-align: 0; }
.rep-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.rep-title h1 { margin: 0; font-size: 1.4rem; }
.rep-actions { display: flex; gap: 8px; }
.rep-desc { margin: 6px 0 16px; }
.rep-filters { background: #fff; border-radius: 12px; margin-bottom: 14px; }
.rep-filters summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.rep-filters summary::-webkit-details-marker { display: none; }
.rep-filters summary .i { margin: 0; vertical-align: 0; color: var(--text-dim); }
.rep-count { background: var(--accent); color: #fff; border-radius: 10px; font-size: .7rem; padding: 1px 7px; }
.rep-form { padding: 4px 16px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.rep-form .form-row { margin: 0; }
.rep-form-actions { display: flex; gap: 8px; align-items: flex-end; }
.rep-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.rep-tile { background: #fff; border-radius: 12px; padding: 14px 16px; }
.rep-tile span { display: block; font-size: .76rem; color: var(--text-dim); }
.rep-tile b { display: block; font-size: 1.35rem; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.rep-note { text-align: center; margin: 12px 0 0; font-size: .82rem; }
.table th.right, .table td.right { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 880px) {
    .rep-hub { grid-template-columns: 1fr; }
    .rep-title { align-items: flex-start; }
    .rep-actions { width: 100%; }
    .rep-actions .btn { flex: 1; min-height: 44px; }
    .rep-tiles { grid-template-columns: 1fr 1fr; }
    .rep-card-table { background: transparent; padding: 0; margin-bottom: 0; }
    .rep-form { grid-template-columns: 1fr; }
}

.rep-title { margin-bottom: 16px; }

/* sticker toolbar on the assets list */
.stk-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: .85rem; }
.stk-bar .sp { flex: 1; }
.table input[type=checkbox] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }

.rep-scope { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 16px; max-width: 640px; }
.rep-scope .form-row { margin: 0; }

/* no zoom when the keyboard opens on phones: form controls must be at least 16px */
@media (max-width: 880px) {
    input, select, textarea, .ss-btn, .ss-search, .login-card .field input { font-size: 16px !important; }
    input, select, textarea { touch-action: manipulation; }
}

/* sign-in style pages (forgot / reset / 2FA) as a bottom sheet on phones */
@media (max-width: 600px) {
    .login-page { align-items: flex-end; padding: 0; }
    .login-card { max-width: none; width: 100%; border-radius: 28px 28px 0 0; padding: 34px 24px calc(30px + env(safe-area-inset-bottom)); box-shadow: none; min-height: 62vh; }
    .login-card .field input { height: 54px; border-radius: 14px; padding: 0 16px; }
    .login-card .btn-primary { height: 56px; border-radius: 14px; font-size: 1.05rem; font-weight: 600; }
    .login-card .logo-card img { width: 170px; }
}

/* ---- date fields on phones: same height and look as other fields, calendar icon, whole field opens the picker ---- */
@media (max-width: 880px) {
    input[type=date] {
        -webkit-appearance: none; appearance: none;
        display: block; width: 100%; min-height: 50px; height: 50px; padding: 0 46px 0 16px; line-height: 50px;
        border-radius: 12px; text-align: left; position: relative; overflow: hidden; color: var(--text); background-color: #fff;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235d6775' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='16.5' rx='2.5'/%3E%3Cline x1='3' y1='9.5' x2='21' y2='9.5'/%3E%3Cline x1='8' y1='2.5' x2='8' y2='6.5'/%3E%3Cline x1='16' y1='2.5' x2='16' y2='6.5'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-position: right 15px center; background-size: 20px;
    }
    input[type=date]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
    input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.4em; }
    input[type=date]::-webkit-datetime-edit { padding: 0; }
    input[type=date]::-webkit-inner-spin-button, input[type=date]::-webkit-clear-button { display: none; }
    /* empty field: show a hint like the other fields instead of a blank box or mm/dd/yyyy */
    input[type=date].is-empty { color: transparent; }
    input[type=date].is-empty::-webkit-datetime-edit { color: transparent; }
    input[type=date].is-empty::before { content: attr(data-hint); position: absolute; left: 16px; top: 0; color: #9aa2ae; line-height: 50px; pointer-events: none; }
    input[type=date]:focus { border-color: var(--text); }
}

/* phone forms: one consistent field height and corner radius */
@media (max-width: 880px) {
    input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=url], input[type=date], select, .ss-btn {
        min-height: 50px; border-radius: 12px;
    }
    .ss-btn { display: flex; align-items: center; padding-top: 0; padding-bottom: 0; }
    textarea { border-radius: 12px; padding: 12px 14px; }
}

/* aligned action buttons inside table rows */
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.row-actions form { margin: 0; display: flex; }
.row-actions .btn { min-height: 32px; white-space: nowrap; }
.row-actions .btn .i { margin-right: 6px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: .85rem; }
.stock-forms .card { margin-bottom: 0; }
.stock-forms .btn { width: 100%; margin-top: 4px; }
a.rep-tile { color: inherit; text-decoration: none; display: block; }
a.rep-tile:hover { background: var(--row-hover); text-decoration: none; }

/* categories editor */
.cat-row { padding: 14px 0; border-top: 1px solid var(--border); }
.cat-row:first-child { border-top: 0; }
.cat-main { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.cat-main input[type=text]:first-child { flex: 1; min-width: 0; }
.cat-main input[name=code] { width: 90px; flex: none; }
.cat-count { white-space: nowrap; font-size: .82rem; }
.cat-opts { display: grid; grid-template-columns: 1.3fr 1.5fr .8fr .8fr .8fr auto; gap: 10px; align-items: end; }
.cat-opts label { display: block; font-size: .72rem; color: var(--text-dim); font-weight: 500; }
.cat-opts label input, .cat-opts label select { margin-top: 4px; font-size: .86rem; }
.cat-btns { display: flex; gap: 8px; align-items: center; }
@media (max-width: 880px) { .cat-opts { grid-template-columns: 1fr 1fr; } .cat-btns { grid-column: 1 / -1; } .cat-main { flex-wrap: wrap; } }

/* purchase order items */
.po-lines { display: grid; gap: 8px; margin-bottom: 10px; }
.po-line { display: grid; grid-template-columns: 2.2fr 1.6fr .6fr 1fr 40px; gap: 8px; align-items: center; }
.po-line.po-head { font-size: .72rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.po-line .po-rm { min-height: 36px; padding: 0; width: 40px; }
@media (max-width: 880px) { .po-line { grid-template-columns: 1fr 1fr; } .po-line.po-head { display: none; } .po-line input[name='line_desc[]'] { grid-column: 1 / -1; } .po-line select { grid-column: 1 / -1; } }

.sched-form { display: grid; grid-template-columns: 2fr 1fr auto auto auto; gap: 10px; align-items: center; margin-top: 14px; }
.sched-every { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: .86rem; color: var(--text-dim); }
.sched-every input { width: 70px; } .sched-every select { width: 110px; }
.sched-first { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--text-dim); margin: 0; white-space: nowrap; }
@media (max-width: 880px) { .sched-form { grid-template-columns: 1fr; } .sched-first, .sched-every { flex-wrap: wrap; } }

/* a row of action buttons: same height, icon and label centred, even gaps */
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; margin: 0; white-space: nowrap; }
.btn-row .btn .i { margin: 0; }
@media (max-width: 700px) { .btn-row { flex-direction: column; align-items: stretch; } .btn-row .btn { width: 100%; } }
.page-actions > div:not(.btn-row) { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions > div:not(.btn-row) .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; margin: 0; }
.page-actions > div:not(.btn-row) .btn .i { margin: 0; }

/* Sitewide button alignment: every button is the same height with icon and label centred;
   any container holding two or more buttons lays them out in one even row. */
.btn { box-sizing: border-box; gap: 8px; line-height: 1.2; white-space: nowrap; vertical-align: middle; }
.btn .i { margin: 0; flex: none; }
:is(div, span, p):has(> .btn + .btn):not(.btn-row):not(.form-actions) { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
:is(div, span, p):has(> .btn + .btn):not(.btn-row) > .btn { margin: 0; }
:is(div, span, p):has(> .btn + .btn) > form { margin: 0; display: flex; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-actions .btn { margin: 0; }
.page-actions > div:has(> .btn) .btn { min-height: 40px; }

/* header bar (signed in as, date) stays on screen while scrolling */
.topbar { position: sticky; top: 0; z-index: 40; }
.table th { top: 60px; }
.table-scroll .table th { top: 0; }

/* Phones: nothing may push the page sideways. Tables marked "stack" become label/value lists. */
@media (max-width: 700px) {
    .grid > *, .card, .main { min-width: 0; }
    .card { max-width: 100%; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr) !important; }
    .main { overflow-x: clip; }
    img, video, canvas, svg { max-width: 100%; }
    .table-scroll.stack { overflow: visible; }
    .table-scroll.stack .table { min-width: 0; width: 100%; }
    .table-scroll.stack thead { display: none; }
    .table-scroll.stack tr { display: block; padding: 10px 0; border-top: 1px solid var(--border); }
    .table-scroll.stack tr:first-child { border-top: 0; }
    .table-scroll.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
    .table-scroll.stack td::before { content: attr(data-label); flex: none; color: var(--text-dim); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; text-align: left; }
    .table-scroll.stack td[data-label=""]::before { display: none; }
    .table-scroll.stack td[colspan] { display: block; text-align: left; }
    .table-scroll.stack td[colspan]::before { display: none; }
    .table-scroll.stack .row-actions { justify-content: flex-start; }
    dl div, .kv { min-width: 0; }
}
@media (max-width: 700px) {
    .page-actions > div:has(> .btn + .btn) { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .page-actions > div:has(> .btn + .btn) > .btn, .page-actions > div:has(> .btn + .btn) > form, .page-actions > div:has(> .btn + .btn) > form .btn { width: 100%; }
}

@media (max-width: 700px) {
    .table-scroll.stack tr:has(> th) { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 0; }
    .table-scroll.stack th { position: static; background: none; box-shadow: none; padding: 0; width: auto; flex: none; text-align: left; color: var(--text-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
    .table-scroll.stack tr:has(> th) td { padding: 0; }
    .table-scroll.stack tr:has(> th) td::before { display: none; }
}

/* Branded dialogs (static/js/dialog.js) */
html.bd-lock { overflow: hidden; }
.bd-back { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(28, 12, 16, .55); animation: bd-fade .14s ease-out; }
.bd-back.bd-out { opacity: 0; transition: opacity .12s; }
.bd-box { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 26px 26px 22px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); animation: bd-pop .16s ease-out; }
.bd-logo { height: 34px; width: auto; margin: 0 auto 14px; display: block; }
.bd-title { margin: 0 0 8px; font-size: 1.15rem; font-weight: 600; color: var(--text); }
.bd-msg { margin: 0 0 20px; color: var(--text-dim); line-height: 1.5; overflow-wrap: anywhere; }
.bd-input { width: 100%; height: 44px; border: 1px solid var(--border-2); border-radius: 8px; padding: 0 12px; font: inherit; margin: -6px 0 6px; box-sizing: border-box; }
.bd-input:focus { outline: none; border-color: var(--text); }
.bd-err { min-height: 1.2em; margin-bottom: 10px; color: var(--red); font-size: .82rem; text-align: left; }
.bd-actions { display: flex; gap: 10px; justify-content: center; }
.bd-btn { flex: 1; min-height: 44px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.bd-cancel { background: #fff; color: var(--text); border-color: var(--border-2); }
.bd-cancel:hover { background: var(--bg-3); }
.bd-ok { background: var(--accent); color: #fff; }
.bd-ok:hover { background: var(--accent-2); }
.bd-danger { background: var(--red); color: #fff; }
.bd-danger:hover { filter: brightness(.92); }
.bd-btn:focus-visible { outline: 2px solid rgba(155,28,37,.4); outline-offset: 2px; }
@keyframes bd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bd-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) { .bd-back { align-items: flex-end; padding: 0; } .bd-box { max-width: none; border-radius: 16px 16px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); } }

/* bulk change panel on the assets list */
.bulk-panel { background: var(--bg-3, #f6f7f9); border-radius: 10px; padding: 14px 16px; margin: 0 0 12px; }
.bulk-title { margin-bottom: 10px; }
.bulk-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk-row .bf { display: inline-flex; gap: 8px; }
.bulk-row input[type=text], .bulk-row select { min-width: 170px; }
.bulk-chk { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; color: var(--text-dim); }
.bulk-row select, .bulk-row input[type=text] { width: auto; flex: 0 1 230px; }
@media (max-width: 700px) {
    .table-scroll.stack td { white-space: normal !important; flex-wrap: wrap; justify-content: flex-start; text-align: left; }
    .table-scroll.stack td::before { min-width: 38%; }
    .table-scroll.stack td form { display: inline-flex !important; flex-wrap: wrap; gap: 6px; max-width: 100%; margin: 2px 4px 2px 0; }
    .table-scroll.stack td form input[type=text] { width: 100% !important; }
    .table-scroll.stack td .btn { white-space: nowrap; }
}
