/* ============================================================
   Pixel Plus Invoicing — Phase 1 Stylesheet
   Will be expanded in later phases. Kept clean & minimal.
   ============================================================ */

:root {
    --brand:        #0079C1;
    --brand-dark:   #005c93;
    --brand-soft:   #e6f3fb;
    --ink:          #1a1a2e;
    --ink-soft:     #4a4a5e;
    --muted:        #8a8a9a;
    --line:         #e3e6eb;
    --bg:           #f7f8fa;
    --bg-card:      #ffffff;
    --success-bg:   #e7f6ec;
    --success-tx:   #1b6e3a;
    --error-bg:     #fdecec;
    --error-tx:     #a32424;
    --info-bg:      #e6f0fc;
    --info-tx:      #1b4a80;
    --warn-bg:      #fff7e6;
    --warn-tx:      #8a5f00;
    --radius:       8px;
    --radius-sm:    6px;
    --shadow-sm:    0 1px 2px rgba(20, 30, 50, 0.06);
    --shadow-md:    0 4px 16px rgba(20, 30, 50, 0.08);
    --font:         "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: white; text-decoration: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--brand); border-color: var(--line); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

/* ─── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 14px;
}
.alert-success { background: var(--success-bg); color: var(--success-tx); }
.alert-error   { background: var(--error-bg);   color: var(--error-tx); }
.alert-info    { background: var(--info-bg);    color: var(--info-tx); }
.alert-warning { background: var(--warn-bg);    color: var(--warn-tx); }

/* ─── Auth pages ─────────────────────────────────────── */
.auth-body {
    background: linear-gradient(180deg, #f7f8fa 0%, #e9eef5 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-shell {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth-brand { margin-bottom: 28px; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--brand);
    color: white;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 1px;
    border-radius: 12px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-md);
}
.brand-mark.sm {
    width: 36px;
    height: 36px;
    font-size: 15px;
    border-radius: 8px;
    margin-bottom: 0;
}
.brand-name {
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 4px;
}
.brand-tag {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}
.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
    text-align: left;
}
.auth-title {
    font-size: 19px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--ink);
    text-align: center;
}
.auth-sub {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 24px;
    text-align: center;
}
.auth-form { margin-bottom: 8px; }
.auth-hint {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin: 18px 0 0;
}
.auth-footer {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
}

