:root {
    color-scheme: light;
    --ms-bg: #edf2f8;
    --ms-bg-deep: #e5ebf3;
    --ms-panel: #eef3f9;
    --ms-panel-strong: #f8fafc;
    --ms-panel-soft: #e7edf5;
    --ms-text: #172033;
    --ms-text-2: #344054;
    --ms-muted: #667085;
    --ms-line: #d7dfe9;
    --ms-line-strong: #c5cfdd;
    --ms-primary: #e66a16;
    --ms-primary-hover: #cb5709;
    --ms-primary-soft: #fff0e4;
    --ms-primary-line: #f1b483;
    --ms-success: #17734a;
    --ms-success-soft: #e7f5ed;
    --ms-success-line: #add9c1;
    --ms-warning: #96600e;
    --ms-warning-soft: #fff3da;
    --ms-warning-line: #edcf97;
    --ms-danger: #b93833;
    --ms-danger-soft: #fdeceb;
    --ms-danger-line: #efb7b4;
    --ms-info: #285bc5;
    --ms-info-soft: #eaf0ff;
    --ms-sidebar: #e9eff6;
    --ms-sidebar-text: #27364e;
    --ms-shadow-high: 10px 10px 24px rgba(139, 153, 174, .27), -10px -10px 24px rgba(255, 255, 255, .90), inset 1px 1px 0 rgba(255, 255, 255, .7);
    --ms-shadow-mid: 5px 5px 13px rgba(139, 153, 174, .22), -5px -5px 13px rgba(255, 255, 255, .80), inset 1px 1px 0 rgba(255, 255, 255, .65);
    --ms-shadow-low: 2px 2px 7px rgba(139, 153, 174, .16), -2px -2px 7px rgba(255, 255, 255, .70);
    --ms-shadow-inset: inset 3px 3px 8px rgba(139, 153, 174, .18), inset -3px -3px 8px rgba(255, 255, 255, .72);
    --ms-overlay: rgba(18, 26, 40, .58);
    --ms-focus: 0 0 0 3px rgba(37, 99, 235, .23);
    --ms-radius-xl: 26px;
    --ms-radius-lg: 19px;
    --ms-radius-md: 14px;
    --ms-radius-sm: 10px;
    --ms-sidebar-width: 284px;
    --ms-max-content: 1560px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --ms-bg: #151a22;
    --ms-bg-deep: #11161d;
    --ms-panel: #1c232d;
    --ms-panel-strong: #242c38;
    --ms-panel-soft: #171d25;
    --ms-text: #f5f7fa;
    --ms-text-2: #d0d5dd;
    --ms-muted: #98a2b3;
    --ms-line: #303946;
    --ms-line-strong: #424d5e;
    --ms-primary: #ff8737;
    --ms-primary-hover: #ff9d5f;
    --ms-primary-soft: #38291f;
    --ms-primary-line: #69452f;
    --ms-success: #6bd39f;
    --ms-success-soft: #1d332b;
    --ms-success-line: #315947;
    --ms-warning: #ffc16d;
    --ms-warning-soft: #382f20;
    --ms-warning-line: #615032;
    --ms-danger: #ff7d77;
    --ms-danger-soft: #3a2627;
    --ms-danger-line: #693d3f;
    --ms-info: #80aaff;
    --ms-info-soft: #202c43;
    --ms-sidebar: #1a212b;
    --ms-sidebar-text: #dce2ea;
    --ms-shadow-high: 10px 10px 24px rgba(3, 6, 10, .52), -7px -7px 18px rgba(57, 67, 84, .16), inset 1px 1px 0 rgba(255, 255, 255, .025);
    --ms-shadow-mid: 5px 5px 13px rgba(3, 6, 10, .45), -4px -4px 11px rgba(57, 67, 84, .14), inset 1px 1px 0 rgba(255, 255, 255, .02);
    --ms-shadow-low: 2px 2px 7px rgba(3, 6, 10, .38), -2px -2px 7px rgba(57, 67, 84, .10);
    --ms-shadow-inset: inset 3px 3px 8px rgba(2, 5, 9, .58), inset -2px -2px 7px rgba(58, 69, 87, .14);
    --ms-overlay: rgba(0, 0, 0, .68);
    --ms-focus: 0 0 0 3px rgba(128, 170, 255, .24);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--ms-bg); }
body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background: radial-gradient(circle at 12% -10%, var(--ms-panel-strong) 0, transparent 32rem), linear-gradient(145deg, var(--ms-bg) 0%, var(--ms-bg-deep) 100%);
    color: var(--ms-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
button { border: 0; }
::selection { background: var(--ms-primary); color: #fff; }
:focus-visible { outline: none; box-shadow: var(--ms-focus) !important; }
[hidden] { display: none !important; }

.ms-app { min-height: 100vh; display: grid; grid-template-columns: var(--ms-sidebar-width) minmax(0, 1fr); }
.ms-sidebar {
    position: sticky;
    top: 0;
    z-index: 70;
    height: 100vh;
    overflow-y: auto;
    padding: 18px 14px 26px;
    background: var(--ms-sidebar);
    border-right: 1px solid var(--ms-line);
    box-shadow: 8px 0 24px rgba(52, 64, 84, .08);
    scrollbar-width: thin;
    scrollbar-color: var(--ms-line-strong) transparent;
}
.ms-sidebar::-webkit-scrollbar { width: 7px; }
.ms-sidebar::-webkit-scrollbar-thumb { background: var(--ms-line-strong); border-radius: 999px; }
.ms-brand {
    min-height: 66px;
    display: grid;
    grid-template-columns: 46px minmax(0,1fr) auto;
    align-items: center;
    gap: 11px;
    margin: 0 2px 14px;
    padding: 8px 9px;
    border-radius: var(--ms-radius-lg);
}
.ms-brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ms-primary-line);
    border-radius: 16px;
    background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel));
    color: var(--ms-primary);
    box-shadow: var(--ms-shadow-mid);
    font-size: 13px;
    font-weight: 950;
    letter-spacing: -.03em;
}
.ms-brand-copy { min-width: 0; }
.ms-brand-copy strong { display: block; color: var(--ms-text); font-size: 16px; line-height: 1.2; letter-spacing: -.02em; }
.ms-brand-copy span { display: block; margin-top: 3px; color: var(--ms-muted); font-size: 10px; font-weight: 700; }
.ms-sidebar-close { display: none; width: 36px; height: 36px; border-radius: 12px; background: transparent; color: var(--ms-muted); cursor: pointer; font-size: 24px; }
.ms-nav { display: block; }
.ms-nav-heading { margin-top: 8px; padding: 15px 10px 6px; color: var(--ms-muted); font-size: 9.5px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.ms-nav-link {
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 1px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--ms-sidebar-text);
    font-size: 12.5px;
    font-weight: 760;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}
