/* Only 3 semantic colors are used across the whole app: success (primary/positive),
   warning (attention/pending), danger (negative/destructive). No blue/purple/teal. */
:root {
    --success: #16a37a;
    --success-dark: #128363;
    --success-light: #e5f7f1;
    --warning: #d97706;
    --warning-dark: #b45f04;
    --warning-light: #fef3e2;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-light: #fdecec;

    /* Primary/brand accent = success green */
    --accent: var(--success);
    --accent-dark: var(--success-dark);
    --accent-light: var(--success-light);

    --sidebar-bg: #1f2430;
    --sidebar-bg-hover: #2a303f;
    --sidebar-text: #a8adba;
    --sidebar-text-strong: #ffffff;
    --sidebar-w: 230px;

    --border: #e7eaf3;
    --text-muted: #8992a9;
    --text-body: #1f2937;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(16, 24, 55, 0.04), 0 8px 24px rgba(16, 24, 55, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: #f3f5fb;
    font-family: "Poppins", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text-body);
    font-size: 12px;
    overflow-x: hidden;
}

/* Authenticated screens use an app viewport, not the browser document. */
body.app-body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Poppins", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: -0.01em;
}

a {
    text-decoration: none;
    color: var(--accent-dark);
}

/* ---------- Shell layout ---------- */

.app-shell {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    padding: 16px 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    color: var(--sidebar-text);
    transition: width .25s ease, padding .25s ease, transform .25s ease;
}

@media (min-width: 992px) {
    .app-shell.sidebar-collapsed .sidebar {
        width: 64px;
        padding-inline: 10px;
    }

    .app-shell.sidebar-collapsed .brand {
        padding-inline: 4px;
        justify-content: center;
    }

    .app-shell.sidebar-collapsed .brand > div,
    .app-shell.sidebar-collapsed .nav-section {
        display: none;
    }

    .app-shell.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        gap: 0;
        padding-inline: 8px;
        white-space: nowrap;
        overflow: hidden;
        font-size: 0 !important;
    }

    .app-shell.sidebar-collapsed .sidebar .nav-link i {
        width: auto;
        font-size: 16px !important;
    }
}

.sidebar-scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    flex-grow: 1;
    min-height: 0;
    padding-right: 2px;
    scrollbar-gutter: stable;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px 16px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--success);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.brand-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.15;
    color: var(--sidebar-text-strong);
}

.brand-sub {
    font-size: 10px;
    letter-spacing: .08em;
    color: #7c869c;
}

.nav-section {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #6b7385;
    margin: 14px 8px 6px 8px;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1px;
    transition: background .12s ease, color .12s ease;
}

.sidebar .nav-link i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.sidebar .nav-link.active {
    background: rgba(22, 163, 122, 0.18);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--success);
}

.sidebar .nav-link.disabled-link {
    color: #565d6e;
    cursor: default;
    pointer-events: none;
}

.main-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-toggle {
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
}

.topbar-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-body);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-chip-text {
    line-height: 1.2;
}

.user-chip-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-body);
}

.user-chip-role {
    font-size: 11px;
    color: var(--text-muted);
}

.content {
    padding: 20px 24px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* The fixed top bar already shows the page title. Keep only record identifiers. */
.content h2:not(.entity-title) {
    display: none;
}

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

.form-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    max-width: 720px;
    box-shadow: var(--shadow-card);
}

.section-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 16px 0 10px 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.section-label:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

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

.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 0.35rem 0.65rem;
    font-size: 13px;
    line-height: 1.35;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 12px;
    line-height: 1.3;
}

.btn-accent {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-accent:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
    color: #fff;
}

.btn-create-bom,
.btn-create-bom:focus {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: #fff !important;
}

.btn-create-bom:hover {
    background-color: var(--success-dark) !important;
    border-color: var(--success-dark) !important;
    color: #fff !important;
}

.design-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.design-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.design-view-icon {
    color: var(--success-dark);
}

.design-bom-icon {
    color: var(--success);
}

.design-action-icon:hover,
.design-action-icon:focus-visible {
    color: var(--success-dark);
    background: var(--success-light) !important;
    border-radius: 5px;
    outline: none;
}

/* RM Inward Details: three compact summaries in one desktop viewport. */
.rm-details-card {
    width: 100%;
    max-width: none;
    padding: 14px 16px;
}