/* ─── Form fields ─────────────────────────────────────── */
.field {
    display: block;
    margin-bottom: 16px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.field-hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

/* ─── App layout (post-login) ─────────────────────────── */
.app-body { background: var(--bg); min-height: 100vh; }
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.app-sidebar {
    background: #1a1a2e;
    color: #d4d8e0;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 22px;
    border-bottom: 1px solid #2a2a40;
}
.brand-name-sm { font-size: 15px; font-weight: 600; color: white; }
.sidebar-nav {
    flex: 1;
    padding: 14px 0;
    overflow-y: auto;
}
.nav-group { margin-bottom: 22px; }
.nav-group-title {
    padding: 0 18px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6e7080;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: #b8bcca;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s;
}
.nav-item:hover { background: #232342; color: white; text-decoration: none; }
.nav-item.active {
    background: var(--brand);
    color: white;
    font-weight: 500;
}
.nav-item.disabled {
    color: #5a5e72;
    cursor: not-allowed;
}
.nav-item.disabled:hover { background: transparent; color: #5a5e72; }
.nav-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
    color: inherit;
    opacity: 0.85;
}

.sidebar-foot {
    border-top: 1px solid #2a2a40;
    padding: 14px 18px;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.user-name { font-size: 13px; color: white; font-weight: 500; line-height: 1.2; }
.user-role { font-size: 11px; color: #8e92a4; }
.logout-form { margin: 0; }
.logout-form .btn { color: #b8bcca; }

/* App main area */
.app-main {
    padding: 0;
    min-width: 0;
}
.app-header {
    display: flex;
    align-items: center;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: white;
    gap: 18px;
}
.page-title {
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}
.header-spacer { flex: 1; }
.header-search input {
    width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
}
.header-search input:disabled {
    background: #f3f4f7;
    color: var(--muted);
    cursor: not-allowed;
}
.app-content {
    padding: 24px 28px;
}

/* Cards */
.card, .welcome-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card h3, .welcome-card h2 { margin: 0 0 8px; color: var(--ink); font-size: 17px; font-weight: 600; }
.card h4 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.welcome-card h2 { font-size: 22px; }
.muted { color: var(--muted); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 18px;
}
.info-item {
    background: var(--bg);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
}
.info-label { display: block; color: var(--muted); font-size: 12px; }
.info-value { display: block; color: var(--ink); font-size: 14px; font-weight: 500; margin-top: 2px; }

.perm-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.pill {
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

/* Responsive */
@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 100;
        transition: left 0.2s;
    }
    .app-sidebar.open { left: 0; }
    .header-search input { width: 160px; }
}

/* ============================================================
   Phase 1.2a — Users, Roles, Audit Log, list pages
   ============================================================ */

/* ─── Page toolbar (top of list pages) ────────────────────── */
.page-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.page-toolbar > .btn { margin-left: auto; }

/* ─── Filter bar ──────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.filter-bar.wide,
.filter-bar.filter-bar-wide { gap: 8px; }
.filter-search,
.filter-date,
.filter-select,
.filter-bar input[type="search"],
.filter-bar input[type="date"],
.filter-bar input[type="text"],
.filter-bar select {
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
    height: 34px;
    box-sizing: border-box;
}
.filter-search { min-width: 220px; flex: 1; max-width: 320px; }
.filter-date   { min-width: 130px; }
.filter-select { min-width: 130px; }
.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; color: var(--muted); }

/* ─── Filter chips (active filters) ───────────────────────── */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
    border-radius: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.chip:hover { background: white; border-color: var(--brand); text-decoration: none; }
.chip-x { font-weight: bold; opacity: 0.7; }
.chip-clear { background: transparent; color: var(--muted); }
.chip-clear:hover { color: var(--ink); }

/* ─── Card variations ─────────────────────────────────────── */
.card.no-pad { padding: 0; overflow: hidden; }
.card.no-pad .pagination { padding: 12px 18px; border-top: 1px solid var(--line); }
.form-card { padding: 22px 26px; }

/* ─── Data tables ─────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    text-align: left;
    padding: 11px 14px;
    background: var(--bg);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table td.empty {
    text-align: center;
    padding: 30px 14px;
    color: var(--muted);
    font-style: italic;
}
.data-table td.actions { text-align: right; }
.data-table td.actions .btn { margin-left: 6px; }

.cell-user {
    display: flex;
    align-items: center;
    gap: 9px;
}
.cell-user a { font-weight: 500; }

/* ─── Avatar variants ─────────────────────────────────────── */
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 12px;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-role    { background: var(--brand-soft); color: var(--brand-dark); }
.badge-success { background: var(--success-bg); color: var(--success-tx); }
.badge-muted   { background: #ebedf0; color: #6a6e7a; }
.badge-warning { background: var(--warn-bg); color: var(--warn-tx); }
.badge-info    { background: var(--info-bg); color: var(--info-tx); }
.badge-action  {
    background: #f1ecf9;
    color: #5d3da4;
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 11px;
}

/* ─── Breadcrumb ──────────────────────────────────────────── */
.page-breadcrumb {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}
.page-breadcrumb a { color: var(--muted); }
.page-breadcrumb a:hover { color: var(--brand); }

/* ─── Form components ─────────────────────────────────────── */
.field-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 18px;
    margin-bottom: 18px;
}
.field-grid .field { margin-bottom: 0; }
.field-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 18px;
}
.field-fieldset legend { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 0 6px; }
.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 0;
    font-size: 13px;
    cursor: pointer;
}
.check-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.req { color: #c53030; font-weight: 700; }

.info-banner {
    background: var(--info-bg);
    color: var(--info-tx);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin: 14px 0;
    font-size: 13px;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.form-actions .btn-primary { margin-left: auto; }

select {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn-danger {
    background: #c53030;
    border-color: #c53030;
    color: white;
}
.btn-danger:hover { background: #a32424; border-color: #a32424; color: white; }

/* ─── Pagination ──────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}
.pagination-info { font-size: 12px; }
.pagination-controls { display: flex; gap: 4px; align-items: center; }
.page-link {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.15s;
    min-width: 32px;
    text-align: center;
}
.page-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page-link.active { background: var(--brand); color: white; border-color: var(--brand); }
.page-link.active:hover { color: white; }
.page-link.disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; pointer-events: none; }
.page-link.ellipsis { border-color: transparent; pointer-events: none; }

/* ─── User detail (show.php) ──────────────────────────────── */
.grid-cols-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}
.user-show-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.user-show-actions { margin-left: auto; }
.user-show-actions .btn { white-space: nowrap; }

.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.action-row form { margin: 0; }

.entity-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.activity-list li:last-child { border-bottom: none; }
.activity-action {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--brand-dark);
}
.activity-desc { font-size: 13px; color: var(--ink); margin-top: 2px; }
.activity-meta { margin-top: 3px; }

/* ─── Temp password reveal ────────────────────────────────── */
.temp-password-box {
    background: var(--bg);
    border: 2px dashed var(--brand);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 18px 0;
}
.password-display {
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 12px 0;
    color: var(--brand-dark);
    user-select: all;
}

/* ─── Audit log specific ──────────────────────────────────── */
.audit-table .audit-row.has-details { cursor: pointer; }
.audit-table .audit-row.expanded { background: var(--brand-soft); }
.audit-expand {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 18px;
}
.audit-detail-row td {
    background: #fafbfc !important;
    padding: 14px !important;
}
.audit-detail { display: flex; flex-direction: column; gap: 10px; }
.diff-block {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.diff-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
    letter-spacing: 0.4px;
}
.diff-pre {
    margin: 0;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--ink);
}

/* ─── Roles permission grid ───────────────────────────────── */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}
.permission-group {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.permission-group h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--brand-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.permission-group .check-row { padding: 3px 0; font-size: 13px; }
.permission-group .check-row code {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
}

/* ─── Small typography helpers ────────────────────────────── */
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }
code {
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 12px;
    background: #f3f4f7;
    padding: 1px 5px;
    border-radius: 3px;
    color: #c53030;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .field-grid { grid-template-columns: 1fr; }
    .grid-cols-2-1 { grid-template-columns: 1fr; }
    .filter-bar { gap: 6px; }
    .filter-search { min-width: 100%; max-width: 100%; }
    .page-toolbar { padding: 10px; }
    .data-table { font-size: 12px; }
    .data-table thead th, .data-table tbody td { padding: 8px; }
}

/* ============================================================
   Phase 1.2a additions
   ============================================================ */

/* ─── Page chrome ─────────────────────────────────────── */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.page-breadcrumb {
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--muted);
}
.page-breadcrumb a { color: var(--brand); }

/* ─── Filter bar ──────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.filter-bar.wide { flex: 1; }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; color: var(--muted); }
.filter-search,
.filter-select {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    background: white;
    color: var(--ink);
    min-width: 120px;
}
.filter-search { min-width: 200px; }
.filter-search:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-soft);
}
.filter-bar input[type="date"] {
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* ─── Tables ──────────────────────────────────────────── */
.card.no-pad { padding: 0; overflow: hidden; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table.compact { font-size: 13px; }
.data-table thead {
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.data-table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}
.data-table.compact th { padding: 8px 12px; }
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.data-table.compact td { padding: 8px 12px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table tr.detail-row:hover td { background: #fafbfc; }
.data-table td.empty {
    text-align: center;
    padding: 32px;
    color: var(--muted);
}
.data-table td.actions { text-align: right; white-space: nowrap; }
.data-table .nowrap { white-space: nowrap; }

/* ─── Badges ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    background: var(--bg);
    color: var(--ink-soft);
    letter-spacing: 0.2px;
}
.badge-success { background: var(--success-bg); color: var(--success-tx); }
.badge-warning { background: var(--warn-bg);    color: var(--warn-tx); }
.badge-error,
.badge-danger  { background: var(--error-bg);   color: var(--error-tx); }
.badge-info    { background: var(--info-bg);    color: var(--info-tx); }
.badge-muted   { background: #e9ecef;           color: var(--muted); }
.badge-role    { background: var(--brand-soft); color: var(--brand-dark); font-weight: 500; }

/* ─── Cell helpers ────────────────────────────────────── */
.cell-user { display: flex; align-items: center; gap: 10px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; border-radius: 50%; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 50%; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 12px; }

/* ─── Buttons ──────────────────────────────────────────── */
.btn-danger {
    background: var(--error-tx);
    border-color: var(--error-tx);
    color: white;
}
.btn-danger:hover { background: #821e1e; border-color: #821e1e; color: white; }

/* ─── Forms ──────────────────────────────────────────── */
.form-card { padding: 24px; }
.field-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 18px;
    margin-bottom: 14px;
}
.field-grid .field { margin-bottom: 0; }
.field select,
.field input[type="tel"],
.field input[type="date"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}
.field select:focus,
.field input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input[readonly] { background: #f8f9fa; }
.req { color: var(--error-tx); }
.field-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 14px;
}
.field-fieldset legend {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    padding: 0 8px;
}
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
}
.check-row input[type="checkbox"] { margin-top: 3px; }
.check-row span { display: block; flex: 1; }
.check-row small { display: block; margin-top: 2px; }
.info-banner {
    background: var(--info-bg);
    color: var(--info-tx);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin: 6px 0 14px;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ─── Card header (title + action) ─────────────────────── */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.card-header h3 { margin: 0; }

/* ─── User detail page ─────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 18px;
    margin-bottom: 18px;
}
.user-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.action-row:last-child { border-bottom: none; }
.action-row > div { flex: 1; }
.action-row p { margin: 3px 0 0; }

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
    .field-grid { grid-template-columns: 1fr; }
}

/* ─── Credentials display ──────────────────────────────── */
.credentials-card { padding: 24px; }
.cred-row {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.cred-row:last-of-type { border-bottom: none; }
.cred-label { color: var(--muted); font-size: 13px; }
.cred-value { font-size: 14px; word-break: break-all; }
.temp-password {
    background: var(--warn-bg);
    color: var(--warn-tx);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* ─── Audit log ────────────────────────────────────────── */
.audit-meta {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}
.expandable { cursor: pointer; }
.detail-row td {
    padding: 14px 24px !important;
    background: #fafbfc;
}
.diff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.diff-grid h5 {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.5px;
}
.diff-json {
    background: white;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 11px;
    max-height: 250px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.toggle-detail { padding: 2px 8px; font-size: 12px; }

/* ─── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    flex-wrap: wrap;
}
.page-btn {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--ink-soft);
    font-size: 13px;
    min-width: 34px;
    text-align: center;
    text-decoration: none;
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page-btn.current {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
}
.page-btn.disabled {
    pointer-events: none;
    opacity: 0.4;
}
.page-ellipsis { padding: 0 4px; color: var(--muted); }
.page-info { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ─── Roles permissions matrix ─────────────────────────── */
.perm-group { margin-bottom: 20px; }
.perm-group-title {
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 6px 12px;
}
.perm-check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
}
.perm-check-row input { margin-top: 4px; }
.perm-check-row code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 3px;
    color: var(--ink);
}
.perm-check-row small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
    font-size: 11px;
}


/* ============================================================
   PHASE 1.2b — Password reset email + 2FA + Email Settings
   ============================================================ */

/* TOTP code input (large, monospace, centered) */
.totp-input {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    padding: 14px 12px !important;
}

/* Auth footer link block */
.auth-foot {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
}
.auth-foot a { color: var(--brand); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* 2FA setup */
.setup-2fa-container {
    display: grid;
    gap: 18px;
    max-width: 720px;
}
.setup-steps {
    padding-left: 24px;
    line-height: 1.7;
}
.setup-steps > li {
    margin-bottom: 16px;
}
.setup-steps a {
    color: var(--brand);
}

.manual-entry {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    margin-top: 10px;
}
.manual-entry-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line);
}
.manual-entry-row:last-child { border-bottom: 0; }
.manual-entry-label {
    color: var(--muted);
    font-size: 12px;
    min-width: 110px;
}
.manual-entry-value {
    flex: 1;
    font-size: 13px;
}
.key-display {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 14px;
    letter-spacing: 1.5px;
}
.copy-btn {
    background: var(--brand);
    color: white;
    border: 0;
    padding: 3px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
}
.copy-btn:hover { background: var(--brand-dark, #005d96); }
.otpauth-row {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 4px;
    word-break: break-all;
}
.otpauth-link {
    color: var(--brand);
    text-decoration: none;
    font-size: 12px;
}
.otpauth-link:hover { text-decoration: underline; }

/* Recovery codes display */
.recovery-codes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 18px;
    background: var(--bg);
    padding: 18px 22px;
    border-radius: 6px;
    border: 1px solid var(--line);
    margin: 18px 0;
}
@media (max-width: 600px) {
    .recovery-codes-grid { grid-template-columns: 1fr; }
}
.recovery-code {
    font-size: 16px;
    letter-spacing: 1.5px;
    padding: 6px 0;
}
.rc-index {
    color: var(--muted);
    margin-right: 8px;
    font-size: 13px;
}

/* Checkbox style for "I have saved these codes" */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}
.checkbox input { margin: 0; }

/* User chip in sidebar — now clickable for Account page */
.user-chip-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 4px;
    margin: -8px -8px 8px -8px;
    transition: background-color 0.1s ease;
}
.user-chip-link:hover {
    background: rgba(255,255,255,0.05);
}

/* Settings page layout */
.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 22px;
    align-items: start;
}
@media (max-width: 800px) {
    .settings-layout { grid-template-columns: 1fr; }
}
.settings-nav {
    background: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    position: sticky;
    top: 16px;
}
.settings-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.settings-nav li a,
.settings-nav li > span {
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    text-decoration: none;
    color: var(--ink);
}
.settings-nav li a:hover { background: var(--bg); }
.settings-nav li.active a {
    background: var(--brand);
    color: white;
    font-weight: 500;
}
.settings-nav li.disabled > span {
    color: var(--muted);
    cursor: default;
}
.settings-content > .card + .card {
    margin-top: 18px;
}
.badge-soft {
    display: inline-block;
    background: var(--bg);
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 4px;
    vertical-align: 1px;
}

/* Two-column form grid */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
    margin-bottom: 4px;
}
@media (max-width: 600px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}
.form-inline {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}

