:root {
    --primary: #009dda;
    --primary-dark: #007eaf;
    --primary-soft: #eaf7fc;
    --navy: #18212b;
    --slate: #68727d;
    --muted: #98a0a8;
    --surface: #ffffff;
    --canvas: #f5f7f9;
    --border: #e4e9ed;
    --success: #05875d;
    --success-soft: #e8f8f1;
    --warning: #b96805;
    --warning-soft: #fff4dc;
    --danger: #c93645;
    --danger-soft: #feedef;
    --purple: #7251b5;
    --shadow-sm: 0 1px 2px rgba(24, 33, 43, .04), 0 4px 14px rgba(24, 33, 43, .035);
    --shadow-lg: 0 22px 60px rgba(24, 33, 43, .12);
    --radius: 14px;
    --sidebar: 258px;
}

/* v1.1: shared controls, branding and compact account screens. */
.ui-icon { display: block; width: 21px; height: 21px; flex: 0 0 auto; }
.sr-only, .search-select-native { position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.search-select { position: relative; min-width: 0; width: 100%; flex: 1 1 180px; }
.search-select-input { width: 100%; padding-right: 30px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2368727d' stroke-width='1.7'%3E%3Ccircle cx='7.5' cy='7.5' r='4.5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") !important; background-repeat: no-repeat !important; background-position: right 10px center !important; }
.search-select-menu { position: fixed; z-index: 2000; overflow-y: auto; overscroll-behavior: contain; padding: 5px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.search-select-option { padding: 9px 10px; border-radius: 6px; color: var(--navy); cursor: pointer; overflow-wrap: anywhere; }
.search-select-option:hover, .search-select-option.is-active { background: var(--primary-soft); }
.search-select-option[aria-selected=true] { color: var(--primary-dark); font-weight: 700; }
.search-select-note { padding: 10px; color: var(--slate); font-size: 12px; }
.search-select-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.search-select-tags:not(:empty) { padding-top: 6px; }
.search-select-clear { margin-top:6px; padding:2px 0; border:0; background:none; color:var(--primary-dark); font-size:12px; text-decoration:underline; }
.search-select-tag { max-width: 100%; border: 1px solid #cce8f2; background: var(--primary-soft); color: var(--primary-dark); padding: 3px 8px; border-radius: 6px; font-size: 12px; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.pagination { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--border); }
.pagination-links { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.pagination-links [aria-current=page] { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-summary { color: var(--slate); font-size: 13px; }

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--navy);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar);
    padding: 20px 14px;
    border-right: 1px solid var(--border);
    background: #fff;
    flex-direction: column;
    transition: transform .22s ease;
}
.brand { display: flex; height: 88px; min-height: 88px; padding: 4px 9px 16px; align-items: center; justify-content: center; flex: 0 0 auto; }
.brand img { display: block; width: 100%; max-width: 202px; height: 66px; object-fit: contain; object-position: center; }
.sidebar nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.sidebar-label { padding: 15px 12px 6px; color: #a1a9b1; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav-link {
    display: flex;
    min-height: 43px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #4a5661;
    font-weight: 600;
    gap: 11px;
    align-items: center;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: #f3f8fa; color: var(--navy); }
.nav-link.active { background: var(--primary-soft); color: #0078a8; }
.nav-icon { display: grid; width: 22px; height: 22px; color: currentColor; font-size: 17px; place-items: center; }
.nav-count { min-width: 21px; padding: 1px 6px; margin-left: auto; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; text-align: center; }
.sidebar-footer { padding-top: 14px; margin-top: auto; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; padding: 9px; border-radius: 11px; gap: 10px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); object-fit: cover; flex: 0 0 auto; }
.sidebar-user-copy { min-width: 0; flex: 1; }
.sidebar-user-name { display: block; overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.app-content { min-width: 0; padding-left: var(--sidebar); }
.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    height: 69px;
    padding: 0 30px;
    border-bottom: 1px solid rgba(228, 233, 237, .9);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(14px);
    align-items: center;
    justify-content: space-between;
}
.mobile-menu { display: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--primary-soft); color: var(--navy); font-size: 21px; }
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-button { position: relative; display: grid; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 11px; background: #fff; color: var(--slate); place-items: center; }
.icon-button:hover { border-color: #bcd8e3; color: var(--primary-dark); }
.icon-dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--danger); }
.main { width: 100%; max-width: 1600px; padding: 28px 30px 52px; margin: 0 auto; }
.sidebar-backdrop { display: none; }

.page-header { display: flex; margin-bottom: 23px; gap: 18px; align-items: flex-start; justify-content: space-between; }
.page-title { margin: 0; color: var(--navy); font-size: clamp(24px, 3vw, 31px); font-weight: 750; letter-spacing: -.035em; line-height: 1.2; }
.page-subtitle { max-width: 760px; margin: 6px 0 0; color: var(--slate); }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-header { display: flex; min-height: 62px; padding: 16px 19px; border-bottom: 1px solid var(--border); gap: 12px; align-items: center; justify-content: space-between; }
.card-header h2, .card-header h3 { margin: 0; font-size: 16px; letter-spacing: -.015em; }
.card-body { padding: 19px; }
.card-footer { padding: 13px 19px; border-top: 1px solid var(--border); background: #fbfcfd; border-radius: 0 0 var(--radius) var(--radius); }
.metric-card { position: relative; overflow: hidden; padding: 20px; }
.metric-card::after { position: absolute; width: 76px; height: 76px; border-radius: 50%; background: var(--primary-soft); content: ""; right: -24px; top: -24px; }
.metric-label { color: var(--slate); font-size: 12px; font-weight: 650; }
.metric-value { display: block; margin-top: 7px; font-size: 30px; font-weight: 760; letter-spacing: -.04em; line-height: 1.1; }
.metric-link { display: inline-flex; margin-top: 12px; font-size: 12px; font-weight: 700; }
.section-stack { display: grid; margin-top: 18px; gap: 18px; }
.empty-state { padding: 34px 20px; color: var(--slate); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--navy); font-size: 15px; }

.button { display: inline-flex; min-height: 39px; padding: 8px 14px; border: 1px solid transparent; border-radius: 9px; background: var(--primary); color: #fff; font-weight: 700; line-height: 1.2; gap: 7px; align-items: center; justify-content: center; transition: .15s ease; }
.button:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.button-secondary { border-color: var(--border); background: #fff; color: var(--navy); }
.button-secondary:hover { border-color: #bad6e1; background: var(--primary-soft); color: var(--primary-dark); }
.button-danger { background: var(--danger); }
.button-danger:hover { background: #a92a36; }
.button-success { background: var(--success); }
.button-warning { background: var(--warning); }
.button-ghost { border-color: transparent; background: transparent; color: var(--slate); }
.button-small { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.button-block { width: 100%; }
.link-button { padding: 0; border: 0; background: none; color: var(--primary-dark); font-weight: 650; }
.inline-form { display: inline-flex; }
.button-row { display: flex; margin-top: 18px; gap: 9px; flex-wrap: wrap; }
.form-grid + .button, .form-grid + .button-row { margin-top: 20px; }
.auth-box form > .button-block { margin-top: 22px; }
.auth-box .field > .control + .button { margin-top: 14px; }
.field > .control + .help { margin-top: 7px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.field { grid-column: span 12; min-width: 0; }
.field-3 { grid-column: span 3; }
.field-4 { grid-column: span 4; }
.field-6 { grid-column: span 6; }
.field-8 { grid-column: span 8; }
.field-9 { grid-column: span 9; }
.label { display: flex; margin-bottom: 6px; color: #35414c; font-size: 12px; font-weight: 750; gap: 6px; align-items: center; }
.required { color: var(--danger); }
.control { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #d8dfe4; border-radius: 9px; outline: none; background: #fff; color: var(--navy); transition: border-color .15s, box-shadow .15s; }
.control:hover { border-color: #bdc9d1; }
.control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 157, 218, .12); }
.control[readonly], .control:disabled { background: #f3f5f7; color: var(--slate); }
textarea.control { min-height: 105px; resize: vertical; }
select.control { appearance: auto; }
.help { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.error-text { margin: 5px 0 0; color: var(--danger); font-size: 12px; font-weight: 600; }
.has-error .control { border-color: var(--danger); }
.check-row { display: flex; min-height: 38px; gap: 8px; align-items: center; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.input-group { display: flex; }
.input-group .control { border-radius: 9px 0 0 9px; }
.input-prefix, .input-suffix { display: flex; padding: 0 11px; border: 1px solid #d8dfe4; background: #f6f8f9; color: var(--slate); align-items: center; }
.input-prefix { border-right: 0; border-radius: 9px 0 0 9px; }
.input-prefix + .control { border-radius: 0 9px 9px 0; }
.field-label-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.field-label-row .label { margin: 0; min-width: 0; overflow-wrap: anywhere; flex-wrap: wrap; }
.question-help { display: inline-grid; width: 28px; height: 28px; padding: 0; flex: 0 0 auto; border: 1px solid #b8c8d0; border-radius: 50%; color: var(--primary-dark); background: #fff; font-size: 14px; font-weight: 700; place-items: center; cursor: pointer; }
.question-help:hover, .question-help[aria-expanded=true] { background: var(--primary-soft); border-color: var(--primary); }
.question-help:focus-visible { outline: 3px solid #9ed5e9; outline-offset: 2px; }
.field-hint { margin: 0 0 12px; padding: 13px 15px; border-left: 3px solid var(--primary); border-radius: 8px; background: var(--primary-soft); color: #355061; font-size: 13px; overflow-wrap: anywhere; }
.field-hint p { margin: 0; line-height: 1.65; }
.field-hint-close { margin-top: 8px; padding: 0; background: transparent; border: 0; color: var(--primary-dark); font-size: 12px; text-decoration: underline; }
.user-picker { position: relative; }
.user-picker-results { position:absolute; top:100%; left:0; right:0; z-index:60; border:1px solid var(--border); background:#fff; box-shadow:var(--shadow-lg); border-radius:8px; max-height:250px; overflow:auto; }
.user-picker-results[hidden] { display:none; }
.user-picker-option { display:block; width:100%; padding:10px 12px; background:white; border:0; border-bottom:1px solid #f1f5f9; text-align:left; cursor:pointer; color:var(--navy); font:inherit; font-size:13px; }
.user-picker-option:hover,.user-picker-option:focus { background:var(--primary-soft); }
.user-picker-option small { display:block; color:var(--slate); margin-top:2px; }
.user-picker-note { padding:10px 12px; color:var(--slate); font-size:12px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc; color: #6d7780; font-size: 10px; font-weight: 800; letter-spacing: .065em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdfe; }
.table-primary { font-weight: 700; }
.table-secondary { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.nowrap { white-space: nowrap; }
.badge { display: inline-flex; min-height: 23px; padding: 3px 8px; border-radius: 999px; background: #eef2f5; color: #52606b; font-size: 11px; font-weight: 750; align-items: center; white-space: nowrap; }
.badge-blue { background: var(--primary-soft); color: #0079aa; }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-yellow { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: #f1ecfb; color: var(--purple); }
.badge-status { color: var(--status-color, #52606b); border: 1px solid color-mix(in srgb, var(--status-color, #52606b) 28%, white); background: color-mix(in srgb, var(--status-color, #52606b) 10%, white); }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.rich-editor { min-height: 150px; overflow: auto; background: #fff; }
.rich-editor:focus { outline: 2px solid rgba(0, 157, 218, .18); border-color: var(--primary); }
.workflow-subsection { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.workflow-subsection .card-header { padding: 0 0 10px; border: 0; }

.alert { display: flex; padding: 13px 15px; margin-bottom: 18px; border: 1px solid; border-radius: 11px; gap: 10px; align-items: flex-start; }
.alert-success { border-color: #bce8d5; background: var(--success-soft); color: #086b4c; }
.alert-error { border-color: #f2c4c9; background: var(--danger-soft); color: #9e2935; }
.alert-info { border-color: #c7e6f1; background: var(--primary-soft); color: #16647f; }

.auth-page { display: grid; min-height: 100vh; background: #fff; grid-template-columns: minmax(360px, 46%) 1fr; }
.auth-visual { position: relative; display: flex; overflow: hidden; padding: clamp(38px, 6vw, 80px); background: linear-gradient(145deg, #102330 0%, #123e50 56%, #007eaf 100%); color: #fff; flex-direction: column; justify-content: space-between; }
.auth-visual::before, .auth-visual::after { position: absolute; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; content: ""; }
.auth-visual::before { width: 440px; height: 440px; right: -180px; top: -140px; }
.auth-visual::after { width: 270px; height: 270px; left: -100px; bottom: -80px; }
.auth-mark { position: relative; width: 215px; z-index: 1; }
.auth-copy { position: relative; z-index: 1; max-width: 560px; }
.auth-copy h1 { max-width: 520px; margin: 0 0 17px; font-size: clamp(32px, 5vw, 54px); letter-spacing: -.05em; line-height: 1.04; }
.auth-copy p { max-width: 500px; margin: 0; color: rgba(255,255,255,.73); font-size: 16px; line-height: 1.7; }
.auth-credit { position: relative; z-index: 1; color: rgba(255,255,255,.6); font-size: 11px; }
.auth-panel { display: grid; padding: 36px; place-items: center; }
.auth-box { width: min(430px, 100%); }
.auth-mobile-brand { display: none; width: 205px; margin-bottom: 35px; }
.auth-box h2 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.035em; }
.auth-box > p { margin: 0 0 25px; color: var(--slate); }
.auth-links { display: flex; margin-top: 18px; color: var(--slate); font-size: 12px; justify-content: space-between; }
.auth-links a { font-weight: 700; }

.tabs { display: flex; overflow-x: auto; padding: 5px; border: 1px solid var(--border); border-radius: 11px; background: #eef2f4; gap: 4px; }
.tab-button { min-height: 34px; padding: 7px 13px; border: 0; border-radius: 8px; background: transparent; color: var(--slate); font-size: 12px; font-weight: 700; white-space: nowrap; }
.tab-button.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(24,33,43,.09); }
.tab-panel { display: none; margin-top: 18px; }
.tab-panel.active { display: block; }

.builder-shell { display: grid; grid-template-columns: 225px minmax(380px, 1fr) 290px; gap: 16px; align-items: start; }
.builder-panel { position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow: auto; }
.palette-grid { display: grid; padding: 13px; gap: 7px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.palette-item { display: flex; min-height: 64px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #4b5964; font-size: 11px; font-weight: 700; text-align: center; flex-direction: column; gap: 4px; align-items: center; justify-content: center; cursor: grab; }
.palette-item:hover { border-color: #9ed5e9; background: var(--primary-soft); color: var(--primary-dark); }
.palette-symbol { font-size: 18px; line-height: 1; }
.builder-canvas { min-height: 500px; padding: 18px; border: 2px dashed #dce5e9; border-radius: var(--radius); background: #f9fbfc; }
.builder-empty { display: grid; min-height: 455px; color: var(--muted); place-items: center; text-align: center; }
.builder-fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.builder-field { position: relative; grid-column: span 12; min-width: 0; padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: #fff; cursor: pointer; }
.builder-field:hover, .builder-field.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,157,218,.08); }
.builder-field.dragging { opacity: .48; }
.builder-field-title { padding-right: 65px; font-weight: 700; }
.builder-field-meta { margin-top: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.builder-field-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.mini-action { display: grid; width: 27px; height: 27px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--slate); place-items: center; }
.mini-action:hover { border-color: #bdd9e3; color: var(--primary-dark); }
.property-stack { display: grid; padding: 14px; gap: 12px; }
.property-empty { padding: 30px 15px; color: var(--muted); text-align: center; }
.property-stack .label { font-size: 11px; }
.property-stack .control { min-height: 37px; padding: 7px 9px; font-size: 12px; }
.workflow-canvas { display: grid; padding: 16px; gap: 13px; }
.workflow-stage { position: relative; padding: 16px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 11px; background: #fff; }
.workflow-stage::after { position: absolute; width: 2px; height: 14px; bottom: -14px; left: 34px; background: #bfdae4; content: ""; }
.workflow-stage:last-child::after { display: none; }
.workflow-stage-head { display: flex; margin-bottom: 13px; gap: 10px; align-items: center; justify-content: space-between; }
.workflow-stage-number { display: grid; width: 28px; height: 28px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 800; place-items: center; }
.workflow-stage-title { margin-right: auto; font-weight: 750; }
.condition-row, .assignee-row { display: grid; margin-top: 9px; grid-template-columns: 1fr 1fr 1fr auto; gap: 7px; }
.builder-toolbar { display: flex; margin-bottom: 15px; gap: 9px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.builder-savebar { position: sticky; z-index: 20; bottom: 14px; display: flex; padding: 11px; margin-top: 20px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-lg); backdrop-filter: blur(12px); gap: 8px; justify-content: flex-end; }

.form-section { padding: 20px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.form-section-title { margin: 0 0 4px; font-size: 18px; }
.form-section-description { margin: 0 0 18px; color: var(--slate); }
.repeater-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.repeater-table th, .repeater-table td { padding: 7px; border-bottom: 1px solid var(--border); text-align: left; }
.repeater-table .control { min-height: 36px; }
.signature-wrap { overflow: hidden; border: 1px solid #d8dfe4; border-radius: 10px; background: #fff; }
.signature-canvas { display: block; width: 100%; height: 170px; touch-action: none; }
.signature-tools { display: flex; padding: 8px; border-top: 1px solid var(--border); background: #f8fafb; justify-content: flex-end; }

.details-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 18px; align-items: start; }
.data-list { display: grid; margin: 0; }
.data-row { display: grid; padding: 13px 0; border-bottom: 1px solid var(--border); grid-template-columns: minmax(140px, 34%) 1fr; gap: 18px; }
.data-row:last-child { border-bottom: 0; }
.data-label { color: var(--slate); font-size: 12px; font-weight: 700; }
.data-value { min-width: 0; overflow-wrap: anywhere; }
.timeline { position: relative; display: grid; padding-left: 20px; gap: 18px; }
.timeline::before { position: absolute; inset: 5px auto 5px 4px; width: 2px; background: #dce6ea; content: ""; }
.timeline-item { position: relative; }
.timeline-item::before { position: absolute; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px #bce3f1; content: ""; left: -20px; top: 4px; }
.timeline-title { font-weight: 700; }
.timeline-meta { margin-top: 2px; color: var(--muted); font-size: 11px; }
.timeline-note { margin-top: 5px; color: var(--slate); font-size: 12px; }

.store-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-card { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); }
.product-image { width: 100%; aspect-ratio: 4/2.3; background: var(--primary-soft); object-fit: cover; }
.product-body { padding: 15px; }
.product-category { color: var(--primary-dark); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.product-name { margin: 5px 0 3px; font-size: 16px; }
.product-description { min-height: 42px; margin: 0; color: var(--slate); font-size: 12px; }
.product-footer { display: flex; margin-top: 15px; gap: 10px; align-items: center; justify-content: space-between; }
.product-price { font-size: 18px; font-weight: 800; }
.quantity { width: 70px; }
.stocktake-quantity { min-width: 110px; }
.stocktake-note { min-width: 190px; }
.stocktake-table td:first-child { min-width: 210px; }
.cart-bar { position: sticky; z-index: 20; bottom: 14px; display: flex; padding: 14px 17px; margin-top: 20px; border: 1px solid #bfe1ee; border-radius: 13px; background: rgba(255,255,255,.95); box-shadow: var(--shadow-lg); gap: 14px; align-items: center; justify-content: flex-end; backdrop-filter: blur(10px); }
.cart-total { margin-right: auto; }
.cart-total strong { display: block; font-size: 20px; }
.cart-total span { color: var(--slate); font-size: 11px; }

.filter-bar { display: flex; padding: 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 12px; background: #fff; gap: 9px; align-items: center; flex-wrap: wrap; }
.filter-bar .control { width: auto; min-width: 150px; flex: 1; }
.search-control { min-width: min(340px, 100%) !important; }
.meta-list { display: grid; gap: 9px; }
.meta-item { display: flex; gap: 12px; justify-content: space-between; }
.meta-item span:first-child { color: var(--slate); }
.code { padding: 2px 5px; border-radius: 5px; background: #eef2f4; color: #45525d; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.muted { color: var(--slate); }
.small { font-size: 12px; }
.sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

dialog { width: min(680px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 15px; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(14, 25, 34, .48); backdrop-filter: blur(2px); }
.dialog-header { display: flex; padding: 17px 19px; border-bottom: 1px solid var(--border); align-items: center; justify-content: space-between; }
.dialog-header h2 { margin: 0; font-size: 18px; }
.dialog-body { max-height: 70vh; overflow: auto; padding: 19px; }
.dialog-close { border: 0; background: transparent; color: var(--slate); font-size: 24px; }
.action-dialog { width: min(540px, calc(100vw - 30px)); }
.action-dialog-message { margin: 0; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.action-dialog-actions { justify-content: flex-end; gap: 10px; margin-top: 24px; }
.delete-dialog .dialog-body > p:first-child { margin-top: 0; }
.delete-dialog .deletion-option { margin: 20px 0; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.delete-dialog .deletion-option .help:last-child { margin-bottom: 0; }
.delete-dialog .button-row { justify-content: flex-end; }
@media (max-width: 480px) { .action-dialog-actions { flex-wrap: wrap; } .action-dialog-actions .button { flex: 1; } }
.accordion { border-top: 1px solid var(--border); }
.accordion summary { padding: 13px 0; font-weight: 700; cursor: pointer; }

@media (max-width: 1240px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .store-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .builder-shell { grid-template-columns: 195px minmax(360px, 1fr); }
    .builder-shell > :last-child { position: static; max-height: none; grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 35; inset: 0; background: rgba(18,31,41,.35); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-content { padding-left: 0; }
    .mobile-menu { display: grid; place-items: center; }
    .topbar { height: 62px; padding: 0 18px; }
    .main { padding: 22px 18px 42px; }
    .auth-page { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
    .auth-panel { min-height: 100vh; padding: 25px; }
    .auth-mobile-brand { display: block; }
    .details-grid { grid-template-columns: 1fr; }
    .builder-shell { grid-template-columns: 1fr; }
    .builder-panel { position: static; max-height: none; }
    .palette-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: auto; }
    .page-header { flex-direction: column; }
    .page-actions { width: 100%; justify-content: flex-start; }
    .field-3, .field-4, .field-6, .field-8, .field-9 { grid-column: span 12; }
    .data-row { grid-template-columns: 1fr; gap: 3px; }
    .store-grid { grid-template-columns: 1fr; }
    .palette-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .condition-row, .assignee-row { grid-template-columns: 1fr; }
    .cart-bar { align-items: stretch; flex-direction: column; }
    .cart-total { margin-right: 0; }
    .cart-bar .button { width: 100%; }
    .table th, .table td { padding: 10px 9px; }
}

.auth-page.auth-page-centred { grid-template-columns: 1fr; background: var(--canvas); }
.auth-page-centred .auth-panel { min-height: 100vh; padding: 32px 20px; }
.auth-page-centred .auth-box { width: min(450px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: var(--shadow-sm); }
.auth-company-brand { display: flex; justify-content: center; align-items: center; margin: 0 0 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.auth-company-brand img { width: 100%; max-width: 240px; height: 104px; object-fit: contain; }
@media (max-width: 480px) {
    .auth-page-centred .auth-box { padding: 25px 22px; }
    .auth-company-brand img { height: 88px; }
    .pagination { padding: 14px; }
}

@media print {
    .sidebar, .topbar, .page-actions, .button, .filter-bar { display: none !important; }
    .app-content { padding: 0; }
    .main { max-width: none; padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}
.alert[data-archive-prompt][hidden]{display:none}
