/* Masiha ERP 7 — shared visual system */
:root {
    --app-font: "Vazir", sans-serif;
    --fs-body: 14px;
    --fs-h1: 28px;
    --fs-h2: 24px;
    --fs-h3: 20px;
    --fs-h4: 18px;
    --fs-h5: 16px;
    --fs-h6: 14px;
    --fs-label: 13px;
    --fs-input: 14px;
    --fs-button: 13px;
    --fs-table: 13px;
    --fs-small: 12px;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-ink: #172033;
    --color-muted: #64748b;
    --color-line: #dbe4f0;
    --color-canvas: #f3f6fb;
    --color-surface: #ffffff;
    --radius-field: 12px;
    --radius-card: 20px;
    --shadow-card: 0 10px 35px rgba(15, 23, 42, 0.055);
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body,
jdp-container,
input,
button,
select,
textarea,
.jdp-container * {
    font-family: var(--app-font) !important;
}

body.app-body {
    background: var(--color-canvas) !important;
    color: var(--color-ink);
    font-size: var(--fs-body) !important;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

.app-main {
    background:
        radial-gradient(circle at 8% 0%, rgba(37, 99, 235, 0.055), transparent 25rem),
        var(--color-canvas) !important;
    scrollbar-gutter: stable;
}

.app-main h1 { font-size: var(--fs-h1) !important; line-height: 1.35; }
.app-main h2 { font-size: var(--fs-h2) !important; line-height: 1.4; }
.app-main h3 { font-size: var(--fs-h3) !important; line-height: 1.45; }
.app-main h4 { font-size: var(--fs-h4) !important; line-height: 1.5; }
.app-main h5 { font-size: var(--fs-h5) !important; line-height: 1.55; }
.app-main h6 { font-size: var(--fs-h6) !important; line-height: 1.6; }
.app-main p,
.app-main li { font-size: var(--fs-body); }
.app-main small,
.app-main .ui-caption { font-size: var(--fs-small) !important; }
.app-main :is(p, span, div, a)[class~="text-[8px]"],
.app-main :is(p, span, div, a)[class~="text-[9px]"],
.app-main :is(p, span, div, a)[class~="text-[10px]"] { font-size: var(--fs-small) !important; }
.app-main :is(p, span, div, a)[class~="text-[11px]"],
.app-main :is(p, span, div, a)[class~="text-[12px]"] { font-size: var(--fs-body) !important; }
.app-main label,
.app-main label > span,
.app-main label :is(span, p)[class*="text-"] { font-size: var(--fs-label) !important; }
.app-main table td { font-size: var(--fs-table) !important; }
.app-main table th { font-size: var(--fs-label) !important; }

button,
a { -webkit-tap-highlight-color: transparent; }
button,
a,
input,
select,
textarea { transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease, color .18s ease, transform .18s ease; }

.app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]),
.app-main textarea,
.app-main select {
    min-height: 44px;
    background: #fff !important;
    border: 1px solid var(--color-line) !important;
    border-radius: var(--radius-field) !important;
    color: var(--color-ink) !important;
    font-size: var(--fs-input) !important;
    line-height: 1.45;
    outline: none !important;
}

.app-main textarea { min-height: 104px; resize: vertical; }
.app-main input::placeholder,
.app-main textarea::placeholder { color: #94a3b8; opacity: 1; }
.app-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
.app-main textarea:focus,
.app-main select:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .11) !important;
}
.app-main input:disabled,
.app-main textarea:disabled,
.app-main select:disabled {
    background: #f1f5f9 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
}
.app-main input[type="checkbox"],
.app-main input[type="radio"] {
    accent-color: var(--color-primary);
    width: 18px;
    height: 18px;
}
.app-main input[type="file"] {
    padding: 7px !important;
    color: var(--color-muted) !important;
}
.app-main input[type="file"]::file-selector-button {
    border: 0;
    border-radius: 9px;
    background: #eaf1ff;
    color: #1d4ed8;
    padding: 8px 12px;
    margin-left: 10px;
    font-weight: 800;
    cursor: pointer;
}

.app-main button,
.app-main a[class*="bg-"] {
    font-size: var(--fs-button) !important;
    letter-spacing: -.01em;
}
.app-main button:not(:disabled):active,
.app-main a[class*="bg-"]:active { transform: translateY(1px); }
.app-main button:focus-visible,
.app-main a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .28);
    outline-offset: 2px;
}