/* Field hint (small descriptive text under inputs) */
.field-hint {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 4px;
}

/* Grid for account layout (2/1 columns) */
.grid-cols-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .grid-cols-2-1 { grid-template-columns: 1fr; }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

/* Page breadcrumb */
.page-breadcrumb {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 14px;
}
.page-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}
.page-breadcrumb a:hover {
    color: var(--brand);
    text-decoration: underline;
}

/* Alert variants extension */
.alert-info {
    background: #eef6fb;
    color: #114b6f;
    border-left: 3px solid var(--brand);
}

/* Radio button groups (Settings > Security) */
.radio-group {
    border: 0;
    padding: 0;
    margin: 0;
}
.radio-group legend {
    padding: 0;
    margin: 0;
}
.radio-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}
.radio-row:hover {
    background: var(--bg);
}
.radio-row:has(input:checked) {
    background: #eef6fb;
    border-color: var(--brand);
}
.radio-row input[type=radio] {
    margin: 3px 0 0 0;
    flex-shrink: 0;
}
.radio-row > div {
    flex: 1;
}
.radio-row .muted.small {
    font-size: 12px;
    margin-top: 4px;
}

/* ─── Phase 1.2d: Settings (Company, Numbering, Tax) ─── */

.company-form .card { margin-bottom: 18px; }

