:root {
    --border: #e7e7ef;
    --border-strong: #d8d7e3;
    --surface-subtle: #fafafe;
    --accent: #7164f3;
    --accent-dark: #5749d4;
    --focus-ring: rgba(113, 100, 243, .2);
    --shadow-sm: 0 2px 8px rgba(35, 32, 65, .04);
    --shadow-md: 0 12px 32px rgba(35, 32, 65, .1);
}

/* Sidebar collapse overrides must remain after responsive navigation rules. */
.sidebar { transition: width .2s ease, min-width .2s ease, padding .2s ease; }
.main-content { transition: padding-left .2s ease; }
@media (max-width: 760px) {
    .sidebar-collapsed .sidebar { width: 100%; min-width: 0; padding: 14px 16px; }
    .sidebar-collapsed .brand > span:last-child, .sidebar-collapsed .workspace-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .profile-mini > span:not(.avatar) { display: initial; }
    .sidebar-collapsed .brand { gap: 9px; padding-left: 14px; padding-right: 14px; }
    .sidebar-collapsed .side-nav a, .sidebar-collapsed .sidebar-bottom > a { justify-content: initial; padding-left: 11px; padding-right: 11px; overflow: visible; font-size: 13px; white-space: normal; }
    .sidebar-collapsed .side-nav a span, .sidebar-collapsed .sidebar-bottom > a span { font-size: 18px; }
}