.app-main [class~="bg-white"][class*="rounded"],
.app-card {
    border-color: #e2e8f0 !important;
    box-shadow: var(--shadow-card) !important;
}
.app-main [class~="rounded-[2.5rem]"],
.app-main [class~="rounded-[3rem]"] { border-radius: var(--radius-card) !important; }

.app-main table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.app-main table thead th {
    background: #f7f9fc;
    color: #475569;
    font-weight: 900;
    white-space: nowrap;
}
.app-main table tbody tr:hover { background: #f8fbff; }
.app-main table td,
.app-main table th { border-color: #e5eaf2 !important; }

.app-header {
    height: 68px !important;
    background: rgba(255, 255, 255, .94) !important;
    border-color: #e5eaf2 !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, .035) !important;
    backdrop-filter: blur(14px);
}

.app-sidebar {
    background: linear-gradient(180deg, #17233a 0%, #0b1325 100%) !important;
    border-left: 1px solid rgba(148, 163, 184, .12);
}
.app-sidebar > div:first-child { background: rgba(255, 255, 255, .035) !important; }
.app-sidebar nav a {
    min-height: 35px;
    border-radius: 10px !important;
    font-size: var(--fs-small) !important;
    font-weight: 700;
    opacity: .92;
}
.app-sidebar nav a:hover {
    background: rgba(255, 255, 255, .075) !important;
    opacity: 1;
    transform: translateX(-2px);
}
.app-sidebar nav a.is-active {
    background: rgba(37, 99, 235, .18) !important;
    box-shadow: inset -3px 0 0 #60a5fa;
    color: #fff !important;
    opacity: 1;
}
.app-sidebar nav > div[class*="uppercase"] {
    font-size: calc(var(--fs-small) - 1px) !important;
    letter-spacing: .02em;
    color: #71809c !important;
}

.custom-scrollbar::-webkit-scrollbar,
.app-main::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track,
.app-main::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb,
.app-main::-webkit-scrollbar-thumb { background: #b6c2d2; border-radius: 999px; }
.app-sidebar .custom-scrollbar::-webkit-scrollbar-thumb { background: #34435e; }

.sidebar-direct-link,
.sidebar-menu > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    min-height: 2.65rem;
    padding: .65rem .85rem;
    border-radius: .8rem;
    color: #d7dfeb;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}
.sidebar-direct-link { justify-content: flex-start; }
.sidebar-menu > summary::-webkit-details-marker { display: none; }
.sidebar-menu > summary::marker { content: ''; }
.sidebar-menu > summary span { display: flex; align-items: center; gap: .7rem; }
.sidebar-direct-link:hover,
.sidebar-menu > summary:hover,
.sidebar-menu[open] > summary { background: rgba(51, 65, 85, .72); color: #fff; }
.submenu-chevron { font-size: .62rem; transition: transform .2s ease; color: #64748b; }
.sidebar-menu[open] .submenu-chevron { transform: rotate(180deg); }
.sidebar-submenu {
    display: grid;
    gap: .15rem;
    margin: .25rem .85rem .55rem 0;
    padding-right: .6rem;
    border-right: 1px solid rgba(100, 116, 139, .35);
}
.sidebar-submenu a {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: 2.15rem;
    padding: .45rem .7rem;
    border-radius: .65rem;
    color: #b8c3d4;
    font-size: .7rem;
    font-weight: 750;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-submenu a:hover { background: rgba(30, 41, 59, .9); color: #fff; transform: translateX(-2px); }
.sidebar-submenu a.is-active,
.sidebar-direct-link.is-active { background: linear-gradient(90deg, #1d4ed8, #2563eb); color: #fff; box-shadow: 0 7px 18px rgba(37, 99, 235, .25); }

.smart-search-option:hover,
.smart-search-option.is-active {
    background: #eff6ff;
    box-shadow: inset -3px 0 0 #2563eb;
}

.live-result-active {
    background: #eff6ff !important;
    outline: 2px solid rgba(37, 99, 235, .35);
    outline-offset: -2px;
}

jdp-container { z-index: 999999 !important; }
.en-mode {
    direction: ltr !important;
    text-align: left !important;
    font-family: sans-serif !important;
}
.en-mode aside { order: 0; }

/* Order document controls */
.order-hero { padding: 24px; border-radius: var(--radius-card); background: #fff; }
.order-document-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #e7ecf3;
}
.order-document-card {
    position: relative;
    min-width: 0;
    border: 1px solid #e1e8f2;
    border-radius: 14px;
    background: #f9fbfe;
    padding: 9px;
}
.order-document-upload {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 11px;
    cursor: pointer;
    color: #334155;
    font-weight: 900;
}
.order-document-upload:hover { background: #eef4ff; color: #1d4ed8; }
.order-document-upload > i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #dbeafe; color: #2563eb; }
.order-document-upload small { display: block; color: #94a3b8; font-weight: 700; }
.order-document-card details { border-top: 1px solid #e7ecf3; padding-top: 7px; margin-top: 4px; }
.order-document-card summary { cursor: pointer; color: #64748b; font-size: var(--fs-small); font-weight: 800; }
.order-document-list { max-height: 160px; overflow: auto; margin-top: 7px; display: grid; gap: 6px; }
.order-document-row { display: flex; align-items: center; gap: 6px; padding: 7px; border-radius: 9px; background: #fff; border: 1px solid #e6ebf2; }
.order-document-row > a { min-width: 0; flex: 1; color: #2563eb; text-decoration: none; }
.order-document-row .document-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.order-document-row .document-meta { display: block; color: #94a3b8; font-size: var(--fs-small); }
.order-document-delete { color: #dc2626; width: 30px; height: 30px; border-radius: 8px; background: #fff1f2; flex: 0 0 auto; }

/* Order 2 and execution checklist */
.order2-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    color: #6d28d9;
    background: #f5f3ff;
    font-size: var(--fs-small);
    font-weight: 900;
    white-space: nowrap;
}
.checklist-open-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border: 1px solid #c4b5fd;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    box-shadow: 0 8px 20px rgba(109, 40, 217, .2);
    font-weight: 900;
    transition: .2s ease;
}
.checklist-open-button:hover { transform: translateY(-1px); box-shadow: 0 11px 25px rgba(109, 40, 217, .28); }
.checklist-open-button > span { margin-right: 5px; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-family: monospace; font-size: 10px; }
body.checklist-modal-open { overflow: hidden; }
.checklist-modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(7, 15, 31, .76);
    backdrop-filter: blur(8px);
}
.checklist-modal.hidden { display: none; }
.checklist-dialog {
    width: min(1180px, calc(100vw - 48px));
    max-width: 100%;
    max-height: min(720px, 92vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 34px 100px rgba(2, 8, 23, .42);
}
.checklist-dialog > * { min-width: 0; }
.checklist-header,
.checklist-summary,
.checklist-footer { flex: 0 0 auto; }
.checklist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid #e4eaf2;
    background: linear-gradient(135deg, #f8faff, #f5f3ff);
}
.checklist-header-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #fff; background: linear-gradient(135deg, #7c3aed, #4f46e5); box-shadow: 0 8px 18px rgba(109, 40, 217, .2); }
.checklist-header h2 { margin: 0 0 3px; color: #172033; font-size: var(--fs-h3); font-weight: 950; }
.checklist-header p { margin: 0; color: #64748b; font-size: var(--fs-small); font-weight: 700; }
.checklist-close { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #e2e8f0; border-radius: 10px; color: #64748b; background: #fff; cursor: pointer; }
.checklist-close:hover { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
.checklist-summary { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #e5eaf2; background: #fff; }
.checklist-progress-card,
.checklist-purchase-total { padding: 8px 10px; border: 1px solid #e4eaf2; border-radius: 11px; background: #fafcff; color: #475569; font-size: var(--fs-small); font-weight: 800; }
.checklist-progress-card strong { color: #6d28d9; font-size: 13px; }
.checklist-progress-card small { display: block; margin-top: 2px; color: #94a3b8; }
.checklist-progress-track { height: 5px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: #ede9fe; }
.checklist-progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8b5cf6, #4f46e5); }
.checklist-purchase-total { display: flex; align-items: center; gap: 11px; }
.checklist-purchase-total > i { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #047857; background: #d1fae5; }
.checklist-purchase-total > span { display: grid; gap: 2px; }
.checklist-purchase-total small { color: #94a3b8; font-weight: 700; }
.checklist-purchase-total strong { margin-right: auto; color: #047857; font-family: monospace; font-size: 12px; white-space: nowrap; }
.checklist-items {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-gutter: stable;
    background: #f5f7fb;
}
.checklist-items * { min-width: 0; }
.checklist-item-card {
    overflow: hidden;
    border: 1px solid #dfe6f0;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .045);
}
.checklist-item-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border-bottom: 1px solid #e5eaf2;
    background: linear-gradient(135deg, #f8faff, #f4f1ff);
}
.checklist-item-number {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: #fff;
    background: #6d28d9;
    box-shadow: 0 6px 16px rgba(109, 40, 217, .2);
    font-weight: 900;
}
.checklist-item-header h3 {
    margin: 0;
    color: #172033;
    overflow-wrap: anywhere;
    font-size: var(--fs-label) !important;
    font-weight: 950;
}
.checklist-item-header p { display: flex; flex-wrap: wrap; gap: 3px 12px; margin: 1px 0 0; color: #64748b; font-size: var(--fs-small) !important; font-weight: 700; }
.checklist-stage-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 8px; }
.checklist-stage-card {
    min-height: 128px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 7px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fbfcfe;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.checklist-stage-card:hover { border-color: #cbd5e1; box-shadow: 0 8px 20px rgba(15, 23, 42, .055); transform: translateY(-1px); }
.checklist-stage-card.is-complete { border-color: #a7f3d0; background: #f5fdf9; }
.checklist-stock-card.is-pending { border-color: #fde68a; background: #fffdf5; }
.checklist-stage-card.is-purchase-stage { grid-column: auto; }
.checklist-stage-title { display: flex; align-items: center; gap: 5px; min-height: 24px; padding-bottom: 5px; border-bottom: 1px solid rgba(148, 163, 184, .18); color: #334155; }
.checklist-stage-title > i { width: 22px; height: 22px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: #6d28d9; background: #ede9fe; }
.checklist-stage-title > span { overflow-wrap: anywhere; font-size: var(--fs-small); font-weight: 900; }
.checklist-stage-title > small { margin-right: auto; color: #94a3b8; font-size: calc(var(--fs-small) - 1px); font-weight: 800; white-space: nowrap; }
.checklist-stock-state,
.checklist-readonly { min-height: 54px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px; border: 0; border-radius: 8px; color: #64748b; background: transparent; }
.checklist-stock-state > i,
.checklist-readonly > i { font-size: 18px; }
.checklist-stock-state strong,
.checklist-readonly strong { font-size: var(--fs-small); font-weight: 900; }
.checklist-stock-state small,
.checklist-readonly small { color: #94a3b8; font-size: calc(var(--fs-small) - 1px); font-weight: 700; }
.checklist-stock-state.is-complete,
.checklist-readonly.is-complete { color: #047857; }
.checklist-stock-state.is-pending { color: #b45309; }
.checklist-readonly > span { max-width: 100%; margin-top: 4px; color: #475569; overflow-wrap: anywhere; text-align: center; font-family: monospace; font-size: var(--fs-small); line-height: 1.6; }
.checklist-stage-form { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.checklist-toggle { display: flex; align-items: center; justify-content: flex-start; gap: 8px; cursor: pointer; }
.checklist-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.checklist-toggle > span { width: 25px; height: 25px; display: grid; place-items: center; border: 2px solid #cbd5e1; border-radius: 7px; color: transparent; background: #fff; transition: .18s ease; }
.checklist-toggle input:focus-visible + span { outline: 3px solid rgba(124, 58, 237, .2); outline-offset: 2px; }
.checklist-toggle input:checked + span { color: #fff; border-color: #059669; background: #059669; }
.checklist-toggle b { color: #64748b; font-size: var(--fs-small); font-weight: 900; }
.checklist-purchase-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }
.checklist-purchase-fields label { color: #64748b; text-align: right; font-size: calc(var(--fs-small) - 1px); font-weight: 800; }
.checklist-purchase-fields input { width: 100%; max-width: 100%; min-height: 28px !important; margin-top: 1px; padding: 3px 4px !important; border: 1px solid #dbe4f0 !important; border-radius: 7px !important; text-align: center; font-family: monospace; font-size: var(--fs-small) !important; }
.checklist-save { width: 100%; min-height: 28px; margin-top: auto; border: 1px solid #ddd6fe; border-radius: 7px; color: #6d28d9; background: #f5f3ff; font-size: var(--fs-small) !important; font-weight: 900; cursor: pointer; }
.checklist-save:hover { color: #fff; border-color: #7c3aed; background: #7c3aed; }
.checklist-empty { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 30px; border: 1px dashed #cbd5e1; border-radius: 16px; color: #94a3b8; background: #fff; font-weight: 800; }
.checklist-empty > i { font-size: 28px; }
.checklist-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid #e4eaf2; background: #fff; }
.checklist-footer p { margin: 0; color: #64748b; font-size: var(--fs-small); font-weight: 700; }
.checklist-footer p i { margin-left: 5px; color: #2563eb; }
.checklist-footer button { min-width: 88px; min-height: 32px; border: 0; border-radius: 8px; color: #fff; background: #172033; font-weight: 900; cursor: pointer; }

/* Appearance settings */
.typography-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.typography-field { padding: 12px; border: 1px solid #e4eaf2; border-radius: 14px; background: #fafcff; }
.typography-field input { text-align: center; font-weight: 900; }
.font-preview { border: 1px dashed #bfdbfe; border-radius: 14px; background: #eff6ff; padding: 16px; color: #1e3a8a; }

/* Login and first-run setup */
.auth-page,
.setup-page {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    padding: 20px;
    background: linear-gradient(145deg, #0b1325 0%, #16243e 52%, #0b1730 100%);
    font-family: var(--app-font) !important;
    font-size: var(--fs-body);
}
.auth-glow { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(10px); opacity: .24; pointer-events: none; }
.auth-glow-one { top: -180px; right: -100px; background: #2563eb; }
.auth-glow-two { bottom: -220px; left: -80px; background: #7c3aed; }
.auth-card,
.setup-card {
    position: relative;
    z-index: 1;
    width: min(100%, 440px);
    padding: 36px;
    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(255, 255, 255, .65);
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(2, 8, 23, .35);
}
.auth-logo { max-width: 180px; max-height: 64px; object-fit: contain; }
.auth-field { display: block; position: relative; }
.auth-field > span { display: block; margin: 0 3px 7px; color: #475569; font-size: var(--fs-label); font-weight: 800; }
.auth-field > i { position: absolute; right: 15px; bottom: 16px; color: #94a3b8; pointer-events: none; }
.auth-field input {
    width: 100%;
    min-height: 50px;
    padding: 12px 44px 12px 44px;
    border: 1px solid #dbe4f0;
    border-radius: 13px;
    outline: none;
    color: #172033;
    background: #f9fbfe;
    font-size: var(--fs-input);
}
.auth-field input:focus { background: #fff; border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.password-toggle { position: absolute; left: 8px; bottom: 8px; width: 34px; height: 34px; border: 0; background: transparent; color: #64748b; cursor: pointer; border-radius: 9px; }
.password-toggle:hover { background: #eaf1ff; color: #2563eb; }
.auth-submit {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 12px 28px rgba(37, 99, 235, .22);
    font-size: var(--fs-button);
    font-weight: 900;
    cursor: pointer;
}
.auth-submit:hover { box-shadow: 0 15px 34px rgba(37, 99, 235, .3); transform: translateY(-1px); }
.auth-footnote { margin: 24px 0 0; text-align: center; color: #94a3b8; font-size: var(--fs-small); }

.setup-page { overflow-y: auto; }
.setup-card { width: min(100%, 560px); }
.setup-heading { text-align: center; margin-bottom: 24px; }
.setup-heading h2 { margin: 10px 0 2px; color: #172033; font-size: 24px; }
.setup-heading p { margin: 0; color: #64748b; font-size: 13px; }
.setup-icon { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; color: #fff; background: linear-gradient(135deg, #2563eb, #4f46e5); box-shadow: 0 10px 25px rgba(37, 99, 235, .23); }
.setup-card input,
.setup-card textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    margin: 7px 0;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    outline: none;
    color: #172033;
    background: #f9fbfe;
    font-size: 13px;
}
.setup-card input:focus,
.setup-card textarea:focus { border-color: #60a5fa; background: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.setup-card textarea { min-height: 118px; font-family: monospace !important; direction: ltr; text-align: left; resize: vertical; }
.setup-card button { width: 100%; min-height: 50px; margin-top: 14px; border: 0; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #059669, #047857); font-weight: 900; font-size: 14px; cursor: pointer; }
.setup-card button:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(5, 150, 105, .2); }
.hwid-label,
.field-label { display: block; margin: 12px 2px 2px; color: #475569; font-size: 12px; font-weight: 800; }
.hwid-box { padding: 11px; margin: 7px 0 14px; border: 1px dashed #93c5fd; border-radius: 12px; direction: ltr; text-align: center; background: #eff6ff; color: #1e3a8a; font-family: monospace !important; font-size: 13px; font-weight: 900; letter-spacing: .06em; overflow-wrap: anywhere; }
.error-box { padding: 12px 14px; margin-bottom: 16px; border: 1px solid #fecaca; border-radius: 12px; background: #fff1f2; color: #be123c; font-size: 12px; font-weight: 800; line-height: 1.7; }

@media (max-width: 1024px) {
    .order-document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .typography-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .checklist-stage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .checklist-stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .app-main { padding: 14px !important; }
    .app-header { height: 62px !important; padding-inline: 12px !important; }
    .order-hero { padding: 16px; }
    .order-document-grid { grid-template-columns: 1fr; }
    .typography-grid { grid-template-columns: 1fr; }
    .app-main [class*="p-8"] { padding: 18px !important; }
    .app-main [class*="gap-8"] { gap: 16px !important; }
    .app-main table td,
    .app-main table th { padding: 10px !important; }
    .auth-card,
    .setup-card { padding: 24px 20px; border-radius: 20px; }
    .checklist-modal {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        padding: 6px;
        overflow: hidden;
        place-items: stretch;
    }
    .checklist-dialog {
        width: 100%;
        height: calc(100vh - 12px);
        height: calc(100dvh - 12px);
        max-width: none;
        max-height: none;
        min-height: 0;
        display: grid;
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, .8);
        border-radius: 16px;
    }
    .checklist-header { gap: 7px; padding: 9px 10px; }
    .checklist-header-icon { width: 32px; height: 32px; border-radius: 9px; }
    .checklist-header h2 { font-size: 15px !important; line-height: 1.45; }
    .checklist-header p { display: none; }
    .checklist-close { width: 32px; height: 32px; }
    .checklist-summary { gap: 6px; padding: 6px; }
    .checklist-progress-card,
    .checklist-purchase-total { padding: 7px 8px; }
    .checklist-purchase-total { align-items: flex-start; flex-wrap: wrap; }
    .checklist-purchase-total strong { width: 100%; margin-right: 49px; }
    .checklist-items {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: none;
        gap: 7px;
        padding: 7px 7px max(14px, env(safe-area-inset-bottom));
        overflow-x: hidden;
        overflow-y: scroll;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    .checklist-item-card { border-radius: 12px; }
    .checklist-item-header { padding: 7px 9px; }
    .checklist-item-number { width: 27px; height: 27px; border-radius: 8px; }
    .checklist-item-header p { gap: 3px 10px; }
    .checklist-item-header p span { width: 100%; }
    .checklist-stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px; }
    .checklist-stage-card,
    .checklist-stage-card.is-purchase-stage { grid-column: auto; min-height: 108px; padding: 7px; }
    .checklist-stock-state,
    .checklist-readonly { min-height: 60px; }
    .checklist-stage-form { gap: 5px; }
    .checklist-purchase-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .checklist-footer { position: relative; z-index: 3; padding: 7px 9px max(7px, env(safe-area-inset-bottom)); box-shadow: 0 -5px 16px rgba(15, 23, 42, .07); }
    .checklist-footer p { display: none; }
    .checklist-footer button { width: 100%; }
}
@media (max-width: 430px) {
    .checklist-summary { grid-template-columns: minmax(0, 1fr); }
    .checklist-stage-grid { grid-template-columns: minmax(0, 1fr); }
    .checklist-stage-card,
    .checklist-stage-card.is-purchase-stage { min-height: 96px; }
}
@media (max-width: 380px) {
    .checklist-header h2 { font-size: 14px !important; }
    .checklist-header-icon { display: none; }
    .checklist-purchase-fields { grid-template-columns: minmax(0, 1fr); }
    .checklist-purchase-total strong { margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Granular permission manager ------------------------------------------------ */
body.modal-open { overflow: hidden !important; }
.permission-launch-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid #dbe5f2;
    border-radius: 22px;
    background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}
.permission-launch-icon {
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #6d28d9);
    box-shadow: 0 10px 24px rgba(79,70,229,.25);
}
.permission-count-badge {
    padding: 4px 9px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 10px;
    font-weight: 900;
    white-space: nowrap;
}
.permission-summary-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; margin-top: 10px; }
.permission-summary-chips span {
    padding: 4px 8px;
    border-radius: 8px;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-size: 9px;
    font-weight: 900;
}
.permission-summary-chips .is-admin { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.permission-summary-chips .is-guest { color: #334155; background: #e2e8f0; }
.permission-summary-chips .is-empty { color: #94a3b8; font-weight: 700; }
.permission-launch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    flex: 0 0 auto;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    color: #fff;
    background: #172554;
    font-size: 11px;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(15,23,42,.16);
    transition: transform .18s ease, background-color .18s ease;
}
.permission-launch-button:hover { background: #1d4ed8; transform: translateY(-1px); }

.permissions-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    place-items: center;
    padding: 18px;
    background: rgba(8,15,30,.82);
    backdrop-filter: blur(10px);
}
.permissions-dialog {
    display: grid;
    grid-template-rows: auto auto minmax(0,1fr) auto;
    width: min(1280px, 96vw);
    height: min(860px, 91dvh);
    min-height: 580px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.72);
    border-radius: 28px;
    background: #f8fafc;
    box-shadow: 0 30px 90px rgba(2,6,23,.42);
}
.permissions-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
.permissions-title-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg,#2563eb,#7c3aed);
    box-shadow: 0 9px 22px rgba(79,70,229,.24);
}
.permissions-header h2 { color: #0f172a; font-size: 20px !important; font-weight: 950; }
.permissions-header p { margin-top: 3px; color: #64748b; font-size: 10px; font-weight: 700; }
.permissions-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    background: #f8fafc;
}
.permissions-close:hover { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.permissions-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
.permissions-search {
    display: flex;
    align-items: center;
    gap: 9px;
    width: min(440px,100%);
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid #dbe5f2;
    border-radius: 13px;
    color: #64748b;
    background: #f8fafc;
}
.permissions-search:focus-within { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); background: #fff; }
.permissions-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #0f172a; font-size: 11px; font-weight: 800; }
.permissions-search kbd { padding: 2px 7px; border: 1px solid #cbd5e1; border-radius: 6px; color: #94a3b8; background: #fff; font: 10px sans-serif; }
.permissions-toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.permissions-toolbar-actions button {
    min-height: 35px;
    padding: 0 11px;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 9px;
    font-weight: 900;
}
.permissions-toolbar-actions button:hover { color: #fff; background: #2563eb; }
.permissions-toolbar-actions button.is-danger { color: #b91c1c; border-color: #fee2e2; background: #fef2f2; }
.permissions-toolbar-actions button.is-danger:hover { color: #fff; background: #dc2626; }
.permissions-toolbar-actions.is-readonly { pointer-events: none; opacity: .4; }

.permissions-body { display: grid; grid-template-columns: 232px minmax(0,1fr); min-height: 0; }
.permission-category-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    border-left: 1px solid #e2e8f0;
    background: #f1f5f9;
}
.permission-nav-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #475569;
    text-align: right;
    font-size: 10px;
    font-weight: 900;
    transition: all .15s ease;
}
.permission-nav-button b { min-width: 36px; padding: 3px 6px; border-radius: 999px; color: #64748b; background: #e2e8f0; text-align: center; font-size: 8px; }
.permission-nav-button:hover { color: #1d4ed8; background: #fff; }
.permission-nav-button.is-active { color: #fff; border-color: #2563eb; background: linear-gradient(135deg,#1d4ed8,#4f46e5); box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.permission-nav-button.is-active b { color: #1d4ed8; background: #fff; }
.permission-panels { min-width: 0; min-height: 0; overflow-y: auto; padding: 14px 18px 20px; }
.permission-role-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 13px; }
.permission-role-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 62px;
    padding: 10px 13px;
    border: 1px solid #dbe5f2;
    border-radius: 14px;
    cursor: pointer;
    background: #fff;
}
.permission-role-card input { width: 18px; height: 18px; accent-color: #2563eb; }
.permission-role-card span { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; }
.permission-role-card i { grid-row: 1 / 3; color: #64748b; }
.permission-role-card b { color: #1e293b; font-size: 10px; }
.permission-role-card small { color: #94a3b8; font-size: 8px; font-weight: 700; }
.permission-role-card.is-guest:has(input:checked) { border-color: #64748b; background: #f1f5f9; }
.permission-role-card.is-admin:has(input:checked) { border-color: #fca5a5; background: #fef2f2; }
.permission-role-card.is-admin:has(input:checked) i,
.permission-role-card.is-admin:has(input:checked) b { color: #b91c1c; }
.permission-role-row.is-readonly .permission-role-card { pointer-events: none; opacity: .72; }
.permission-readonly-notice { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #fde68a; border-radius: 12px; color: #92400e; background: #fffbeb; font-size: 9px; font-weight: 900; }
.permission-panel { display: none; }
.permission-panel.is-active { display: block; }
.permissions-modal.is-searching .permission-panel { display: none; margin-bottom: 18px; }
.permissions-modal.is-searching .permission-panel.is-search-match { display: block; }
.permission-panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.permission-panel-heading div span { display: block; margin-bottom: 2px; color: #94a3b8; font-size: 8px; font-weight: 800; }
.permission-panel-heading h3 { color: #0f172a; font-size: 17px !important; font-weight: 950; }
.permission-panel-heading > span { padding: 4px 9px; border-radius: 8px; color: #475569; background: #e2e8f0; font-size: 8px; font-weight: 900; }
.permission-option-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.permission-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 10px 11px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 13px;
    cursor: pointer;
    background: #fff;
    transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.permission-option:hover { border-color: #93c5fd; transform: translateY(-1px); }
.permission-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.permission-option-check {
    display: grid;
    place-items: center;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    border: 2px solid #cbd5e1;
    border-radius: 9px;
    color: transparent;
    background: #fff;
}
.permission-option b { display: block; overflow: hidden; color: #334155; font-size: 9px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.permission-option small { display: block; margin-top: 3px; overflow: hidden; color: #94a3b8; font: 7px/1.3 monospace; direction: ltr; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.permission-option:has(input:checked) { border-color: #93c5fd; background: #eff6ff; box-shadow: inset 0 0 0 1px rgba(59,130,246,.08); }
.permission-option:has(input:checked) .permission-option-check { color: #fff; border-color: #2563eb; background: #2563eb; }
.permission-panel.is-readonly .permission-option { pointer-events: none; opacity: .76; }
.permission-filter-hidden { display: none !important; }
.permission-empty-state { padding: 50px 20px; color: #94a3b8; text-align: center; font-size: 11px; font-weight: 900; }
.permission-empty-state i { display: block; margin-bottom: 10px; font-size: 28px; }
.permissions-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 -6px 22px rgba(15,23,42,.04);
}
.permissions-footer div { display: flex; flex-direction: column; gap: 2px; }
.permissions-footer strong { color: #1d4ed8; font-size: 10px; }
.permissions-footer span { color: #94a3b8; font-size: 8px; font-weight: 700; }
.permissions-footer button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 170px; min-height: 42px; padding: 0 18px; border-radius: 12px; color: #fff; background: #172554; font-size: 10px; font-weight: 900; }
.permissions-footer button:hover { background: #1d4ed8; }

@media (max-width: 960px) {
    .permissions-dialog { width: 97vw; height: 94dvh; }
    .permissions-body { grid-template-columns: 190px minmax(0,1fr); }
    .permission-option-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
    .permission-launch-card { align-items: flex-start; flex-wrap: wrap; padding: 14px; }
    .permission-launch-icon { width: 42px; height: 42px; flex-basis: 42px; }
    .permission-launch-button { width: 100%; }
    .permissions-modal { padding: 0; place-items: stretch; }
    .permissions-dialog { width: 100vw; height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
    .permissions-header { padding: 10px 12px; }
    .permissions-title-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; }
    .permissions-header h2 { font-size: 15px !important; }
    .permissions-header p { display: none; }
    .permissions-close { width: 36px; height: 36px; }
    .permissions-toolbar { align-items: stretch; flex-direction: column; padding: 8px 10px; }
    .permissions-search { width: 100%; min-height: 38px; }
    .permissions-toolbar-actions { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
    .permissions-toolbar-actions button { min-height: 32px; padding: 0 5px; font-size: 7px; }
    .permissions-toolbar-actions button i { display: none; }
    .permissions-body { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); }
    .permission-category-nav { flex-direction: row; gap: 5px; overflow-x: auto; overflow-y: hidden; padding: 7px 9px; border-bottom: 1px solid #e2e8f0; border-left: 0; scroll-snap-type: x proximity; }
    .permission-nav-button { min-width: 132px; min-height: 35px; padding: 0 9px; scroll-snap-align: start; }
    .permission-panels { padding: 9px 10px 16px; }
    .permission-role-row { grid-template-columns: minmax(0,1fr); gap: 6px; margin-bottom: 9px; }
    .permission-role-card { min-height: 52px; padding: 7px 10px; }
    .permission-panel-heading { margin-bottom: 8px; }
    .permission-panel-heading h3 { font-size: 14px !important; }
    .permission-option-grid { grid-template-columns: minmax(0,1fr); gap: 6px; }
    .permission-option { min-height: 54px; padding: 7px 9px; }
    .permission-option b { font-size: 9px; }
    .permission-option small { font-size: 6px; }
    .permissions-footer { padding: 8px 10px max(8px,env(safe-area-inset-bottom)); }
    .permissions-footer span { display: none; }
    .permissions-footer button { min-width: 140px; min-height: 38px; padding: 0 12px; }
}
@media (max-width: 390px) {
    .permissions-toolbar-actions { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .permissions-footer div { display: none; }
    .permissions-footer button { width: 100%; }
}