.form-grid {
    display: grid;
    gap: 14px 18px;
    margin-top: 6px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) {
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}

.form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 14px 18px;
    margin: 18px 0 0;
    border-top: 1px solid #e5e8ed;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
    z-index: 5;
}

/* Branding tiles (logo / stamp / signature) */
.branding-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 10px;
}
@media (max-width: 760px) { .branding-grid { grid-template-columns: 1fr; } }

.branding-tile {
    border: 1px solid #e5e8ed;
    border-radius: 6px;
    padding: 14px;
    text-align: center;
    background: #fafbfc;
}
.branding-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    color: #4a525e;
}
.branding-preview {
    min-height: 110px;
    max-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px dashed #cfd4dc;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
}
.branding-preview img {
    max-width: 100%;
    max-height: 130px;
    object-fit: contain;
}
.branding-empty {
    color: #9aa1ac;
    font-size: 12px;
    font-style: italic;
}
.branding-upload {
    display: block;
    text-align: center;
    cursor: pointer;
    padding: 6px 0;
}
.branding-upload input[type="file"] {
    display: block;
    width: 100%;
    font-size: 12px;
    margin-bottom: 4px;
}
.btn-link {
    background: transparent;
    border: 0;
    color: #c62828;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px;
}
.btn-link:hover { color: #8b0000; }

/* Numbering page */
.numbering-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.numbering-preview {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 13px;
}
.preview-label {
    color: #6b7280;
}
.preview-value {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    background: #f0f7fb;
    color: #0079C1;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.3px;
}
.numbering-form .form-actions {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eef0f3;
}
.readonly-display {
    padding: 8px 12px;
    background: #f5f6f8;
    border-radius: 4px;
    font-size: 14px;
    color: #4a525e;
}

/* Tax table */
.tax-table th, .tax-table td { vertical-align: middle; }
.tax-table input[type="text"].full,
.tax-table input[type="number"] {
    padding: 5px 8px;
    font-size: 13px;
}
.tax-table .full { width: 100%; }
.tax-table .btn-sm { padding: 4px 12px; font-size: 12px; }

/* Slightly larger settings nav (matches new tabs) */
.settings-nav { min-width: 200px; }

/* Field defaults if not already styled elsewhere */
.field .field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #4a525e;
    margin-bottom: 4px;
}
.field .field-label .req { color: #c62828; }
.field .field-label .muted { font-weight: 400; }
.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input[type="date"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cfd4dc;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: white;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: #0079C1;
    box-shadow: 0 0 0 2px rgba(0, 121, 193, 0.15);
}


/* ─── Phase 2a: Customers module ────────────────────────────────── */

/* Page-level layout */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 12px;
}
.page-header h1 { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Table row variations */
.row-link {
    color: var(--brand-dark);
    text-decoration: none;
    font-weight: 600;
}
.row-link:hover { text-decoration: underline; }
.row-inactive td { opacity: 0.55; }
.row-inactive .row-link { color: var(--text); }

/* Inline tags + monospace TRN */
.tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    margin-left: 6px;
    vertical-align: middle;
}
.tag-muted { background: #ebedf0; color: #6a6e7a; }
.trn { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; }

/* Form helpers */
.span-2 { grid-column: 1 / -1; }

/* Empty states */
.empty-state {
    text-align: center;
    padding: 32px 16px;
}
.empty-state p { margin: 8px 0 16px; }

/* Customer detail header */
.customer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 12px;
}