.ms-nav-link:hover { transform: translateX(2px); background: var(--ms-panel-strong); border-color: var(--ms-line); color: var(--ms-text); }
.ms-nav-link.is-active { background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); border-color: var(--ms-line); color: var(--ms-text); box-shadow: var(--ms-shadow-mid); }
.ms-nav-link.is-active::after { content: ""; position: absolute; left: -3px; top: 10px; bottom: 10px; width: 4px; border-radius: 999px; background: var(--ms-primary); }
.ms-nav-icon { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 10px; background: var(--ms-panel-soft); color: var(--ms-muted); box-shadow: var(--ms-shadow-inset); font-size: 9px; font-weight: 950; letter-spacing: -.02em; }
.ms-nav-link.is-active .ms-nav-icon { background: var(--ms-primary-soft); color: var(--ms-primary); box-shadow: none; }
.ms-scrim { display: none; }

.ms-main { min-width: 0; min-height: 100vh; }
.ms-topbar {
    position: sticky;
    top: 0;
    z-index: 55;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px clamp(16px, 2vw, 28px);
    background: rgba(238, 243, 249, .94);
    border-bottom: 1px solid var(--ms-line);
    box-shadow: 0 6px 20px rgba(52, 64, 84, .07);
    backdrop-filter: blur(14px);
}
html[data-theme="dark"] .ms-topbar { background: rgba(28, 35, 45, .94); }
.ms-topbar-start, .ms-topbar-end { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ms-topbar-title-wrap { min-width: 0; }
.ms-topbar-title { display: block; max-width: min(48vw, 620px); overflow: hidden; color: var(--ms-text); text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 900; letter-spacing: -.02em; }
.ms-topbar-subtitle { display: block; margin-top: 1px; color: var(--ms-muted); font-size: 10px; font-weight: 650; }
.ms-menu-btn { display: none; width: 42px; height: 42px; place-items: center; border: 1px solid var(--ms-line); border-radius: 13px; background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); color: var(--ms-text); box-shadow: var(--ms-shadow-mid); cursor: pointer; font-size: 18px; }
.ms-theme-btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--ms-line); border-radius: 12px; background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); color: var(--ms-text-2); box-shadow: var(--ms-shadow-mid); cursor: pointer; font-size: 12px; font-weight: 800; }
.ms-account-chip { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; border: 1px solid var(--ms-line); border-radius: 14px; background: var(--ms-panel-soft); color: var(--ms-text-2); box-shadow: var(--ms-shadow-inset); }
.ms-account-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 10px; background: var(--ms-primary-soft); color: var(--ms-primary); font-size: 11px; font-weight: 950; }
.ms-user-email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.ms-content { width: 100%; max-width: var(--ms-max-content); margin: 0 auto; padding: clamp(18px, 2.2vw, 32px); }