html { scroll-behavior: smooth; }
body { line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.main-content { padding-left: clamp(22px, 4vw, 56px); padding-right: clamp(22px, 4vw, 56px); }
.topbar { margin-bottom: clamp(28px, 4vw, 44px); }
.sidebar-header { display: flex; align-items: flex-start; gap: 6px; }
.sidebar-header .brand { flex: 1; min-width: 0; }
.sidebar-toggle { width: 28px; height: 28px; flex: 0 0 28px; display: inline-flex; align-items: center; justify-content: center; margin: 0 4px 0 0; border: 1px solid #484655; border-radius: 7px; background: transparent; color: #aaa7b8; cursor: pointer; font-size: 22px; line-height: 1; }
.sidebar-toggle:hover { background: #302e3d; color: #fff; }
.sidebar-collapsed .sidebar { width: 76px; min-width: 76px; padding-left: 12px; padding-right: 12px; }
.sidebar-collapsed .sidebar-header { justify-content: center; }
.sidebar-collapsed .sidebar-header .brand { flex: 0 0 auto; padding-left: 0; padding-right: 0; }
.sidebar-collapsed .brand > span:last-child, .sidebar-collapsed .workspace-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .profile-mini > span:not(.avatar) { display: none; }
.sidebar-collapsed .brand { gap: 0; }
.sidebar-collapsed .side-nav a, .sidebar-collapsed .sidebar-bottom > a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    font-size: 0;
    white-space: nowrap;
}
.sidebar-collapsed .side-nav a span, .sidebar-collapsed .sidebar-bottom > a span { font-size: 18px; }
.sidebar-collapsed .side-nav em { position: absolute; margin: -22px 0 0 26px; }
.sidebar-collapsed .profile-mini { justify-content: center; padding-left: 0; padding-right: 0; }
.page-header { gap: 24px; }
.page-header h1, .detail-hero h1 { color: #242332; }
.page-header p, .detail-hero p { line-height: 1.65; }

.button, .mini-action, .filter-submit, .select-button, .upload-button {
    min-height: 38px;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.button:hover, .mini-action:hover, .filter-submit:hover, .upload-button:hover { transform: translateY(-1px); }
.button.primary { background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); box-shadow: 0 7px 18px rgba(113, 100, 243, .24); }
.button.dark { background: #302e3c; }
.button.dark:hover { background: #24222f; }
.button.outline, .mini-action { border-color: var(--border-strong); }
.button.outline:hover, .mini-action:hover { background: var(--surface-subtle); border-color: #c8c6d7; color: #373445; }
.mini-action.danger:hover { color: #c94255; border-color: #f2c3c9; background: #fff7f8; }

.panel, .stat-card, .filterbar, .product-card, .theme-card, .setup-card {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.panel { border-radius: 12px; }
.stat-card { border-radius: 12px; }
.panel-head { gap: 18px; }
.panel h2 { color: #2e2c3b; }

.client-plan-card { display: flex; flex-direction: column; }
.client-plan-card .plan-products { flex: 1 0 auto; }
.client-plan-card > .button.full { margin-top: auto; }

.sales-enquiry-modal .modal-dialog { width: min(720px, calc(100% - 2rem)); max-width: 720px; }
.sales-enquiry-form .modal-header { align-items: flex-start; }
.sales-enquiry-form .modal-header > div { min-width: 0; }
.sales-enquiry-form .modal-header p { margin-top: 7px; }
.sales-enquiry-form .modal-body { padding: 22px 28px; }
.sales-enquiry-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; row-gap: 14px; }
.sales-enquiry-field { min-width: 0; }
.sales-enquiry-field label { display: block; margin: 0 0 6px; color: #555363; font-size: 11px; font-weight: 700; }
.sales-enquiry-field .form-control { display: block; width: 100%; min-width: 0; margin: 0; }
.sales-enquiry-message { grid-column: 1 / -1; }
.sales-enquiry-message textarea.form-control { min-height: 112px; resize: vertical; }
.sales-enquiry-form .modal-footer { justify-content: flex-end; }

@media (max-width: 760px) {
    .sales-enquiry-fields { grid-template-columns: minmax(0, 1fr); row-gap: 10px; }
    .sales-enquiry-message { grid-column: auto; }
    .sales-enquiry-form .modal-body { padding: 18px 20px; }
    .sidebar-toggle { display: none; }
    .sidebar-collapsed .sidebar { width: 100%; min-width: 0; padding: 14px 16px; }
    .sidebar-collapsed .brand > span:last-child, .sidebar-collapsed .workspace-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .profile-mini > span:not(.avatar) { display: initial; }
    .sidebar-collapsed .brand { gap: 9px; padding-left: 14px; padding-right: 14px; }
    .sidebar-collapsed .side-nav a, .sidebar-collapsed .sidebar-bottom > a { justify-content: initial; padding-left: 11px; padding-right: 11px; overflow: visible; font-size: 13px; white-space: normal; }
    .sidebar-collapsed .side-nav a span, .sidebar-collapsed .sidebar-bottom > a span { font-size: 18px; }
}

.filterbar { flex-wrap: wrap; align-items: center; gap: 12px; padding: 15px; }
.search-box { min-height: 40px; border-color: var(--border-strong); background: #fff; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.filter-select { flex: 0 1 150px; }
.filter-select select, .form-control, input.form-control, textarea.form-control, select.form-control {
    min-height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: #fff;
    color: #302e3d;
    padding: 9px 11px;
}
.filter-select select { min-height: 36px; padding: 7px 4px; border-color: transparent; }
.form-control:focus, input.form-control:focus, textarea.form-control:focus, select.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: 0;
}
.check-filter { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; color: #5f5d6b; font-size: 11px; white-space: nowrap; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

table { border-spacing: 0; }
th { background: var(--surface-subtle); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: #fbfbfe; }
td { vertical-align: middle; }

.toast-message, .bulk-results, .info-note, .validation-summary-errors {
    border: 1px solid transparent;
    border-radius: 9px;
    box-shadow: var(--shadow-sm);
}
.toast-message {
    position: fixed;
    top: 86px;
    right: clamp(16px, 3vw, 36px);
    z-index: 1090;
    width: min(380px, calc(100vw - 32px));
    margin: 0;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(35, 32, 65, .14);
    animation: toast-in .2s ease-out;
}
.toast-message::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 10px 10px;
    background: currentColor;
    content: "";
    opacity: .28;
    animation: toast-progress 30s linear forwards;
    transform-origin: left;
}
.toast-message.toast-dismissed { opacity: 0; transform: translateY(-8px); transition: opacity .2s ease, transform .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.toast-message.success { background: #effbf6; border-color: #c9efdf; color: #197a5d; }
.toast-message.error { background: #fff3f4; border-color: #f3cbd0; color: #b53e4f; }
.info-note { background: #f4f7ff; border-color: #dce4ff; color: #59627d; padding: 14px 16px; }
.currency-summary { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 18px 22px; }
.currency-summary-icon, .currency-symbol { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: #edeafd; color: var(--accent); font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 700; }
.plan-edit-trigger { border: 0; background: transparent; cursor: pointer; font: inherit; }
.plan-edit-trigger:hover { color: var(--accent); }
.currency-summary strong { display: block; color: #343240; font-size: 13px; }
.currency-summary p { margin: 3px 0 0; color: #92909f; font-size: 11px; }
.currency-library .panel-head { margin-bottom: 0; }
.currency-code { display: inline-flex; padding: 5px 8px; border-radius: 6px; background: #f3f2f8; color: #565363; font-size: 10px; font-weight: 700; letter-spacing: .8px; }
.currency-symbol-cell { color: #4b4958; font-size: 16px; font-weight: 700; }
.currency-actions { gap: 8px; }
.currency-actions form { margin: 0; }
.empty-state { padding: 34px 24px; color: #92909f; text-align: center; }
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    color: #92909f;
    font-size: 11px;
}
.table-pagination-controls { display: inline-flex; align-items: center; gap: 5px; }
.table-pagination-button {
    min-width: 32px;
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #fff;
    color: #5f5d6b;
    cursor: pointer;
    font-size: 11px;
}
.table-pagination-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.table-pagination-button:disabled { cursor: default; opacity: .5; }
@media (max-width: 640px) {
    .table-pagination { align-items: flex-start; flex-direction: column; }
}
.modal-sm { --bs-modal-width: 460px; }

.detail-grid { gap: 24px; }
.detail-panel, .spec-panel { padding: clamp(20px, 3vw, 28px); }
.spec-panel + .spec-panel { margin-top: 18px; }
.spec-row { min-height: 42px; border-bottom-color: #f0eff5; gap: 16px; }
.spec-row b { color: #363442; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px; color: #6f6d7b; font-size: 12px; font-weight: 600; }
.back-link:hover { color: var(--accent); }

.modal { --bs-modal-width: 560px; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
.modal.show { display: block; }
.modal.fade { opacity: 0; transition: opacity .15s linear; }
.modal.fade.show { opacity: 1; }
.modal-open { overflow: hidden; }
.modal-dialog {
    position: relative;
    width: auto;
    max-width: var(--bs-modal-width);
    margin: 1.75rem auto;
    pointer-events: none;
}
.modal-dialog { margin: 1rem auto; min-height: calc(100% - 2rem); }
.modal-dialog-centered { align-items: center; }
.modal-dialog-centered { display: flex; min-height: calc(100% - 2rem); }
.custom-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border); background: #fff; }
.modal-header h2 { margin: 0; color: #2b2938; font-family: 'Space Grotesk', sans-serif; font-size: 18px; }
.modal-body { max-height: min(68vh, 620px); overflow-y: auto; padding: 24px; background: #fff; }
.modal-body > label { display: block; margin: 0 0 7px; color: #555363; font-size: 11px; font-weight: 700; }
.modal-body > label:not(:first-child) { margin-top: 17px; }
.modal-body > label + .form-control,
.modal-body > label + .input-group,
.modal-body > label + input,
.modal-body > label + select,
.modal-body > label + textarea { display: block; width: 100%; }
.modal-body .form-control + .form-control { margin-top: 12px; }
.modal-body input:not([type="hidden"]):not([type="color"]),
.modal-body select,
.modal-body textarea { min-height: 44px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 9px 11px; background: #fff; color: #302e3d; font-size: 13px; }
.modal-body textarea { min-height: 88px; resize: vertical; }
.modal-body input[type="color"] { width: 100%; min-height: 44px; padding: 4px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; }
.modal-body input:not([type="hidden"]):focus, .modal-body select:focus, .modal-body textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); outline: 0; }
.modal-footer { display: flex; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-subtle); }
.modal-footer .button { margin: 0; }
.modal-footer .button:disabled { cursor: wait; opacity: .65; transform: none; }
.btn-close {
    position: relative;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #777584;
    opacity: 1;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.btn-close::before,
.btn-close::after {
    position: absolute;
    top: 15px;
    left: 8px;
    width: 15px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    content: "";
}
.btn-close::before { transform: rotate(45deg); }
.btn-close::after { transform: rotate(-45deg); }
.btn-close:hover { border-color: #dedce8; background: #f6f5fa; color: #373445; }
.modal-backdrop.show { opacity: .55; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background: #171622;
}
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: .55; }
.modal-eyebrow { display: block; margin-bottom: 5px; color: #888698; font-size: 9px; font-weight: 700; letter-spacing: 1.4px; }
.form-intro { margin: -2px 0 22px; padding-bottom: 16px; border-bottom: 1px solid #f0eff5; }
.form-intro p { margin: 0; color: #777584; font-size: 12px; line-height: 1.6; }
.plan-form-field { margin-top: 18px; }
.plan-form-field:first-of-type { margin-top: 0; }
.plan-form-field > label { display: block; margin-bottom: 7px; color: #4d4b5b; font-size: 12px; font-weight: 700; }
.plan-form-field > label > span { color: #cf5161; }
.plan-form-field .form-control { width: 100%; min-height: 44px; font-size: 13px; }
.plan-select { cursor: pointer; appearance: auto; }
.plan-form-field textarea.form-control { min-height: 88px; resize: vertical; }
.plan-product-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.plan-product-option { display: flex; align-items: center; gap: 9px; min-height: 54px; padding: 9px 11px; border: 1px solid #e8e7ef; border-radius: 7px; cursor: pointer; }
.plan-product-option:has(input:checked) { border-color: #a49cf8; background: #f7f6ff; }
.plan-product-option input { accent-color: var(--accent); }
.plan-product-option strong, .plan-product-option small { display: block; }
.plan-product-option strong { color: #4d4b5b; font-size: 11px; }
.plan-product-option small { margin-top: 3px; color: #92909f; font-size: 10px; }
.plan-product-options.is-invalid { outline: 1px solid #dc6b78; outline-offset: 3px; border-radius: 4px; }
.field-help, .field-error { display: block; margin-top: 6px; font-size: 11px; line-height: 1.4; }
.field-help { color: #92909f; }
.field-error { min-height: 15px; color: #c84456; }
.input-prefix { display: flex; align-items: stretch; width: 100%; }
.input-prefix > span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 0 10px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 7px 0 0 7px; background: var(--surface-subtle); color: #706e7d; font-size: 13px; font-weight: 600; }
.input-prefix input { min-width: 0; border-radius: 0 7px 7px 0 !important; }
.input-prefix:focus-within > span { border-color: var(--accent); color: var(--accent); }
.form-control.is-invalid { border-color: #dc6b78; box-shadow: 0 0 0 3px rgba(220, 107, 120, .13); }
.form-alert { margin-top: 18px; padding: 10px 12px; border: 1px solid #f1c4ca; border-radius: 7px; background: #fff5f6; color: #b33c4d; font-size: 12px; }

.setup-page-container { max-width: 920px; margin: 0 auto; }
.setup-card { border-radius: 14px; }
.scope-card { border-color: var(--border-strong); border-radius: 10px; transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease; }
.scope-card:hover, .scope-card--selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }

@media (max-width: 1100px) {
    .sidebar { width: 216px; min-width: 216px; }
    .content-grid { grid-template-columns: 1fr; }
    .quick-panel { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 18px; }
    .quick-panel .panel-head { grid-column: 1 / -1; }
    .quick-action { border-top: 0; border-right: 1px solid #f0eff4; padding: 12px 16px 12px 0; }
    .quick-action:last-child { border-right: 0; }
}

@media (max-width: 800px) {
    .app-shell { display: block; }
    .sidebar { width: 100%; min-width: 0; padding: 14px 16px; }
    .brand { padding: 0 4px 14px; }
    .workspace-label, .nav-group-label, .sidebar-bottom { display: none; }
    .side-nav { display: flex; gap: 6px; overflow-x: auto; }
    .side-nav a, .side-nav a.active { display: inline-flex; min-width: max-content; height: 36px; padding: 0 11px; }
    .side-nav a.active { box-shadow: inset 0 -3px var(--accent); }
    .main-content { padding-bottom: 32px; }
    .topbar { height: 58px; margin-bottom: 28px; }
    .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .top-actions { gap: 12px; }
    .top-actions .profile-link, .top-actions .auth-link { display: none; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .page-header h1 { font-size: 30px; }
    .header-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-panel { display: block; }
    .quick-action { border-top: 1px solid #f0eff4; border-right: 0; }
    .filterbar { align-items: stretch; }
    .search-box, .filter-select { flex: 1 1 100%; }
    .filter-submit { width: 100%; }
}

@media (max-width: 520px) {
    .main-content { padding-left: 16px; padding-right: 16px; }
    .page-header h1 { font-size: 27px; }
    .stat-grid { gap: 10px; }
    .stat-card { min-height: 130px; padding: 15px; }
    .stat-card strong { font-size: 24px; }
    .panel { padding: 18px; }
    .panel-head { flex-direction: column; }
    .panel-head .text-link { align-self: flex-start; }
    .detail-hero { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
    .detail-hero > div:nth-child(2) { flex: 1 1 calc(100% - 70px); }
    .detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .detail-actions .button { flex: 1 1 auto; justify-content: center; }
    .modal-dialog { margin: .5rem; min-height: calc(100% - 1rem); }
    .modal-body { max-height: 64vh; padding: 20px; }
    .modal-header, .modal-footer { padding: 16px 20px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .button { flex: 1 1 120px; justify-content: center; }
    .toast-message { top: 70px; right: 16px; left: 16px; width: auto; }
}

@media (max-width: 760px) {
    .sidebar-collapsed .sidebar { width: 100%; min-width: 0; padding: 14px 16px; }
    .sidebar-collapsed .brand > span:last-child, .sidebar-collapsed .workspace-label, .sidebar-collapsed .nav-group-label, .sidebar-collapsed .profile-mini > span:not(.avatar) { display: initial; }
    .sidebar-collapsed .brand { gap: 9px; padding-left: 14px; padding-right: 14px; }
    .sidebar-collapsed .side-nav a, .sidebar-collapsed .sidebar-bottom > a { justify-content: initial; padding-left: 11px; padding-right: 11px; }
}