.rm-details-card .section-label {
    margin-bottom: 6px;
}

.rm-details-card .table > :not(caption) > * > * {
    padding: 0.34rem 0.35rem;
    vertical-align: top;
}

.rm-details-card th {
    width: 42%;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.rm-total-row > * {
    background: var(--success-light) !important;
    color: var(--success-dark) !important;
}

/* Job Create: compact fields and two independently scrolling material panels. */
.job-create-card {
    width: 100%;
    max-width: none;
    padding: 16px 18px;
}

.job-create-fields .form-label {
    margin-bottom: 4px;
}

.job-material-panels .section-label {
    margin: 12px 0 6px;
    padding-top: 8px;
}

.job-table-scroll {
    height: clamp(180px, calc(100vh - 360px), 330px);
    height: clamp(180px, calc(100dvh - 360px), 330px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overscroll-behavior: contain;
}

.job-table-scroll .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.job-table-scroll .table > :not(caption) > * > * {
    padding: 0.35rem 0.45rem;
    vertical-align: middle;
}

.job-create-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Product Design Details: image, metadata and BOM share one desktop row. */
.product-details-card {
    width: 100%;
    max-width: none;
    padding: 14px 16px;
}

.product-details-card .table > :not(caption) > * > * {
    padding: 0.35rem 0.4rem;
    vertical-align: top;
}

.product-details-card th {
    width: 38%;
    color: var(--text-muted);
    font-weight: 600;
}

.product-details-image {
    display: block;
    width: 100%;
    height: min(48vh, 390px);
    object-fit: contain;
    background: #fff;
}

.product-bom-card {
    min-height: 220px;
    max-height: calc(100vh - 190px);
    max-height: calc(100dvh - 190px);
    overflow: auto;
}

.product-bom-card .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Complete Job: compact summary and bounded dynamic material rows. */
.job-summary-card,
.job-complete-card {
    width: 100%;
    max-width: 1100px;
    padding: 14px 16px;
}

.job-summary-card .section-label,
.job-complete-card .section-label {
    margin-bottom: 7px;
}

.job-complete-card .form-label {
    margin-bottom: 4px;
}

.complete-extra-scroll {
    max-height: 280px;
    min-height: 58px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.material-entry-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.issued-usage-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.usage-count-badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    color: var(--success-dark);
    border: 1px solid #b9e5d4;
    border-radius: 999px;
    background: var(--success-light);
    font-size: 12px;
    font-weight: 700;
}

.usage-table-wrap {
    max-height: 290px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.usage-table {
    min-width: 820px;
}

.usage-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 9px 14px;
    color: var(--text-muted);
    background: #f8fafc;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.usage-table tbody td {
    padding: 12px 14px;
    border-bottom-color: #edf0f5;
}

.usage-table tbody tr:nth-child(even) td { background: #fbfcfe; }
.usage-table tbody tr:hover td { background: #f5faf8; }

.usage-line-number {
    width: 48px;
    text-align: center;
}

.usage-table .used-qty-input {
    min-width: 120px;
    font-weight: 600;
}

.material-entry-toolbar,
.material-entry-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: #f8fafc;
}

.material-entry-toolbar {
    border-bottom: 1px solid var(--border);
}

.material-entry-title {
    color: var(--text);
    font-weight: 700;
}

.material-grid {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.65fr) minmax(100px, .65fr) minmax(150px, .9fr) 86px;
    align-items: center;
    gap: 10px;
}

.material-grid-header {
    padding: 9px 14px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.extra-row.material-grid {
    margin: 0 14px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f5;
}

.extra-row.material-grid:last-child {
    border-bottom: 0;
}

.material-row-action .btn {
    width: 38px;
    height: 38px;
    padding: 0;
}

.material-row-action {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.material-entry-footer {
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.material-total-label strong {
    margin-left: 10px;
    color: var(--success-dark);
    font-size: 16px;
}

.completion-attachment-panel {
    margin-top: 14px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
}

.job-complete-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

@media (min-width: 992px) {
    .content:has(.job-complete-page) {
        overflow-y: auto;
    }

    .job-complete-page {
        display: block;
        min-height: 100%;
        overflow: visible;
    }

    .job-complete-card {
        min-height: 0;
        overflow: visible;
    }

    .job-complete-card form {
        display: block;
        height: auto;
    }

    .complete-extra-scroll { max-height: 280px; }
}

@media (max-width: 767.98px) {
    .material-grid-header { display: none; }

    .material-entry-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .material-entry-toolbar .btn { width: 100%; }

    .extra-row.material-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin: 0 12px;
        padding: 14px 0;
    }

    .material-field:nth-child(1),
    .material-field:nth-child(2) { grid-column: 1 / -1; }

    .material-field::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 700;
    }

    .material-row-action {
        grid-column: 1 / -1;
        text-align: right;
    }

    .material-entry-footer { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (min-width: 992px) {
    .content:has(.product-details-page) {
        overflow-y: hidden;
    }
}

@media (min-width: 992px) {
    .content:has(.job-create-page) {
        overflow-y: hidden;
    }
}

@media (min-width: 992px) {
    .content:has(.rm-details-page) {
        overflow-y: hidden;
    }

    .rm-details-page {
        height: 100%;
        overflow: hidden;
    }
}

.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-body);
}

.btn-outline-secondary:hover {
    background: #f3f5fb;
    border-color: var(--border);
    color: var(--text-body);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}
.btn-success:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
}

.btn-outline-primary {
    color: var(--success);
    border-color: var(--success);
}
.btn-outline-primary:hover {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

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

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

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
}

/* ---------- Forms ---------- */

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: 7px 11px;
    font-size: 13.5px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-light);
}