.ms-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 0 0 20px; }
.ms-page-head h1 { margin: 0; color: var(--ms-text); font-size: clamp(25px, 2.3vw, 35px); line-height: 1.12; font-weight: 930; letter-spacing: -.045em; }
.ms-page-head h2 { margin: 0; }
.ms-page-head p { max-width: 820px; margin: 7px 0 0; color: var(--ms-muted); font-size: 12.5px; }
.ms-section-title { margin: 0 0 13px; color: var(--ms-text); font-size: 17px; line-height: 1.25; font-weight: 900; letter-spacing: -.025em; }
.ms-muted { color: var(--ms-muted) !important; }
.ms-text-danger { color: var(--ms-danger) !important; }
.ms-help { margin-top: 5px; color: var(--ms-muted); font-size: 11px; line-height: 1.45; }
.ms-divider { height: 1px; margin: 17px 0; background: var(--ms-line); }
.ms-spacer-top { margin-top: 18px !important; }
.ms-spacer-top-lg { margin-top: 20px !important; }
.ms-spacer-bottom { margin-bottom: 12px !important; }
.ms-no-margin { margin: 0 !important; }
.ms-no-margin-bottom { margin-bottom: 0 !important; }
.ms-font-20 { font-size: 20px !important; }
.ms-inline { display: inline !important; }
.ms-nowrap { flex-wrap: nowrap !important; }
.ms-inline-chip { display: inline-flex !important; margin: 2px !important; }
.ms-hidden { display: none !important; }
.ms-field-gap { margin-top: 8px !important; }
.ms-checkbox-line { display: flex; align-items: center; gap: 8px; color: var(--ms-text-2); font-size: 12px; font-weight: 750; }
.ms-qr { width: min(280px, 100%); display: block; margin-top: 12px; border: 10px solid #fff; border-radius: 18px; box-shadow: var(--ms-shadow-mid); }

.ms-grid { display: grid; gap: 18px; }
.ms-stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.ms-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.ms-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.ms-field.ms-full { grid-column: 1 / -1; }
.ms-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ms-stack { display: flex; flex-direction: column; gap: 10px; }

.ms-card, .ms-table-scroll, .ms-item-card, .ms-invoice { border: 1px solid var(--ms-line); background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); box-shadow: var(--ms-shadow-high); }
.ms-card { position: relative; padding: 20px; border-radius: var(--ms-radius-xl); }
.ms-card + .ms-card { margin-top: 18px; }
.ms-metric-card { min-height: 128px; overflow: hidden; }
.ms-metric-card::after { content: ""; position: absolute; right: -34px; top: -38px; width: 112px; height: 112px; border-radius: 50%; background: var(--ms-primary-soft); opacity: .65; }
.ms-metric-label { position: relative; z-index: 1; color: var(--ms-muted); font-size: 10.5px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.ms-metric-value { position: relative; z-index: 1; margin-top: 7px; color: var(--ms-text); font-size: clamp(23px, 2vw, 31px); line-height: 1.1; font-weight: 950; letter-spacing: -.04em; }
.ms-metric-hint { position: relative; z-index: 1; margin-top: 7px; color: var(--ms-muted); font-size: 10.5px; }

.ms-btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 1px solid var(--ms-line); border-radius: 13px; background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); color: var(--ms-text-2); box-shadow: var(--ms-shadow-mid); cursor: pointer; font-size: 12px; line-height: 1.2; font-weight: 850; text-align: center; white-space: nowrap; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease, color .14s ease; }
.ms-btn:hover { transform: translateY(-1px); border-color: var(--ms-line-strong); }
.ms-btn:active { transform: translateY(0); box-shadow: var(--ms-shadow-inset); }
.ms-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ms-btn.is-sm { min-height: 34px; padding: 6px 10px; border-radius: 10px; font-size: 10.5px; }
.ms-btn.is-icon { width: 42px; padding: 0; }
.ms-btn-primary { border-color: var(--ms-primary-line); background: linear-gradient(145deg, #f78a3d, var(--ms-primary)); color: #fff; box-shadow: 5px 5px 13px rgba(180, 77, 10, .22), -4px -4px 10px rgba(255, 255, 255, .34), inset 1px 1px 0 rgba(255,255,255,.35); }
html[data-theme="dark"] .ms-btn-primary { background: linear-gradient(145deg, #ff9a55, var(--ms-primary)); box-shadow: 5px 5px 13px rgba(0,0,0,.36), -3px -3px 9px rgba(93,61,40,.18), inset 1px 1px 0 rgba(255,255,255,.2); }
.ms-btn-primary:hover { background: linear-gradient(145deg, var(--ms-primary), var(--ms-primary-hover)); }
.ms-btn-secondary { color: var(--ms-text-2); }
.ms-btn-ghost { background: transparent; box-shadow: none; color: var(--ms-muted); }
.ms-btn.is-danger { border-color: var(--ms-danger-line); background: var(--ms-danger-soft); color: var(--ms-danger); box-shadow: var(--ms-shadow-low); }

.ms-field { min-width: 0; }
.ms-field label { display: block; margin: 0 0 6px; color: var(--ms-text-2); font-size: 11px; line-height: 1.3; font-weight: 850; }
.ms-input, .ms-select, .ms-textarea { width: 100%; min-width: 0; border: 1px solid var(--ms-line); border-radius: 13px; background: var(--ms-panel-soft); color: var(--ms-text); box-shadow: var(--ms-shadow-inset); transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.ms-input, .ms-select { min-height: 43px; padding: 9px 11px; }
.ms-textarea { min-height: 92px; padding: 10px 11px; resize: vertical; }
.ms-input::placeholder, .ms-textarea::placeholder { color: var(--ms-muted); opacity: .82; }
.ms-input:hover, .ms-select:hover, .ms-textarea:hover { border-color: var(--ms-line-strong); }
.ms-input:focus, .ms-select:focus, .ms-textarea:focus { border-color: var(--ms-info); background: var(--ms-panel); box-shadow: var(--ms-focus), var(--ms-shadow-inset); outline: none; }
.ms-input[readonly], .ms-input:disabled, .ms-select:disabled, .ms-textarea:disabled { opacity: .68; cursor: not-allowed; }
.ms-select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ms-muted) 50%), linear-gradient(135deg, var(--ms-muted) 50%, transparent 50%); background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; margin: 0; accent-color: var(--ms-primary); }
.ms-check { display: flex; align-items: center; gap: 8px; color: var(--ms-text-2); font-size: 12px; font-weight: 700; cursor: pointer; }
.ms-search { width: min(430px, 100%); }
.ms-search .ms-input { padding-left: 38px; background-image: radial-gradient(circle at 18px 50%, transparent 0 5px, var(--ms-muted) 5.5px 6.5px, transparent 7px), linear-gradient(45deg, transparent 46%, var(--ms-muted) 47% 54%, transparent 55%); background-size: 28px 100%, 8px 8px; background-position: 0 0, 24px 58%; background-repeat: no-repeat; }
.ms-table-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }

.ms-table-scroll { width: 100%; overflow-x: auto; border-radius: var(--ms-radius-lg); }
.ms-table { width: 100%; min-width: 760px; border-collapse: collapse; background: transparent; color: var(--ms-text-2); }
.ms-table th, .ms-table td { padding: 13px 14px; border-bottom: 1px solid var(--ms-line); text-align: left; vertical-align: middle; }
.ms-table th { position: sticky; top: 0; z-index: 2; background: var(--ms-panel-soft); color: var(--ms-muted); font-size: 9.5px; font-weight: 950; letter-spacing: .075em; text-transform: uppercase; white-space: nowrap; }
.ms-table td { font-size: 11.5px; }
.ms-table tbody tr { transition: background .13s ease; }
.ms-table tbody tr:hover { background: var(--ms-panel-soft); }
.ms-table tbody tr:last-child td { border-bottom: 0; }
.ms-table td:last-child .ms-actions { flex-wrap: nowrap; }
.ms-empty { padding: 38px !important; color: var(--ms-muted) !important; text-align: center !important; }

.ms-badge { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 4px 9px; border: 1px solid var(--ms-line); border-radius: 999px; background: var(--ms-panel-soft); color: var(--ms-text-2); font-size: 10px; line-height: 1.2; font-weight: 900; white-space: nowrap; }
.ms-badge.is-ok { border-color: var(--ms-success-line); background: var(--ms-success-soft); color: var(--ms-success); }
.ms-badge.is-warn { border-color: var(--ms-warning-line); background: var(--ms-warning-soft); color: var(--ms-warning); }
.ms-badge.is-danger { border-color: var(--ms-danger-line); background: var(--ms-danger-soft); color: var(--ms-danger); }
.ms-chip-row { display: flex; gap: 9px; flex-wrap: wrap; }
.ms-chip { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border: 1px solid var(--ms-line); border-radius: 999px; background: linear-gradient(145deg, var(--ms-panel-strong), var(--ms-panel)); color: var(--ms-text-2); box-shadow: var(--ms-shadow-low); font-size: 11px; }

.ms-alert { margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--ms-line); border-radius: 14px; background: var(--ms-panel); color: var(--ms-text-2); box-shadow: var(--ms-shadow-mid); font-size: 12px; font-weight: 750; }
.ms-alert.is-success { border-color: var(--ms-success-line); background: var(--ms-success-soft); color: var(--ms-success); }
.ms-alert.is-error { border-color: var(--ms-danger-line); background: var(--ms-danger-soft); color: var(--ms-danger); }
.ms-toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 150; width: min(380px, calc(100vw - 36px)); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.ms-toast { padding: 12px 14px; border: 1px solid var(--ms-line); border-left: 4px solid var(--ms-primary); border-radius: 14px; background: var(--ms-panel-strong); color: var(--ms-text); box-shadow: 0 22px 60px rgba(15, 23, 42, .30); font-size: 12px; pointer-events: auto; animation: msToastIn .18s ease-out; }
.ms-toast.is-ok { border-left-color: var(--ms-success); }
.ms-toast.is-error { border-left-color: var(--ms-danger); }
@keyframes msToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ms-item-card { margin: 12px 0; padding: 16px; border-radius: var(--ms-radius-lg); }
.ms-item-grid { display: grid; grid-template-columns: minmax(220px, 2fr) .65fr 1fr .8fr auto; gap: 11px; align-items: end; }
.ms-internal { margin-top: 12px; padding: 12px; border: 1px dashed var(--ms-warning-line); border-radius: 14px; background: var(--ms-warning-soft); }
.ms-internal summary { color: var(--ms-warning); cursor: pointer; font-size: 11px; font-weight: 900; user-select: none; }
.ms-internal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-top: 12px; }
.serial-row { display: grid; grid-template-columns: repeat(6, minmax(125px, 1fr)); gap: 8px; margin-top: 9px; }
.ms-source-note { color: var(--ms-warning); font-size: 10.5px; }

