/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
  box-shadow: var(--sh-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-gradient { background: var(--brand-gradient); border: 0; color: #fff; }
.btn-gradient:hover { filter: brightness(1.06); background: var(--brand-gradient); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0E9F6E; border-color: #0E9F6E; }
.btn-danger { background: var(--surface); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-50); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-xs svg { width: 14px; height: 14px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-xs.btn-icon { width: 26px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }
.btn-group .btn.active { background: var(--primary-50); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); z-index: 1; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .err { font-size: 11.5px; color: var(--danger-ink); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input[readonly], .input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-2); }
.input-sm { height: 30px; font-size: 12.5px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .addon { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface-2); color: var(--text-3); font-size: 12px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 32px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { box-shadow: var(--focus); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-section { padding: 18px 0; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section h3 { margin-bottom: 12px; font-size: 14px; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 12px; color: var(--text-3); font-weight: 500; }
.card-body { padding: 14px 16px 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.card.flat { box-shadow: none; }
.card.pad { padding: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 12px; }
.section-title h2 { font-size: 15px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi {
  position: relative; text-align: left; padding: 14px 14px 12px; border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--sh-1); cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.kpi:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: var(--sh-2); }
.kpi:focus-visible { box-shadow: var(--focus); outline: none; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-label svg { width: 14px; height: 14px; }
.kpi-value { font-size: 20px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11.5px; color: var(--text-3); }
.kpi-spark { width: 70px; height: 24px; flex: none; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 11.5px; border-radius: 6px; padding: 1px 5px; }
.delta svg { width: 12px; height: 12px; }
.delta.up { color: var(--success-ink); background: var(--success-50); }
.delta.down { color: var(--danger-ink); background: var(--danger-50); }
.delta.flat { color: var(--neutral-ink); background: var(--neutral-50); }
.kpi-hero { background: radial-gradient(520px 160px at 100% 0%, rgba(124,58,237,.35), transparent), linear-gradient(130deg, #172554, #1E3A8A 70%, #2563EB); color: #fff; border: 0; }
.kpi-hero .kpi-label, .kpi-hero .kpi-foot { color: #C7D2FE; }
.kpi-hero .kpi-value { font-size: 26px; }
.kpi-hero .delta.up { background: rgba(16,185,129,.2); color: #6EE7B7; }
.kpi-hero .delta.down { background: rgba(239,68,68,.22); color: #FCA5A5; }
.kpi-hero .delta.flat { background: rgba(255,255,255,.12); color: #E0E7FF; }
.meter { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.kpi-hero .meter { background: rgba(255,255,255,.16); }
.kpi-hero .meter > span { background: linear-gradient(90deg, #93C5FD, #C4B5FD); }

/* Stat mini */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.stat .label { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.stat .value { font-size: 17px; font-weight: 750; margin-top: 2px; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--neutral-50); color: var(--neutral-ink); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.blue { background: var(--info-50); color: var(--info-ink); }
.badge.green { background: var(--success-50); color: var(--success-ink); }
.badge.amber { background: var(--warning-50); color: var(--warning-ink); }
.badge.red { background: var(--danger-50); color: var(--danger-ink); }
.badge.violet { background: var(--violet-50); color: var(--violet-ink); }
.badge.gray { background: var(--neutral-50); color: var(--neutral-ink); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.tag button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--text-3); line-height: 1; }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.prio-high { color: var(--danger-ink); } .prio-med { color: var(--warning-ink); } .prio-low { color: var(--text-3); }

/* Avatar */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11.5px; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 56px; height: 56px; font-size: 19px; border-radius: 14px; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-text { min-width: 0; line-height: 1.25; }
.who-text b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ===== Tables ===== */
.dt { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0; }
.dt-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.dt-toolbar .input-icon { flex: 1 1 220px; max-width: 320px; }
.dt-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dt-filters .select { height: 32px; width: auto; min-width: 130px; font-size: 12.5px; }
.dt-bulk { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--primary-50); border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--primary); }
.dt-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-3); font-weight: 650; font-size: 11.5px; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; letter-spacing: .01em; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { display: inline-block; width: 10px; margin-left: 3px; opacity: .8; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table tbody tr.selected { background: var(--primary-50); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.num, .table th.num { text-align: right; }
.table .doc-num { font-weight: 700; color: var(--text); }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); border-bottom: 0; }
.table.compact td { padding: 7px 10px; }
.table.compact th { padding: 7px 10px; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 12px; }
.pager button:hover:not([disabled]) { background: var(--surface-2); }
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button[disabled] { opacity: .45; cursor: default; }
.row-actions { display: inline-flex; gap: 2px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; font-weight: 600; font-size: 13px; color: var(--text-3); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .pill { height: 18px; font-size: 10.5px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; font-weight: 600; font-size: 12.5px; color: var(--text-3); cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* ===== Modal / drawer ===== */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fadeIn .15s ease; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); animation: popIn .2s var(--ease); border: 1px solid var(--border); }
.modal.lg { width: min(820px, 100%); }
.modal.xl { width: min(1100px, 100%); }
.modal.sm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-head h2 { font-size: 16px; }
.modal-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-3); }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); flex-wrap: wrap; }
.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer { width: min(560px, 100vw); height: 100vh; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--sh-3); animation: slideIn .22s var(--ease); border-left: 1px solid var(--border); }
.drawer.wide { width: min(760px, 100vw); }
.drawer .modal-foot { border-radius: 0; }
.drawer .modal-body { flex: 1; }
.close-x { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; display: grid; place-items: center; color: var(--text-3); cursor: pointer; flex: none; }
.close-x:hover { background: var(--surface-2); color: var(--text); }
.close-x svg { width: 18px; height: 18px; }

/* ===== Toasts ===== */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-3); animation: popIn .2s var(--ease); font-size: 13px; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }
.toast.info svg { color: var(--primary); }
.toast b { display: block; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-body span { color: var(--text-2); font-size: 12.5px; }

/* ===== Dropdown menu ===== */
.menu { position: fixed; z-index: 200; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--sh-3); padding: 6px; animation: popIn .12s var(--ease); max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.menu-item.danger { color: var(--danger-ink); }
.menu-item.danger svg { color: var(--danger-ink); }
.menu-item[disabled] { opacity: .45; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 6px 10px 4px; }

/* ===== Empty / skeleton ===== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; gap: 8px; color: var(--text-3); }
.empty-art { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); margin-bottom: 6px; }
.empty-art svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text); font-size: 15px; }
.empty p { max-width: 380px; margin: 0 0 6px; font-size: 13px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 0, var(--surface-3) 40%, var(--surface-2) 80%); background-size: 800px 100%; animation: shimmer 1.2s linear infinite; border-radius: 6px; }

/* ===== Alerts / callouts ===== */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; align-items: flex-start; }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.callout.info { background: var(--info-50); border-color: color-mix(in srgb, var(--primary) 25%, transparent); color: var(--text); }
.callout.info svg { color: var(--primary); }
.callout.warn { background: var(--warning-50); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.callout.warn svg { color: var(--warning-ink); }
.callout.danger { background: var(--danger-50); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger svg { color: var(--danger-ink); }
.callout.success { background: var(--success-50); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.callout.success svg { color: var(--success-ink); }
.callout b { display: block; margin-bottom: 2px; }

.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: var(--surface-2); }
.alert-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.alert-ico svg { width: 16px; height: 16px; }
.alert-ico.red { background: var(--danger-50); color: var(--danger-ink); }
.alert-ico.amber { background: var(--warning-50); color: var(--warning-ink); }
.alert-ico.blue { background: var(--info-50); color: var(--info-ink); }
.alert-ico.violet { background: var(--violet-50); color: var(--violet-ink); }
.alert-ico.green { background: var(--success-50); color: var(--success-ink); }
.alert-count { margin-left: auto; font-weight: 750; font-size: 15px; }

/* ===== Stepper / progress ===== */
.stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 4px 2px 2px; }
.step { flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; z-index: 1; }
.step .dot svg { width: 13px; height: 13px; }
.step.done { color: var(--text-2); }
.step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.done::before, .step.current::before { background: var(--success); }
.step.current { color: var(--primary); }
.step.current .dot { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 4px var(--primary-50); }
.step.current .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.step.bad .dot { background: var(--danger); border-color: var(--danger); color: #fff; }

.progress { height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; display: flex; }
.progress > span { height: 100%; }
.qty-bar { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.qty-bar .progress { height: 6px; }

/* ===== Timeline ===== */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 9px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.tl-dot { position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.tl-dot svg { width: 11px; height: 11px; }
.tl-title { font-weight: 600; font-size: 13px; }
.tl-meta { font-size: 11.5px; color: var(--text-3); }
.tl-note { margin-top: 4px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 6px 10px; border-radius: 8px; }

/* ===== Description list ===== */
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; font-size: 13px; margin: 0; }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; }
.kv span:first-child { color: var(--text-2); }
.kv.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 800; }
.kv.total span:first-child { color: var(--text); }

/* ===== Kanban ===== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 220px); min-height: 200px; }
.kb-col.drag-over { border-color: var(--primary); background: var(--primary-50); }
.kb-col.drop-bad { border-color: var(--danger); background: var(--danger-50); }
.kb-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-weight: 700; font-size: 12.5px; }
.kb-head .sum { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.kb-list { padding: 0 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; box-shadow: var(--sh-1); cursor: grab; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.kb-card:hover { border-color: var(--border-strong); }
.kb-card.dragging { opacity: .5; }
.kb-card:focus-visible { box-shadow: var(--focus); outline: none; }
.kb-card .kb-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kb-card .kb-num { font-weight: 700; color: var(--primary); font-size: 12px; }
.kb-card .kb-title { font-weight: 650; font-size: 13px; line-height: 1.3; }
.kb-card .kb-meta { display: flex; justify-content: space-between; align-items: center; color: var(--text-3); font-size: 11.5px; gap: 6px; }

/* ===== Notifications panel ===== */
.np { position: fixed; top: calc(var(--header-h) + 6px); right: 16px; width: min(400px, calc(100vw - 24px)); max-height: min(620px, calc(100vh - 90px)); z-index: 120; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--sh-3); animation: popIn .15s var(--ease); }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.np-list { overflow-y: auto; padding: 4px 6px 8px; }
.np-item { display: flex; gap: 10px; padding: 10px 8px; border-radius: 10px; cursor: pointer; position: relative; }
.np-item:hover { background: var(--surface-2); }
.np-item.unread::after { content: ""; position: absolute; right: 10px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.np-item .np-text { min-width: 0; padding-right: 14px; }
.np-item b { font-size: 13px; font-weight: 650; display: block; }
.np-item p { margin: 2px 0 0; font-size: 12px; color: var(--text-2); }
.np-item time { font-size: 11px; color: var(--text-3); }

/* ===== Command palette ===== */
.cmdk { position: fixed; inset: 0; z-index: 250; background: var(--overlay); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fadeIn .12s; }
.cmdk-box { width: min(640px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--sh-3); overflow: hidden; animation: popIn .15s var(--ease); }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 18px; height: 18px; color: var(--text-3); }
.cmdk-input input { flex: 1; height: 54px; border: 0; background: none; font-size: 15px; outline: none; }
.cmdk-list { max-height: 420px; overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.cmdk-item svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.cmdk-item .ci-sub { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.cmdk-item.active { background: var(--primary-50); color: var(--primary); }
.cmdk-item.active svg { color: var(--primary); }
.cmdk-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

/* ===== Charts ===== */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart text.axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: fixed; z-index: 400; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--sh-3); border-radius: 10px; padding: 8px 10px; font-size: 12px; min-width: 120px; max-width: 260px; }
.chart-tip .tt-title { font-weight: 700; margin-bottom: 4px; }
.chart-tip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-tip .tt-row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-empty { padding: 30px; text-align: center; color: var(--text-3); font-size: 13px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 12.5px; }
.funnel-bar { height: 30px; border-radius: 6px; display: flex; align-items: center; padding: 0 10px; color: #fff; font-weight: 700; font-size: 12px; min-width: 40px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; padding: 4px 0; cursor: default; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; }

/* ===== Login ===== */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 520px) 1fr; background: var(--surface); }
.login-left { display: flex; flex-direction: column; padding: 32px 44px; gap: 18px; overflow-y: auto; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand b { font-size: 17px; letter-spacing: .02em; }
.login-brand span { font-size: 12px; color: var(--text-3); display: block; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.login-form h1 { font-size: 26px; letter-spacing: -.02em; }
.login-profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.profile-btn { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; min-width: 0; transition: border-color .12s, background .12s; }
.profile-btn:hover { border-color: var(--primary); background: var(--primary-50); }
.profile-btn b { font-size: 12.5px; display: block; }
.profile-btn span { font-size: 11px; color: var(--text-3); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-right { position: relative; overflow: hidden; background: radial-gradient(900px 500px at 85% 0%, rgba(124,58,237,.55), transparent 60%), radial-gradient(800px 600px at 0% 100%, rgba(37,99,235,.45), transparent 60%), #0B1433; color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 48px; }
.login-right::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.lr-inner { position: relative; max-width: 760px; width: 100%; margin: 0 auto; }
.lr-title { font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; max-width: 560px; }
.lr-sub { color: #B9C5F5; margin: 10px 0 26px; max-width: 520px; font-size: 14px; }
.glass { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.lr-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.lr-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.lr-kpi { padding: 12px 14px; }
.lr-kpi span { font-size: 11px; color: #AFC0F7; font-weight: 600; }
.lr-kpi b { display: block; font-size: 18px; margin-top: 2px; }
.lr-card { padding: 14px; }
.lr-card h4 { font-size: 12px; color: #C7D2FE; font-weight: 600; margin-bottom: 10px; }
.lr-doc { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.lr-doc:last-child { border-bottom: 0; }
.lr-doc em { font-style: normal; font-size: 10.5px; padding: 2px 7px; border-radius: 9px; background: rgba(255,255,255,.12); }
.lr-float { position: absolute; right: -10px; bottom: -22px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; font-size: 12px; animation: popIn .6s .3s var(--ease) both; }

/* ===== Quote builder ===== */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.builder-side { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 12px; }
.lines { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.lines th { text-align: left; font-size: 11px; color: var(--text-3); font-weight: 650; padding: 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lines td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines .input, .lines .select { height: 32px; font-size: 12.5px; padding: 0 8px; }
.lines .select { padding-right: 24px; background-position: right 6px center; }
.lines .w-qty { width: 76px; } .lines .w-price { width: 122px; } .lines .w-disc { width: 66px; } .lines .w-tax { width: 96px; } .lines .w-total { width: 116px; }
.line-prod b { display: block; font-size: 12.5px; }
.line-prod span { font-size: 11px; color: var(--text-3); }
.line-note td { background: var(--surface-2); }
.line-section td { background: var(--primary-50); font-weight: 700; }
.drag-handle { cursor: grab; color: var(--text-3); background: none; border: 0; padding: 4px; border-radius: 6px; }
.drag-handle svg { width: 15px; height: 15px; }
.line-drag-over td { border-top: 2px solid var(--primary); }
.prod-search { position: relative; }
.prod-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--sh-3); max-height: 320px; overflow-y: auto; padding: 4px; }
.prod-res { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; }
.prod-res:hover, .prod-res.active { background: var(--primary-50); }
.stock-ok { color: var(--success-ink); } .stock-low { color: var(--warning-ink); } .stock-out { color: var(--danger-ink); }
.rule-list { display: flex; flex-direction: column; gap: 6px; }
.rule-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--warning-50); color: var(--text); }
.rule-item svg { width: 15px; height: 15px; color: var(--warning-ink); flex: none; margin-top: 2px; }
.rule-item.l2 { background: var(--danger-50); }
.rule-item.l2 svg { color: var(--danger-ink); }

/* ===== Product cards ===== */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.prod-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.prod-card:hover { border-color: var(--border-strong); box-shadow: var(--sh-2); }
.prod-img { height: 110px; display: grid; place-items: center; color: #fff; position: relative; }
.prod-img svg { width: 42px; height: 42px; opacity: .95; }
.prod-img .badge { position: absolute; top: 8px; left: 8px; background: rgba(255,255,255,.92); color: #0F172A; }
.prod-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.prod-body b { font-size: 13px; line-height: 1.3; }
.prod-body .price { font-weight: 800; font-size: 15px; margin-top: auto; padding-top: 6px; }

/* ===== Calendar ===== */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.cal-h { padding: 8px; font-size: 11.5px; font-weight: 700; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: center; }
.cal-d { min-height: 104px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.out { background: var(--surface-2); }
.cal-d.out .cal-n { color: var(--text-3); opacity: .6; }
.cal-d.today .cal-n { background: var(--primary); color: #fff; }
.cal-n { font-size: 11.5px; font-weight: 700; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--primary-50); color: var(--info-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border: 0; text-align: left; }
.cal-ev.done { text-decoration: line-through; opacity: .6; }
.cal-ev.t-call { background: var(--success-50); color: var(--success-ink); }
.cal-ev.t-meeting { background: var(--violet-50); color: var(--violet-ink); }
.cal-ev.t-task { background: var(--warning-50); color: var(--warning-ink); }
.cal.week .cal-d { min-height: 260px; }

/* ===== Misc ===== */
.health { display: flex; align-items: center; gap: 14px; }
.health-ring { width: 72px; height: 72px; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.sig-pad { border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); touch-action: none; width: 100%; height: 150px; cursor: crosshair; }
.ai-msg { display: flex; gap: 10px; margin-bottom: 14px; }
.ai-msg .bubble { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); max-width: 820px; font-size: 13px; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.user .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.ai-bot { width: 32px; height: 32px; border-radius: 10px; background: var(--brand-gradient); display: grid; place-items: center; color: #fff; flex: none; }
.ai-bot svg { width: 17px; height: 17px; }
.integration { display: flex; flex-direction: column; gap: 10px; }
.int-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; }
.diff-up { background: var(--success-50); }
.diff-down { background: var(--danger-50); }
.diff-chg { background: var(--warning-50); }
.loader { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin .7s linear infinite; }
.backdrop-mobile { display: none; }