.form-label {
    font-size: 13px;
    color: var(--text-body);
}

/* Product Design Create: use the available width so the form fits one screen. */
.design-create-card {
    width: 100%;
    max-width: 960px;
    padding: 18px 20px;
}

.design-create-card .form-label {
    margin-bottom: 5px;
}

.design-create-card .type-toggle {
    gap: 8px;
}

.design-create-card .type-toggle-btn {
    padding: 8px 12px;
}

.design-create-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ---------- Type toggle (Gold/Diamond etc.) ---------- */

.type-toggle {
    display: flex;
    gap: 12px;
}

.type-toggle .btn-check:checked + .type-toggle-btn {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success-dark);
    font-weight: 600;
}

.type-toggle-btn {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    color: var(--text-body);
    background: #fff;
}

.bg-accent-soft {
    background: var(--success-light) !important;
}

/* ---------- Tables ---------- */

.table {
    font-size: 13.5px;
}

.table > :not(caption) > * > * {
    padding: 0.5rem 0.65rem;
}

.table thead th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom-width: 1px;
    border-color: var(--border);
    background: #f8f9fd;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #fafbfe;
}

.table-responsive {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.table-responsive .table {
    margin-bottom: 0;
}

/* Search box above listing tables */
.table-search-wrap {
    position: relative;
    max-width: 340px;
    margin-bottom: 14px;
}
.table-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}
.table-search-input {
    padding-left: 34px !important;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: none;
    margin-bottom: 10px;
}

.table-toolbar .table-search-input {
    width: min(260px, 100%);
    flex: 0 1 260px;
    min-height: 32px;
    padding-top: 5px;
    padding-bottom: 5px;
}

.table-page-size-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    white-space: nowrap;
}

/* RM Inward listing: eight compact rows plus pagination fit in the viewport. */
.rm-inward-search {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: none;
    margin-bottom: 10px;
}

.rm-inward-search .form-control {
    min-width: 0;
}

.rm-inward-search .table-search-input {
    width: 220px !important;
    max-width: 220px !important;
    flex: 0 0 220px !important;
    min-height: 30px;
    padding-top: 4px;
    padding-bottom: 4px;
}

.rm-inward-search button[type="submit"] {
    display: none !important;
}