.ms-dialog-body { padding: 22px; }
.ms-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--ms-line); }
.ms-dialog-head h3 { margin: 0; color: var(--ms-text); font-size: 19px; font-weight: 920; letter-spacing: -.02em; }
dialog { width: min(720px, calc(100vw - 30px)); max-height: min(90vh, 900px); margin: auto; padding: 0; overflow: auto; border: 1px solid var(--ms-line-strong); border-radius: 24px; background: var(--ms-panel); color: var(--ms-text); box-shadow: 0 28px 80px rgba(15, 23, 42, .38); }
dialog.is-wide { width: min(980px, calc(100vw - 30px)); }
dialog::backdrop { background: var(--ms-overlay); backdrop-filter: blur(3px); }

.ms-invoice { width: min(960px, 100%); margin: 20px auto; padding: 36px; border-radius: 22px; }
.ms-invoice-head { display: flex; justify-content: space-between; gap: 22px; padding-bottom: 18px; border-bottom: 2px solid var(--ms-text); }
.ms-invoice-meta { text-align: right; }
.ms-totals { width: min(420px, 100%); margin-left: auto; }
.ms-totals > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 7px 0; border-bottom: 1px dashed var(--ms-line); }
.ms-totals .is-grand { margin-top: 6px; padding-top: 12px; border-top: 2px solid var(--ms-text); border-bottom: 0; color: var(--ms-text); font-size: 20px; font-weight: 950; }

.ms-auth-body { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.ms-auth-shell { width: min(1040px, 100%); min-height: 620px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid var(--ms-line); border-radius: 32px; background: var(--ms-panel); box-shadow: var(--ms-shadow-high); }
.ms-auth-brand-panel { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 5vw, 70px); background: linear-gradient(145deg, var(--ms-primary-soft), var(--ms-panel)); }
.ms-auth-brand-panel::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%; background: var(--ms-primary); opacity: .08; }
.ms-auth-brand-mark, .ms-auth-mobile-mark { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid var(--ms-primary-line); border-radius: 19px; background: var(--ms-panel-strong); color: var(--ms-primary); box-shadow: var(--ms-shadow-mid); font-size: 15px; font-weight: 950; }
.ms-auth-brand-panel h1 { margin: 28px 0 10px; color: var(--ms-text); font-size: clamp(34px, 4vw, 52px); line-height: 1; letter-spacing: -.05em; }
.ms-auth-brand-panel p { max-width: 470px; margin: 0; color: var(--ms-text-2); font-size: 14px; }
.ms-auth-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 34px; }
.ms-auth-feature-grid span { padding: 12px 14px; border: 1px solid var(--ms-line); border-radius: 14px; background: var(--ms-panel); box-shadow: var(--ms-shadow-mid); color: var(--ms-text-2); font-size: 11px; font-weight: 850; }
.ms-auth-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 5vw, 64px); background: var(--ms-panel); }
.ms-auth-head { margin-bottom: 26px; }
.ms-auth-head h2 { margin: 5px 0 8px; color: var(--ms-text); font-size: 31px; line-height: 1.1; letter-spacing: -.04em; }
.ms-auth-head p { margin: 0; color: var(--ms-muted); }
.ms-auth-eyebrow { color: var(--ms-primary) !important; font-size: 10px !important; font-weight: 950; letter-spacing: .12em; text-transform: uppercase; }
.ms-auth-mobile-mark { display: none; margin-bottom: 22px; }
.ms-auth-form { display: flex; flex-direction: column; gap: 16px; }
.ms-auth-submit { width: 100%; margin-top: 2px; }
.ms-auth-note { margin: 22px 0 0; color: var(--ms-muted); font-size: 10.5px; text-align: center; }
.ms-password-wrap { position: relative; }
.ms-password-wrap .ms-input { padding-right: 68px; }
.ms-password-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); min-width: 52px; height: 30px; padding: 0 8px; border-radius: 9px; background: var(--ms-panel); color: var(--ms-muted); cursor: pointer; font-size: 10px; font-weight: 850; }
.ms-error-list { margin: 0; padding-left: 18px; }