/* Tabs on detail page */
.entity-tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.entity-tabs a {
    padding: 9px 14px;
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.entity-tabs a:hover { color: var(--text); }
.entity-tabs a.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}
.entity-tab-content { margin-top: 4px; }

/* Overview cards */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.info-dl {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 14px;
    font-size: 14px;
}
.info-dl dt { color: var(--text-muted); }
.info-dl dd { margin: 0; }
.address-card, .contact-card {
    font-size: 14px;
    line-height: 1.55;
}

/* Address & contact tiles */
.address-list, .contacts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin: 8px 0;
}
.address-tile, .contact-tile {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}
.address-tile-head, .contact-tile-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}
.address-type {
    font-weight: 600;
    font-size: 13px;
}

/* Inline collapsible add-form */
.add-form-details > summary {
    cursor: pointer;
    display: inline-flex;
    list-style: none;
}
.add-form-details > summary::-webkit-details-marker { display: none; }
.add-form-details[open] > summary { display: none; }
.add-form-details .inline-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* Notes */
.note-form textarea {
    width: 100%;
    resize: vertical;
}
.notes-list {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.note-item {
    padding: 10px 12px;
    background: var(--bg);
    border-left: 3px solid var(--brand);
    border-radius: 0 3px 3px 0;
}
.note-meta { font-size: 13px; margin-bottom: 4px; }
.note-body { font-size: 14px; white-space: pre-wrap; }

/* Activity feed (compact rows) */
.activity-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.activity-row:last-child { border-bottom: none; }
.activity-meta { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.activity-action {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    padding: 1px 6px;
    border-radius: 2px;
}
.activity-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* CSV import flow */
.import-stepper {
    display: flex;
    gap: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
}
.import-stepper .step {
    flex: 1;
    padding: 10px 14px;
    text-align: center;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    font-size: 14px;
    background: var(--bg);
}
.import-stepper .step:last-child { border-right: none; }
.import-stepper .step.active {
    color: var(--brand);
    font-weight: 600;
    background: var(--brand-soft);
}
.import-stepper .step.done {
    color: var(--success-tx);
    background: var(--success-bg);
}
.import-stepper .step.done.active {
    color: var(--brand);
    background: var(--brand-soft);
}

/* CSV preview */
.csv-preview-wrap, .error-rows-wrap {
    overflow-x: auto;
    margin: 8px 0;
    max-width: 100%;
}
.csv-preview {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.csv-preview th, .csv-preview td {
    border: 1px solid var(--border);
    padding: 5px 8px;
    text-align: left;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.csv-preview th {
    background: var(--bg);
    font-weight: 600;
    position: relative;
}
.col-idx {
    display: inline-block;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 2px;
    margin-right: 5px;
    font-weight: normal;
    font-family: 'SF Mono', Menlo, monospace;
}

/* Mapping table */
.map-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.map-table th, .map-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.map-table thead th {
    background: var(--bg);
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}
.map-table .map-section th {
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 13px;
    padding: 8px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.map-table td:first-child { width: 38%; }
.map-select { width: 100%; }

/* Import preview stats */
.import-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.stat-tile {
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: center;
}
.stat-tile.stat-good { background: var(--success-bg); border-color: var(--success-tx); }
.stat-tile.stat-warn { background: #fff4e0; border-color: #c98b00; }
.stat-tile.stat-bad  { background: var(--danger-bg); border-color: var(--danger-tx); }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-good .stat-num { color: var(--success-tx); }
.stat-warn .stat-num { color: #c98b00; }
.stat-bad  .stat-num { color: var(--danger-tx); }
.stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.text-error { color: var(--danger-tx); font-size: 13px; }

.error-log {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 10px;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
}

/* Small ✕ button */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 3px;
}
.btn-icon:hover { color: var(--danger-tx); background: var(--danger-bg); }

/* btn-sm helper (small height button) */
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--bg); }

/* ─── Phase 2b.1: Product images ─────────────────────────────── */

/* Thumbnail in list table */
.product-thumb {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
}
.product-thumb-empty {
    background: var(--bg);
    background-image:
        linear-gradient(45deg, transparent 47%, var(--border) 47%, var(--border) 53%, transparent 53%),
        linear-gradient(-45deg, transparent 47%, var(--border) 47%, var(--border) 53%, transparent 53%);
}

/* On the create/edit form: current image preview + actions */
.product-image-current {
    display: flex;
    gap: 14px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 12px;
    align-items: flex-start;
}
.product-image-current img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    flex-shrink: 0;
}
.product-image-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.product-image-actions p { margin: 0; }

/* On the detail page Overview tab */
.product-image-card {
    grid-column: span 2;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: var(--bg);
}
.product-image-large {
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
}
@media (max-width: 800px) {
    .product-image-card { grid-column: span 1; }
}