.rm-page-size-label {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.rm-page-size {
    width: 72px;
    flex: 0 0 72px;
}

.rm-inward-table .table > :not(caption) > * > * {
    padding: 0.38rem 0.5rem;
    white-space: nowrap;
}

.rm-inward-table {
    max-height: calc(100vh - 230px);
    max-height: calc(100dvh - 230px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.rm-inward-table .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.rm-inward-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.rm-inward-pagination .page-link {
    color: var(--success-dark);
    border-color: var(--border);
}

.rm-inward-pagination .page-item.active .page-link {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

/* Shared listing-table pagination and table-only overflow. */
.paginated-table-container {
    max-height: calc(100vh - 230px);
    max-height: calc(100dvh - 230px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.paginated-table-container .table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.table-page-size {
    width: 72px;
    flex: 0 0 72px;
}

.table-page-buttons {
    display: flex;
}

.table-page-buttons .page-link {
    color: var(--success-dark);
    border: 1px solid var(--border);
    margin-left: -1px;
}

.table-page-buttons .page-link.active {
    color: #fff;
    background: var(--success);
    border-color: var(--success);
}

.table-page-buttons .page-link:disabled {
    color: var(--text-muted);
    background: #fff;
    opacity: .65;
}

@media (max-width: 575.98px) {
    .table-toolbar {
        flex-wrap: wrap;
    }

    .table-toolbar .table-search-input {
        flex-basis: calc(100% - 34px);
    }

    .rm-inward-search .table-search-input {
        width: calc(100% - 34px) !important;
        max-width: none !important;
        flex: 1 1 calc(100% - 34px) !important;
    }

    .table-page-size-wrap,
    .rm-page-size-label {
        margin-left: 0;
    }

    .table-pagination-controls,
    .rm-inward-pagination {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ---------- Badges (success / warning / danger / neutral only) ---------- */

.badge {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .02em;
    padding: 5px 10px;
    border-radius: 999px;
}

.bg-success { background-color: var(--success) !important; }
.bg-warning { background-color: var(--warning) !important; color: #fff !important; }
.bg-danger  { background-color: var(--danger) !important; }
.bg-secondary { background-color: #8992a9 !important; }

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

.alert {
    border-radius: var(--radius-md);
    border: none;
    font-size: 14px;
}
.alert-success { background: var(--success-light); color: var(--success-dark); }
.alert-danger { background: var(--danger-light); color: var(--danger-dark); }
.alert-warning { background: var(--warning-light); color: var(--warning-dark); }

/* ---------- Modals ---------- */

.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 20px 60px rgba(16, 24, 55, 0.25);
}

.modal-header, .modal-footer {
    border-color: var(--border);
}

/* ---------- Job product image preview ---------- */
.job-product-image-button { position: relative; display: inline-block; border-radius: 8px; cursor: zoom-in; }
.job-product-thumbnail { width: 58px; height: 58px; display: block; object-fit: cover; border: 1px solid #ddd; border-radius: 8px; transition: transform .18s ease, box-shadow .18s ease; }
.job-product-image-button:hover .job-product-thumbnail { transform: scale(1.08); box-shadow: 0 5px 15px rgba(0,0,0,.22); }
.job-image-zoom-icon { position: absolute; right: 3px; bottom: 3px; display: grid; place-items: center; width: 20px; height: 20px; color: #fff; background: rgba(0,0,0,.68); border-radius: 50%; font-size: 11px; }
.job-product-image-empty { display: grid; place-items: center; color: #999; background: #f4f4f4; font-size: 20px; }
.job-product-zoom-wrap { min-height: 420px; display: flex; align-items: center; justify-content: center; overflow: auto; background: #171717; }
.job-product-zoom-image { max-width: 100%; max-height: 76vh; object-fit: contain; cursor: zoom-in; transition: transform .2s ease; }
.job-product-zoom-image:active { transform: scale(1.5); cursor: zoom-out; }
.app-zoomable-image { cursor: zoom-in; transition: transform .18s ease, box-shadow .18s ease; }
.app-zoomable-image:hover { transform: scale(1.03); box-shadow: 0 5px 16px rgba(0,0,0,.2); }
.app-zoomable-image:focus-visible { outline: 3px solid rgba(23,102,79,.35); outline-offset: 3px; }

/* ---------- Login page ---------- */

html:has(body.auth-page),
body.auth-page {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

.auth-shell {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(24px, 5vw, 80px);
    background: #151719 url("../images/login-jewellery-workshop.png") center / cover no-repeat;
}

.auth-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 20% 50%, rgba(7, 10, 10, .08), rgba(7, 10, 10, .5) 48%, transparent 72%),
        linear-gradient(90deg, rgba(8, 10, 11, .2) 0%, rgba(8, 10, 11, .08) 45%, rgba(8, 10, 11, .12) 100%);
}

.auth-content {
    width: min(100%, 960px);
    display: grid;
    grid-template-columns: 400px minmax(420px, 1fr);
    align-items: center;
    gap: clamp(20px, 4vw, 48px);
}

.auth-card { order: 1; }
.auth-accounts-panel { order: 2; }

.auth-accounts-panel {
    color: #f4efe5;
    background: linear-gradient(145deg, rgba(27, 29, 28, .94), rgba(12, 15, 14, .9));
    border: 1px solid rgba(201, 164, 91, .34);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .48);
    backdrop-filter: blur(18px) saturate(.9);
    padding: clamp(20px, 2.5vw, 28px);
}

.auth-accounts-panel .text-muted { color: #aaa397 !important; }
.auth-account-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-account-item { display: grid; gap: 2px; padding: 9px 11px; background: rgba(255,255,255,.04); border: 1px solid rgba(201,164,91,.16); border-radius: 9px; }
.auth-account-item strong { color: #f4efe5; font-size: 11px; }
.auth-account-item code { color: #ddc385; font-size: 10px; overflow-wrap: anywhere; }
.auth-account-item span { color: #aaa397; font-size: 10px; }

.auth-card {
    position: relative;
    color: #f4efe5;
    background: linear-gradient(145deg, rgba(27, 29, 28, .94), rgba(12, 15, 14, .9));
    border: 1px solid rgba(201, 164, 91, .34);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .58), inset 0 1px 0 rgba(255, 255, 255, .05);
    backdrop-filter: blur(18px) saturate(.9);
    padding: clamp(22px, 2.5vw, 30px);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.auth-brand {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(201, 164, 91, .22);
}

.auth-brand .brand-icon {
    width: 42px;
    height: 42px;
    padding: 4px;
    color: #e1bd70;
    background: rgba(201, 164, 91, .08);
    border-color: rgba(201, 164, 91, .35);
}

.auth-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-card .mb-4 {
    margin-bottom: 1rem !important;
}

.auth-card hr.my-4 {
    margin-top: 1rem !important;
    margin-bottom: 1rem !important;
    border-color: rgba(201, 164, 91, .2);
    opacity: 1;
}

.auth-brand-sub {
    color: #a99e8d;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .11em;
}

.auth-eyebrow {
    margin-bottom: 5px;
    color: #d8b465;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-wrap > i {
    position: absolute;
    top: 50%;
    left: 12px;
    z-index: 2;
    transform: translateY(-50%);
    color: #a99e8d;
}

.auth-input-wrap .form-control {
    min-height: 40px;
    padding-left: 36px;
    color: #f7f2e9;
    background: transparent;
    border-color: rgba(201, 164, 91, .25);
}

.auth-input-wrap .form-control::placeholder {
    color: #8e897f;
}

.auth-input-wrap .form-control:focus {
    color: #fff;
    background: transparent;
    border-color: #c9a45b;
    box-shadow: 0 0 0 .2rem rgba(201, 164, 91, .14);
}

.auth-input-wrap .form-control:-webkit-autofill,
.auth-input-wrap .form-control:-webkit-autofill:hover,
.auth-input-wrap .form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: #f7f2e9;
    -webkit-box-shadow: 0 0 0 1000px rgba(12, 15, 14, .96) inset;
    caret-color: #f7f2e9;
    transition: background-color 9999s ease-out;
}

.auth-card .text-muted {
    color: #aaa397 !important;
}

.auth-card .form-label {
    color: #f1eadf;
}

.auth-card .text-danger {
    color: #ff9b9b !important;
}

.auth-card code {
    color: #ddc385;
    background: rgba(201, 164, 91, .09);
    padding: 1px 4px;
    border-radius: 4px;
}

.auth-submit {
    min-height: 40px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #17664f, #0e4d3b);
    border-color: #28785f;
    box-shadow: 0 8px 22px rgba(4, 53, 39, .35);
}

.auth-submit:hover,
.auth-submit:focus {
    color: #fff;
    background: linear-gradient(135deg, #1d765c, #125b46);
    border-color: #d2ae63;
}

@media (max-width: 767.98px) {
    .auth-shell {
        justify-content: center;
        padding: 18px;
        background-position: 66% center;
    }

    .auth-shell::before {
        background: rgba(10, 13, 16, .55);
    }

    html:has(body.auth-page), body.auth-page { height: auto; min-height: 100%; overflow: auto; }
    .auth-shell { height: auto; min-height: 100vh; overflow: visible; }
    .auth-content { grid-template-columns: 1fr; }
    .auth-card { max-width: none; order: 1; }
    .auth-accounts-panel { order: 2; }
}

/* ---------- Unified typography ----------
   Two sizes only: page titles and standard interface text. */

:root {
    --font-size-standard: 12px;
    --font-size-page-title: 18px;
}

body,
body * {
    font-family: "Poppins", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: var(--font-size-standard) !important;
}

body h2,
body.auth-page .auth-card h3 {
    font-size: var(--font-size-page-title) !important;
    line-height: 1.3;
}

.bi,
.bi::before {
    font-family: "bootstrap-icons" !important;
}

button,
.btn,
input,
select,
textarea,
.form-control,
.form-select,
.input-group-text,
.badge,
table,
.small,
small {
    font-size: var(--font-size-standard) !important;
}

/* ---------- Dashboard: KPI cards (success / warning / danger only) ---------- */

.kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
    height: 100%;
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    margin-bottom: 10px;
}

.kpi-success { background: var(--success-light); color: var(--success); }
.kpi-warning { background: var(--warning-light); color: var(--warning); }
.kpi-danger  { background: var(--danger-light); color: var(--danger); }

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-body);
}

.kpi-label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ---------- Dashboard: Quick Action buttons (success / warning / danger only) ---------- */

.qa-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 13px;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    height: 100%;
    min-height: 78px;
    justify-content: center;
    transition: transform .12s ease, box-shadow .12s ease;
}

.qa-btn i {
    font-size: 18px;
}

.qa-btn:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(16, 24, 55, 0.18);
}

.qa-success { background: var(--success); }
.qa-warning { background: var(--warning); }
.qa-danger  { background: var(--danger); }

/* ---------- Dashboard: status rows ---------- */

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    font-size: 13.5px;
    color: var(--text-body);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Dashboard: dense viewport layout with Recent Designs as the overflow region. */
.dashboard-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-page .form-card {
    width: 100%;
    max-width: none;
}

.dashboard-kpis .kpi-card {
    position: relative;
    min-height: 76px;
    padding: 12px 12px 12px 58px;
}

.dashboard-kpis .kpi-icon {
    position: absolute;
    top: 12px;
    left: 12px;
    margin: 0;
}

.dashboard-kpis .kpi-value {
    font-size: 20px;
}

.dashboard-main-row .form-card {
    padding: 13px 15px;
}

.dashboard-main-row .section-label {
    margin-bottom: 7px;
}

.dashboard-main-row .qa-btn {
    min-height: 60px;
    padding: 9px 11px;
    gap: 4px;
}

.dashboard-main-row .status-row {
    padding: 4px 0;
}

.dashboard-main-row hr {
    margin: 6px 0;
}

.dashboard-recent-card {
    flex: 1 1 auto;
    min-height: 130px;
    padding: 13px 15px;
    overflow: auto;
    overscroll-behavior: contain;
}

.dashboard-recent-card > .d-flex {
    position: sticky;
    top: -13px;
    z-index: 3;
    margin: -13px -15px 8px;
    padding: 11px 15px 8px;
    background: #fff;
}

.dashboard-recent-card .table thead {
    position: sticky;
    top: 35px;
    z-index: 2;
}

@media (min-width: 992px) {
    .content:has(.dashboard-page) {
        overflow-y: hidden;
    }

    .dashboard-page {
        height: 100%;
        overflow: hidden;
    }
}

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1055;
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 20, 35, 0.45);
        z-index: 1050;
        display: none;
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 10px 16px;
    }

    .form-card {
        padding: 16px;
        max-width: 100%;
    }
}

@media (max-width: 575.98px) {
    .content {
        padding: 12px;
    }

    .kpi-value {
        font-size: 19px;
    }

    .user-chip-text {
        display: none;
    }
}

/* Avoid horizontal scroll on the page itself; tables scroll within their own wrapper */
.main-area, .content {
    min-width: 0;
}