.ms-radio-card-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:7px; }
.ms-radio-card { position:relative; display:flex; align-items:flex-start; gap:10px; min-height:74px; padding:12px 13px; border:1px solid var(--ms-line); border-radius:14px; background:var(--ms-panel-soft); cursor:pointer; transition:border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.ms-radio-card:hover { border-color:var(--ms-line-strong); }
.ms-radio-card.is-selected { border-color:var(--ms-primary-line); background:var(--ms-primary-soft); box-shadow:0 0 0 2px color-mix(in srgb, var(--ms-primary) 10%, transparent); }
.ms-radio-card input { position:absolute; opacity:0; pointer-events:none; }
.ms-radio-mark { flex:0 0 18px; width:18px; height:18px; margin-top:1px; border:2px solid var(--ms-muted); border-radius:50%; background:var(--ms-panel); position:relative; }
.ms-radio-card.is-selected .ms-radio-mark { border-color:var(--ms-primary); }
.ms-radio-card.is-selected .ms-radio-mark::after { content:""; position:absolute; inset:4px; border-radius:50%; background:var(--ms-primary); }
.ms-radio-card input:focus-visible + .ms-radio-mark { outline:3px solid var(--ms-focus); outline-offset:2px; }
.ms-radio-copy { display:flex; flex-direction:column; gap:3px; min-width:0; }
.ms-radio-copy strong { font-size:12px; font-weight:850; color:var(--ms-text); }
.ms-radio-copy small { font-size:10.5px; line-height:1.4; color:var(--ms-muted); }
@media (max-width:650px){.ms-radio-card-grid{grid-template-columns:1fr}}
@media (max-width: 1180px) {
    .ms-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-item-grid { grid-template-columns: 1fr 1fr; }
    .ms-internal-grid { grid-template-columns: 1fr 1fr; }
    .serial-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-user-email { max-width: 140px; }
}

@media (max-width: 960px) {
    .ms-app { display: block; }
    .ms-sidebar { position: fixed; top: 0; left: calc(-1 * var(--ms-sidebar-width) - 30px); width: var(--ms-sidebar-width); max-width: 88vw; height: 100dvh; transition: left .20s ease; box-shadow: 20px 0 60px rgba(7, 12, 20, .34); }
    .ms-sidebar.is-open { left: 0; }
    .ms-sidebar-close { display: grid; place-items: center; }
    .ms-scrim { position: fixed; inset: 0; z-index: 65; display: block; background: var(--ms-overlay); opacity: 0; pointer-events: none; transition: opacity .20s ease; }
    .ms-scrim.is-open { opacity: 1; pointer-events: auto; }
    .ms-menu-btn { display: grid; }
    .ms-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .ms-topbar { min-height: 64px; padding: 9px 12px; }
    .ms-topbar-subtitle, .ms-account-chip { display: none; }
    .ms-topbar-title { max-width: 38vw; }
    .ms-theme-btn [data-theme-label] { display: none; }
    .ms-theme-btn { width: 40px; padding: 0; }
    .ms-content { padding: 16px; }
    .ms-page-head { flex-direction: column; align-items: stretch; }
    .ms-page-head > .ms-actions { justify-content: flex-start; }
    .ms-form-grid, .ms-item-grid, .ms-internal-grid, .serial-row { grid-template-columns: 1fr; }
    .ms-field.ms-full { grid-column: auto; }
    .ms-search { width: 100%; }
    .ms-table-tools { align-items: stretch; flex-direction: column; }
    .ms-table { min-width: 680px; }
    .ms-invoice { margin: 0; padding: 20px; border-radius: 18px; }
    .ms-invoice-head { flex-direction: column; }
    .ms-invoice-meta { text-align: left; }
    dialog, dialog.is-wide { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 20px; }
    .ms-auth-body { padding: 14px; }
    .ms-auth-shell { min-height: auto; grid-template-columns: 1fr; border-radius: 24px; }
    .ms-auth-brand-panel { display: none; }
    .ms-auth-card { min-height: calc(100dvh - 28px); padding: 28px 22px; }
    .ms-auth-mobile-mark { display: grid; }
}

@media (max-width: 520px) {
    body { font-size: 13px; }
    .ms-content { padding: 12px; }
    .ms-card { padding: 15px; border-radius: 19px; }
    .ms-stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .ms-metric-card { min-height: 106px; }
    .ms-page-head h1 { font-size: 25px; }
    .ms-actions { gap: 7px; }
    .ms-page-head > .ms-actions .ms-btn { flex: 1 1 auto; }
    .ms-btn { min-height: 40px; padding: 8px 11px; }
    .ms-dialog-body { padding: 16px; }
    .ms-table th, .ms-table td { padding: 10px 11px; }
    .ms-topbar-title { max-width: 34vw; }
    .ms-topbar-end { gap: 6px; }
    .ms-topbar-end > .ms-btn { padding-inline: 9px; }
    .ms-toast-stack { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
    :root { --ms-bg:#fff; --ms-panel:#fff; --ms-panel-strong:#fff; --ms-panel-soft:#f4f4f4; --ms-text:#111; --ms-text-2:#222; --ms-muted:#555; --ms-line:#ddd; }
    html, body { background: #fff !important; color: #111 !important; }
    .ms-sidebar, .ms-topbar, .ms-no-print, .ms-toast-stack, .ms-scrim { display: none !important; }
    .ms-app { display: block; }
    .ms-main { min-height: 0; }
    .ms-content { max-width: none; padding: 0; }
    .ms-invoice { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: #fff !important; color: #111 !important; box-shadow: none !important; }
    .ms-table-scroll { border: 1px solid #ddd; background: #fff !important; box-shadow: none !important; overflow: visible; }
    .ms-table { min-width: 0; }
    .ms-table th { position: static; background: #f4f4f4 !important; color: #444 !important; }
    .ms-table td { color: #111 !important; }
    .ms-muted { color: #555 !important; }
    .ms-badge { border: 1px solid #aaa !important; background: #fff !important; color: #222 !important; }
}

/* Final application-specific helpers */
.ms-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.ms-section-head h2 { margin: 0 0 5px; font-size: 19px; letter-spacing: -.02em; }
.ms-section-head p { margin: 0; color: var(--ms-muted); }
.ms-badge.is-neutral { color: var(--ms-text-2); background: var(--ms-panel-soft); border-color: var(--ms-line); }
.ms-invoice-billto { margin: 22px 0; padding: 16px 18px; border: 1px solid var(--ms-line); border-radius: var(--ms-radius-md); background: var(--ms-panel-soft); }
.ms-invoice-table { margin-top: 18px; box-shadow: none; }
@media (max-width: 760px) {
    .ms-section-head { align-items: stretch; flex-direction: column; }
    .ms-section-head .ms-search { width: 100%; }
}
.ms-auth-theme { position: fixed; top: 18px; right: 18px; z-index: 10; }
@media (max-width: 520px) { .ms-auth-theme { top: 10px; right: 10px; } }

/* =========================================================
   INVOICE DESIGNER + 10 BUILT-IN INVOICE THEMES
   Pure custom CSS. No Bootstrap/Tailwind dependency.
   ========================================================= */
.ms-settings-grid { display:grid; grid-template-columns: minmax(0,1.1fr) minmax(320px,.9fr); gap:18px; }
.ms-upload-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.ms-upload-card { padding:14px; border:1px solid var(--ms-line); border-radius:16px; background:var(--ms-panel-soft); box-shadow:var(--ms-shadow-inset); }
.ms-upload-preview { height:110px; display:grid; place-items:center; margin-bottom:12px; border:1px dashed var(--ms-line-strong); border-radius:14px; background:var(--ms-panel); overflow:hidden; color:var(--ms-muted); font-size:11px; font-weight:900; letter-spacing:.12em; }
.ms-upload-preview img { max-width:92%; max-height:92px; object-fit:contain; }
.ms-upload-preview.is-signature img { max-height:72px; }
.ms-file { width:100%; color:var(--ms-text-2); font-size:12px; }
.ms-file::file-selector-button { margin-right:10px; padding:8px 11px; border:1px solid var(--ms-line); border-radius:10px; background:var(--ms-panel-strong); color:var(--ms-text); font-weight:800; cursor:pointer; }
.ms-check { display:flex; align-items:center; gap:8px; min-height:34px; color:var(--ms-text-2); font-size:12px; font-weight:750; cursor:pointer; }
.ms-check input { width:17px; height:17px; accent-color:var(--ms-primary); }

.ms-invoice-template-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:13px; }
.ms-template-option { position:relative; display:block; min-width:0; padding:10px; border:1px solid var(--ms-line); border-radius:17px; background:var(--ms-panel-soft); cursor:pointer; transition:transform .16s ease,border-color .16s ease,box-shadow .16s ease; }
.ms-template-option:hover { transform:translateY(-2px); border-color:var(--ms-line-strong); box-shadow:var(--ms-shadow-mid); }
.ms-template-option.is-selected { border-color:var(--ms-primary); box-shadow:0 0 0 2px var(--ms-primary-soft),var(--ms-shadow-mid); }
.ms-template-option > input { position:absolute; opacity:0; pointer-events:none; }
.ms-template-preview { position:relative; display:flex; flex-direction:column; gap:7px; aspect-ratio:4/5; padding:10px; overflow:hidden; border-radius:11px; border:1px solid #dbe1e8; background:#fff; color:#222; box-shadow:0 4px 12px rgba(20,30,45,.08); }
.ms-template-preview i { display:block; height:4px; border-radius:10px; background:#d8dee7; }
.ms-template-preview .tp-head { display:flex; align-items:center; justify-content:space-between; gap:6px; padding-bottom:7px; border-bottom:2px solid #ef7c2e; font-size:7px; }
.ms-template-preview .tp-head i { width:28px; height:15px; background:#eceff3; }
.ms-template-preview .tp-info { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.ms-template-preview .tp-info i { height:20px; }
.ms-template-preview .tp-table { display:flex; flex-direction:column; gap:4px; flex:1; padding-top:5px; border-top:1px solid #e2e6eb; }
.ms-template-preview .tp-table i:nth-child(2){width:88%}.ms-template-preview .tp-table i:nth-child(3){width:76%}
.ms-template-preview .tp-total { display:flex; flex-direction:column; align-items:flex-end; gap:4px; }
.ms-template-preview .tp-total i { width:42%; }
.ms-template-name { display:block; padding:9px 2px 2px; }
.ms-template-name strong,.ms-template-name small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ms-template-name strong { color:var(--ms-text); font-size:11.5px; }
.ms-template-name small { margin-top:3px; color:var(--ms-muted); font-size:9.5px; }
.ms-template-preview.invoice-theme-modern .tp-head { margin:-10px -10px 0; padding:9px 10px; color:#fff; border:0; background:#222b3a; }
.ms-template-preview.invoice-theme-minimal { border-color:#fff; box-shadow:none; }
.ms-template-preview.invoice-theme-minimal .tp-head { border-bottom:1px solid #cfd5dc; }
.ms-template-preview.invoice-theme-compact { padding:7px; gap:4px; }
.ms-template-preview.invoice-theme-executive .tp-head { border:0; border-left:5px solid #202733; padding-left:7px; }
.ms-template-preview.invoice-theme-retail .tp-table { border-top:2px dashed #d3d8df; }
.ms-template-preview.invoice-theme-bold::before { content:""; position:absolute; inset:0 0 auto; height:18px; background:#ef7c2e; }
.ms-template-preview.invoice-theme-bold .tp-head { margin-top:10px; }
.ms-template-preview.invoice-theme-bordered { border:3px double #3a4657; }
.ms-template-preview.invoice-theme-elegant .tp-head { border-color:#9a805d; font-family:Georgia,serif; }
.ms-template-preview.invoice-theme-thermal { width:72%; margin-inline:auto; border-radius:2px; box-shadow:0 2px 7px rgba(0,0,0,.08); }
.ms-template-preview.invoice-theme-thermal .tp-head { border-color:#222; }

.ms-toggle-list { display:grid; gap:8px; }
.ms-switch { display:flex; align-items:center; gap:10px; min-height:40px; color:var(--ms-text-2); cursor:pointer; }
.ms-switch input { position:absolute; opacity:0; pointer-events:none; }
.ms-switch > span { position:relative; flex:0 0 42px; width:42px; height:23px; border:1px solid var(--ms-line-strong); border-radius:99px; background:var(--ms-panel-soft); box-shadow:var(--ms-shadow-inset); }
.ms-switch > span::after { content:""; position:absolute; top:3px; left:3px; width:15px; height:15px; border-radius:50%; background:var(--ms-muted); box-shadow:0 2px 5px rgba(0,0,0,.22); transition:left .15s ease,background .15s ease; }
.ms-switch input:checked + span { border-color:var(--ms-primary-line); background:var(--ms-primary-soft); }
.ms-switch input:checked + span::after { left:22px; background:var(--ms-primary); }
.ms-switch input:focus-visible + span { outline:3px solid var(--ms-focus); outline-offset:2px; }
.ms-switch b { font-size:12px; font-weight:800; }
.ms-sticky-save { position:sticky; z-index:20; bottom:12px; display:flex; align-items:center; justify-content:space-between; gap:14px; margin-top:18px; padding:12px 14px; border:1px solid var(--ms-line-strong); border-radius:16px; background:var(--ms-panel-strong); box-shadow:var(--ms-shadow-high); }
.ms-sticky-save strong,.ms-sticky-save span { display:block; }.ms-sticky-save span{margin-top:2px;color:var(--ms-muted);font-size:10.5px}

.ms-invoice-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.ms-toggle-block { padding:13px 14px; border:1px solid var(--ms-line); border-radius:15px; background:var(--ms-panel-soft); }
.ms-toggle-block p { margin:3px 0 0 52px; color:var(--ms-muted); font-size:10.5px; line-height:1.45; }
.ms-option-details { border:1px solid var(--ms-line); border-radius:14px; background:var(--ms-panel-soft); }
.ms-option-details summary { padding:12px 14px; color:var(--ms-text); font-size:12px; font-weight:850; cursor:pointer; }
.ms-toggle-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px 12px; padding:0 14px 14px; }
.ms-sale-footer-grid { display:grid; grid-template-columns:minmax(300px,.8fr) minmax(300px,1.2fr); gap:18px; align-items:stretch; margin-top:18px; }
.ms-sale-summary > div { display:flex; justify-content:space-between; gap:20px; padding:7px 0; border-bottom:1px solid var(--ms-line); color:var(--ms-text-2); }
.ms-sale-summary > div.is-grand { margin-top:4px; padding:11px 0; border-top:2px solid var(--ms-line-strong); border-bottom:0; color:var(--ms-text); font-size:16px; }
.ms-sale-summary > .ms-help { display:block; border:0; }
.ms-complete-sale { display:flex; align-items:center; justify-content:space-between; gap:20px; }.ms-complete-sale p{margin:5px 0 0}

/* Core invoice document */
.ms-invoice { --inv-accent:#e87523; --inv-ink:#18202a; --inv-muted:#69717b; --inv-line:#dce1e6; --inv-soft:#f6f7f9; width:min(100%,980px); margin:0 auto 20px; padding:34px; background:#fff; color:var(--inv-ink); border:1px solid #dde2e8; border-radius:18px; box-shadow:0 14px 38px rgba(20,30,45,.10); font-size:12px; }
.inv-header { display:grid; grid-template-columns:minmax(0,1fr) minmax(220px,.36fr); gap:28px; align-items:start; padding-bottom:22px; border-bottom:2px solid var(--inv-accent); }
.inv-company { display:flex; align-items:flex-start; gap:15px; min-width:0; }.inv-logo{flex:0 0 74px;width:74px;height:74px;display:grid;place-items:center}.inv-logo img{max-width:74px;max-height:74px;object-fit:contain}.inv-company h2{margin:0 0 6px;font-size:24px;line-height:1.05;letter-spacing:-.03em}.inv-company-address{max-width:520px;line-height:1.5;color:var(--inv-muted)}.inv-company-contact{display:flex;flex-wrap:wrap;gap:5px 14px;margin-top:7px;color:var(--inv-muted)}
.inv-document{text-align:right}.inv-title{color:var(--inv-accent);font-size:22px;font-weight:950;letter-spacing:.06em}.inv-number{margin:4px 0 11px;font-size:13px;font-weight:850}.inv-document dl{margin:0;display:grid;gap:4px}.inv-document dl>div{display:flex;justify-content:flex-end;gap:10px}.inv-document dt{color:var(--inv-muted)}.inv-document dd{margin:0;font-weight:800}
.inv-party { display:grid; grid-template-columns:minmax(0,1fr) minmax(240px,.45fr); gap:20px; margin:20px 0; padding:15px 17px; border:1px solid var(--inv-line); border-radius:10px; background:var(--inv-soft); }.inv-party.inv-address-right .inv-billto{grid-column:2}.inv-party.inv-address-right .inv-reference{grid-column:1;grid-row:1}.inv-party.inv-address-full{grid-template-columns:1fr}.inv-party.inv-address-full .inv-reference{display:none}.inv-billto,.inv-reference{display:flex;flex-direction:column;gap:3px}.inv-billto address{margin:3px 0 0;font-style:normal;line-height:1.45;color:var(--inv-muted)}.inv-label{display:block;margin-bottom:4px;color:var(--inv-accent);font-size:9px;font-weight:950;letter-spacing:.11em;text-transform:uppercase}.inv-reference{text-align:right;align-items:flex-end;color:var(--inv-muted)}
.inv-table-wrap{width:100%;overflow-x:auto}.inv-table{width:100%;border-collapse:collapse}.inv-table th,.inv-table td{padding:10px 9px;border-bottom:1px solid var(--inv-line);vertical-align:top}.inv-table th{background:var(--inv-soft);color:var(--inv-muted);font-size:9px;font-weight:950;letter-spacing:.06em;text-transform:uppercase;text-align:left}.inv-table td small{display:block;margin-top:3px;color:var(--inv-muted);font-size:9.5px}.inv-table .num{text-align:right;white-space:nowrap}.inv-col-no{width:32px;color:var(--inv-muted)}
.inv-bottom{display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,.38fr);gap:28px;margin-top:23px}.inv-notes{display:grid;gap:14px}.inv-notes p{margin:0;color:var(--inv-muted);font-size:10.5px;line-height:1.55}.inv-totals{display:grid}.inv-totals>div{display:flex;justify-content:space-between;gap:20px;padding:6px 0;color:var(--inv-muted)}.inv-totals>div.grand{margin-top:5px;padding:10px 0;border-top:2px solid var(--inv-ink);color:var(--inv-ink);font-size:16px}.inv-totals>div.due{color:#b63a32;font-weight:850}.inv-footer{display:flex;align-items:flex-end;justify-content:space-between;gap:25px;margin-top:30px;padding-top:17px;border-top:1px solid var(--inv-line);color:var(--inv-muted)}.inv-footer-message{max-width:60%;font-size:10px}.inv-signature{display:flex;flex-direction:column;align-items:center;min-width:150px;color:var(--inv-ink);font-size:9px;font-weight:800}.inv-signature img{max-width:135px;max-height:60px;margin-bottom:4px;object-fit:contain}

/* 1 Classic */
.ms-invoice.invoice-theme-classic { --inv-accent:#e87523; }
/* 2 Modern */
.ms-invoice.invoice-theme-modern { --inv-accent:#2c405f; padding-top:0; overflow:hidden; }.invoice-theme-modern .inv-header{margin:0 -34px;padding:28px 34px 22px;background:#26364f;color:#fff;border:0}.invoice-theme-modern .inv-company-address,.invoice-theme-modern .inv-company-contact,.invoice-theme-modern .inv-document dt{color:#d4dbea}.invoice-theme-modern .inv-title{color:#ffb06f}.invoice-theme-modern .inv-party{border:0;border-radius:0;border-left:4px solid #e87523}
/* 3 Minimal */
.ms-invoice.invoice-theme-minimal { --inv-accent:#222; border:0; box-shadow:none; }.invoice-theme-minimal .inv-header{border-bottom:1px solid #bbb}.invoice-theme-minimal .inv-party{padding:10px 0;border:0;border-radius:0;background:transparent}.invoice-theme-minimal .inv-table th{background:transparent;border-bottom:1px solid #222}.invoice-theme-minimal .inv-footer{border-color:#bbb}
/* 4 Compact */
.ms-invoice.invoice-theme-compact { --inv-accent:#df6920; padding:22px; font-size:10.5px; }.invoice-theme-compact .inv-header{gap:16px;padding-bottom:14px}.invoice-theme-compact .inv-logo,.invoice-theme-compact .inv-logo img{width:55px;height:55px;max-width:55px;max-height:55px}.invoice-theme-compact .inv-company h2{font-size:20px}.invoice-theme-compact .inv-party{margin:13px 0;padding:10px 12px}.invoice-theme-compact .inv-table th,.invoice-theme-compact .inv-table td{padding:7px 6px}.invoice-theme-compact .inv-bottom{margin-top:14px}.invoice-theme-compact .inv-footer{margin-top:18px}
/* 5 Executive */
.ms-invoice.invoice-theme-executive { --inv-accent:#202733; border-top:8px solid #202733; }.invoice-theme-executive .inv-title{color:#202733}.invoice-theme-executive .inv-header{border-bottom:0}.invoice-theme-executive .inv-company{padding-left:15px;border-left:5px solid #202733}.invoice-theme-executive .inv-table th{background:#202733;color:#fff}.invoice-theme-executive .inv-totals>div.grand{border-color:#202733}
/* 6 Retail Pro */
.ms-invoice.invoice-theme-retail { --inv-accent:#d85b18; }.invoice-theme-retail .inv-header{border-bottom:3px dashed #d85b18}.invoice-theme-retail .inv-party{border-style:dashed}.invoice-theme-retail .inv-table th{border-top:2px solid #d85b18;border-bottom:2px solid #d85b18}.invoice-theme-retail .inv-footer{border-top-style:dashed}
/* 7 Bold Header */
.ms-invoice.invoice-theme-bold { --inv-accent:#f27722; padding-top:0; overflow:hidden; }.invoice-theme-bold .inv-header{position:relative;margin:0 -34px;padding:42px 34px 24px;border:0;background:#f27722;color:#fff}.invoice-theme-bold .inv-header::before{content:"";position:absolute;inset:0 auto 0 0;width:11px;background:#202733}.invoice-theme-bold .inv-company-address,.invoice-theme-bold .inv-company-contact,.invoice-theme-bold .inv-document dt{color:#fff2e9}.invoice-theme-bold .inv-title{color:#fff}.invoice-theme-bold .inv-party{border-color:#f6b78e;background:#fff8f3}
/* 8 Clean Border */
.ms-invoice.invoice-theme-bordered { --inv-accent:#394657; border:3px double #394657; border-radius:3px; }.invoice-theme-bordered .inv-header{border-bottom:3px double #394657}.invoice-theme-bordered .inv-party{border:1px solid #394657;border-radius:0}.invoice-theme-bordered .inv-table{border:1px solid #394657}.invoice-theme-bordered .inv-table th,.invoice-theme-bordered .inv-table td{border:1px solid #d9dee4}.invoice-theme-bordered .inv-footer{border-top:3px double #394657}
/* 9 Elegant */
.ms-invoice.invoice-theme-elegant { --inv-accent:#8a6d4a; border-color:#d6c9b8; font-family:Georgia,"Times New Roman",serif; }.invoice-theme-elegant .inv-company h2{font-size:27px;font-weight:600}.invoice-theme-elegant .inv-title{font-weight:600;letter-spacing:.1em}.invoice-theme-elegant .inv-party{border-color:#ded3c5;background:#fbf8f4}.invoice-theme-elegant .inv-table th{background:#f5f0ea;color:#6f5a42}.invoice-theme-elegant .inv-label{letter-spacing:.15em}
/* 10 Thermal / narrow */
.ms-invoice.invoice-theme-thermal { --inv-accent:#111; width:min(100%,430px); padding:18px; border-radius:2px; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:9.5px; }.invoice-theme-thermal .inv-header{grid-template-columns:1fr;gap:10px;text-align:center;border-bottom:1px dashed #111}.invoice-theme-thermal .inv-company{justify-content:center}.invoice-theme-thermal .inv-company-copy{text-align:center}.invoice-theme-thermal .inv-logo,.invoice-theme-thermal .inv-logo img{width:50px;height:50px;max-width:50px;max-height:50px}.invoice-theme-thermal .inv-company h2{font-size:17px}.invoice-theme-thermal .inv-company-contact{justify-content:center}.invoice-theme-thermal .inv-document{text-align:center}.invoice-theme-thermal .inv-document dl>div{justify-content:center}.invoice-theme-thermal .inv-title{font-size:15px;color:#111}.invoice-theme-thermal .inv-party{grid-template-columns:1fr;padding:9px;margin:12px 0;border:1px dashed #777;border-radius:0;background:#fff}.invoice-theme-thermal .inv-reference{display:none}.invoice-theme-thermal .inv-table{font-size:8px}.invoice-theme-thermal .inv-table th,.invoice-theme-thermal .inv-table td{padding:5px 3px}.invoice-theme-thermal .inv-bottom{grid-template-columns:1fr;gap:10px}.invoice-theme-thermal .inv-notes{order:2}.invoice-theme-thermal .inv-footer{align-items:center;flex-direction:column;text-align:center;border-top:1px dashed #777}.invoice-theme-thermal .inv-footer-message{max-width:100%}

@media (max-width:1180px){.ms-invoice-template-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.ms-toggle-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:900px){.ms-settings-grid,.ms-sale-footer-grid{grid-template-columns:1fr}.ms-invoice-controls{grid-template-columns:1fr}.ms-complete-sale{align-items:stretch;flex-direction:column}.inv-header{grid-template-columns:1fr}.inv-document{text-align:left}.inv-document dl>div{justify-content:flex-start}.inv-bottom{grid-template-columns:1fr}.inv-reference{text-align:left;align-items:flex-start}}
@media (max-width:680px){.ms-invoice-template-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.ms-upload-grid,.ms-toggle-grid{grid-template-columns:1fr}.ms-sticky-save{align-items:stretch;flex-direction:column}.ms-sticky-save .ms-btn{width:100%}.ms-invoice{padding:18px;border-radius:12px}.invoice-theme-modern .inv-header,.invoice-theme-bold .inv-header{margin:0 -18px;padding-left:18px;padding-right:18px}.inv-company{flex-direction:column}.inv-party{grid-template-columns:1fr}.inv-party.inv-address-right .inv-billto,.inv-party.inv-address-right .inv-reference{grid-column:1;grid-row:auto}.inv-reference{margin-top:8px}.inv-footer{align-items:flex-start;flex-direction:column}.inv-footer-message{max-width:100%}.inv-signature{align-items:flex-start}.inv-table{min-width:620px}}
@media (max-width:430px){.ms-invoice-template-grid{grid-template-columns:1fr 1fr}.ms-template-option{padding:7px}.ms-template-name strong{font-size:10.5px}.ms-toggle-block p{margin-left:0}.ms-invoice.invoice-theme-thermal{padding:12px}}

@media print {
    .ms-invoice { width:100% !important; max-width:none !important; margin:0 !important; border-radius:0 !important; box-shadow:none !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .inv-table-wrap { overflow:visible !important; }
    .inv-table { min-width:0 !important; }
    .inv-logo img,.inv-signature img { break-inside:avoid; }
    .invoice-theme-modern .inv-header { background:#26364f !important; color:#fff !important; }
    .invoice-theme-bold .inv-header { background:#f27722 !important; color:#fff !important; }
    .invoice-theme-executive .inv-table th { background:#202733 !important; color:#fff !important; }
    .invoice-theme-thermal { width:80mm !important; margin:0 auto !important; }
}
