:root {
  --ant-primary: #1677ff;
  --ant-primary-hover: #4096ff;
  --ant-primary-active: #0958d9;
  --ant-primary-bg: #e6f4ff;
  --ant-success: #52c41a;
  --ant-warning: #faad14;
  --ant-error: #ff4d4f;
  --ant-text: rgba(0, 0, 0, 0.88);
  --ant-text-secondary: rgba(0, 0, 0, 0.65);
  --ant-text-tertiary: rgba(0, 0, 0, 0.45);
  --ant-border: #d9d9d9;
  --ant-border-secondary: #f0f0f0;
  --ant-fill: #f5f5f5;
  --ant-sider: #001529;
  --ant-header-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  --ant-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02);
  --ant-radius: 6px;
  --brand: var(--ant-primary);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 14px;
  line-height: 1.5715;
  color: var(--ant-text);
  background: var(--ant-fill);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden, .skip {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.skip:focus { position: static; width: auto; height: auto; margin: 8px; clip: auto; background: white; padding: 8px; }

a { color: var(--ant-primary); text-decoration: none; }
a:hover { color: var(--ant-primary-hover); }
:focus-visible { outline: 2px solid var(--ant-primary); outline-offset: 1px; }

h1, h2, h3, h4 { font-family: inherit; font-weight: 600; letter-spacing: 0; margin: 0; color: var(--ant-text); }
h1 { font-size: 20px; line-height: 28px; }
h2 { font-size: 16px; line-height: 24px; }
p { line-height: 1.5715; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: #f5f5f5; }
.sidebar {
  background: #fff;
  color: var(--ant-text);
  padding: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ant-border-secondary);
}
.brand {
  display: flex; gap: 10px; align-items: center;
  height: 64px; padding: 0 16px;
  color: var(--ant-text);
  background: #fff;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ant-primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 16px;
}
.brand small { display: block; color: var(--ant-text-tertiary); font-size: 12px; letter-spacing: 0; text-transform: none; }
.brand strong { font-size: 16px; font-weight: 600; color: var(--ant-text); }
.sidebar nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 2px; overflow: auto; }
.nav-link {
  color: var(--ant-text); text-decoration: none;
  padding: 0 12px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.nav-icon { width: 16px; height: 16px; flex: none; }
.nav-link:hover { color: var(--ant-primary); background: #f5f5f5; }
.nav-link[aria-current="page"] { background: var(--ant-primary-bg); color: var(--ant-primary); font-weight: 500; }
.sidebar-foot { margin-top: auto; color: var(--ant-text-tertiary); font-size: 12px; padding: 16px; }

.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  height: 64px; padding: 0 24px;
  background: #fff;
  box-shadow: var(--ant-header-shadow);
  position: sticky; top: 0; z-index: 10;
}
.search-form { display: flex; flex: 1 1 160px; max-width: 280px; min-width: 0; }
.search-field { position: relative; width: 100%; }
.search-field input {
  border-radius: 8px;
  background: #f5f5f5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238c8c8c' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M11 11l3 3'/%3E%3C/svg%3E") 10px center no-repeat;
  padding-left: 32px;
}
.page { padding: 24px; display: flex; flex-direction: column; gap: 16px; background: #f5f5f5; min-width: 0; overflow: auto; }
.page-head, .head-actions, .filters, .inline-form, .button-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head { justify-content: space-between; align-items: flex-end; }
.eyebrow { font-size: 13px; color: var(--ant-text-tertiary); margin: 0 0 2px; text-transform: none; letter-spacing: 0; }
.who { margin-left: auto; text-align: right; font-size: 14px; display: flex; align-items: center; gap: 12px; flex: none; }
.who-id { display: flex; flex-direction: column; line-height: 1.2; align-items: flex-end; }
.who span { color: var(--ant-text-tertiary); font-size: 12px; }
.who strong { font-weight: 600; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.avatar-xl { width: 72px; height: 72px; font-size: 28px; }
turbo-frame#contact_preview { display: none; }
turbo-frame#contact_preview:has(.contact-preview) {
  display: block; position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.45);
}
.contact-preview {
  position: absolute; top: 0; right: 0; width: min(440px, 100%); height: 100%;
  background: #fff; overflow: auto; padding: 28px 24px 40px;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
}
.preview-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.preview-head h1 { margin: 0; font-size: 22px; line-height: 30px; }
.preview-close {
  margin-left: auto; width: 32px; height: 32px; display: grid; place-items: center;
  font-size: 28px; line-height: 1; color: var(--ant-text-secondary); border-radius: 6px;
}
.preview-close:hover { background: #f5f5f5; color: var(--ant-text); }
.preview-field { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--ant-border-secondary); }
.preview-field > div { flex: 1; min-width: 0; }
.preview-value { font-size: 14px; word-break: break-word; }
.preview-edit { margin-top: 10px; color: var(--ant-text-tertiary); }
.preview-edit:hover { color: var(--ant-primary); }
.preview-stage { padding: 16px 0; }
.stage-track { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.stage-track form { display: inline-flex; margin: 0; }
button.stage-pill, span.stage-pill {
  height: 32px; border-radius: 16px; padding: 0 14px; background: #fff; color: var(--ant-text);
  border: 1px solid var(--ant-border); box-shadow: none; font-size: 14px;
}
button.stage-pill.is-done, button.stage-pill.is-current, span.stage-pill.is-current {
  background: var(--ant-primary); border-color: var(--ant-primary); color: #fff;
}
button.stage-pill.is-bad, span.stage-pill.is-bad { background: var(--ant-error); border-color: var(--ant-error); color: #fff; }
.preview-notes h2 { margin: 8px 0 12px; font-size: 16px; }
.note-compose { margin-bottom: 8px; }
.note-compose input { width: 100%; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.quote-back { align-self: flex-start; }
.quote-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.quote-titlebar h1 { margin: 0; font-size: 24px; }
.quote-steps { display: flex; align-items: center; flex-wrap: wrap; }
.quote-step {
  position: relative; display: inline-flex; align-items: center; height: 32px;
  padding: 0 18px 0 26px; background: #fff; color: var(--ant-text-secondary); font-size: 14px;
}
.quote-step:nth-child(1) { z-index: 5; }
.quote-step:nth-child(2) { z-index: 4; }
.quote-step:nth-child(3) { z-index: 3; }
.quote-step:nth-child(4) { z-index: 2; }
.quote-step:nth-child(5) { z-index: 1; }
.quote-step:first-child { padding-left: 16px; border-radius: 16px 0 0 16px; }
.quote-step:last-child { padding-right: 16px; border-radius: 0 16px 16px 0; }
.quote-step:not(:last-child)::after {
  content: ""; position: absolute; right: -11px; top: 0;
  border-top: 16px solid transparent; border-bottom: 16px solid transparent; border-left: 12px solid #fff;
}
.quote-step.is-done, .quote-step.is-current { background: #08979c; color: #fff; }
.quote-step.is-done:not(:last-child)::after, .quote-step.is-current:not(:last-child)::after { border-left-color: #08979c; }
.quote-step.is-bad { background: var(--ant-error); color: #fff; }
.quote-step.is-bad:not(:last-child)::after { border-left-color: var(--ant-error); }
.quote-document { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.quote-parties { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.quote-company { display: flex; align-items: center; gap: 16px; min-width: 0; }
.quote-company strong { display: block; font-size: 16px; }
.quote-company strong a { color: var(--ant-text); text-decoration: none; }
.quote-company strong a:hover { color: var(--ant-primary); }
.quote-logo {
  width: 72px; height: 72px; border-radius: 4px; display: grid; place-items: center;
  font-size: 18px; font-weight: 700; letter-spacing: 0.04em; flex: none;
}
.quote-prepared { display: grid; gap: 14px; min-width: 180px; }
.quote-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quote-section-head h2 { margin: 0; font-size: 16px; }
.quote-status { color: var(--ant-text-tertiary); font-size: 13px; }
.quote-document .table-wrap { border: 0; box-shadow: none; overflow-x: auto; }
.quote-grid { table-layout: fixed; }
.quote-grid th, .quote-grid td { background: transparent; border: 0; padding: 8px; }
.quote-grid tr:hover td { background: transparent; }
.quote-grid th { font-weight: 500; text-align: center; color: var(--ant-text-secondary); }
.quote-grid th:first-child { text-align: left; }
.quote-grid th:nth-child(2) { width: 168px; }
.quote-grid th:nth-child(3), .quote-grid th:nth-child(4) { width: 120px; }
.quote-grid th:nth-child(5) { width: 150px; }
.quote-grid th:nth-child(6) { width: 48px; }
.quote-affix, .quote-suffix { display: flex; align-items: stretch; }
.quote-affix > span, .quote-suffix > span {
  display: grid; place-items: center; padding: 0 10px; background: #fafafa;
  border: 1px solid var(--ant-border); color: var(--ant-text-secondary); flex: none;
}
.quote-affix > span { border-right: 0; border-radius: 6px 0 0 6px; }
.quote-suffix > span { border-left: 0; border-radius: 0 6px 6px 0; }
.quote-affix input { border-radius: 0 6px 6px 0; }
.quote-suffix input { border-radius: 6px 0 0 6px; text-align: right; }
.quote-grid input[readonly] { background: #fafafa; text-align: right; }
.quote-remove {
  width: 32px; height: 32px; padding: 0; border-color: var(--ant-error); color: var(--ant-error); box-shadow: none;
}
.quote-remove:hover { color: var(--ant-error); border-color: var(--ant-error); background: #fff1f0; }
.quote-add {
  align-self: flex-start; height: auto; padding: 0; border: 0; background: transparent;
  box-shadow: none; color: var(--ant-primary);
}
.quote-add:hover { color: var(--ant-primary-hover); background: transparent; border-color: transparent; }
.quote-totals { width: min(280px, 100%); margin-left: auto; }
.quote-totals div, .quote-totals .quote-tax { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0; }
.quote-totals dt { color: var(--ant-text-secondary); font-weight: 400; }
.quote-totals dd { margin: 0; font-weight: 600; }
.quote-tax .quote-suffix { width: 96px; }
.quote-tax .quote-suffix input { min-height: 32px; }
.quote-grand { border-top: 1px solid var(--ant-border-secondary); margin-top: 4px; padding-top: 10px; }
.quote-notes, .quote-notes-field textarea { white-space: pre-wrap; }
.quote-notes { border-top: 1px solid var(--ant-border-secondary); padding-top: 16px; }
.quote-notes-field { display: flex; flex-direction: column; gap: 8px; }
.quote-notes-field textarea { min-height: 140px; }
dialog.quote-modal {
  top: 50%; left: 50%; right: auto; bottom: auto; height: fit-content; max-height: calc(100vh - 48px);
  width: min(480px, calc(100vw - 32px)); margin: 0; transform: translate(-50%, -50%); overflow: auto;
  border: 0; border-radius: 8px; padding: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
}
.quote-modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.quote-modal form { display: flex; flex-direction: column; }
.quote-modal-head, .quote-modal-foot { display: flex; align-items: center; padding: 16px 24px; }
.quote-modal-head { justify-content: space-between; border-bottom: 1px solid var(--ant-border-secondary); }
.quote-modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.quote-modal-close {
  width: 32px; height: 32px; padding: 0; border: 0; background: transparent; box-shadow: none;
  font-size: 22px; line-height: 1; color: var(--ant-text-secondary);
}
.quote-modal-close:hover { color: var(--ant-text); background: transparent; border-color: transparent; }
.quote-modal-body { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.quote-modal-body .quote-add { margin-top: 4px; }
.quote-modal-foot { justify-content: flex-end; gap: 8px; border-top: 1px solid var(--ant-border-secondary); }
.req::after { content: " *"; color: #ff4d4f; }
@media print {
  .sidebar, .topbar, .config-drawer, .quote-back, .head-actions, .record-section-foot,
  .quote-add, .quote-remove, .quote-status, .quote-modal { display: none !important; }
  .page { background: #fff; }
  .quote-step { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

.card, .stat, .deal-card, .auth-card {
  background: #fff;
  border: 1px solid var(--ant-border-secondary);
  border-radius: 8px;
  box-shadow: var(--ant-card-shadow);
}
.card { padding: 16px 20px; }
.stat-grid, .two-col, .form-grid, .split { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); }
.two-col { grid-template-columns: 1.4fr 0.8fr; }
.split { grid-template-columns: 1fr 1fr; }
.stat { padding: 16px 20px; }
.stat-label { color: var(--ant-text-tertiary); font-size: 14px; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 4px; line-height: 32px; }

.btn, button, input[type="submit"] {
  height: 32px;
  padding: 0 15px;
  border-radius: var(--ant-radius);
  border: 1px solid var(--ant-border);
  background: #fff;
  color: var(--ant-text);
  font: inherit;
  font-size: 14px;
  line-height: 30px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover, button:hover, input[type="submit"]:hover { color: var(--ant-primary-hover); border-color: var(--ant-primary-hover); }
.btn-primary, button.btn-primary, input[type="submit"].btn-primary, .auth-card button[type="submit"] {
  background: var(--ant-primary);
  border-color: var(--ant-primary);
  color: #fff;
  border-radius: 8px;
}
.page-head .btn-primary { border-radius: 20px; padding: 0 16px; }
.btn-primary:hover, button.btn-primary:hover, input[type="submit"].btn-primary:hover {
  background: var(--ant-primary-hover);
  border-color: var(--ant-primary-hover);
  color: #fff;
}
.page form > input[type="submit"],
.page form > button[type="submit"] { margin-top: 24px; }
.page .inline-form > button[type="submit"],
.page .inline-form > input[type="submit"],
.page td form > button[type="submit"],
.page td form > input[type="submit"] { margin-top: 0; }
.inline-form > select, .inline-form > input { width: auto; min-width: 140px; flex: 1 1 160px; }
.inline-form > button { flex: none; }
.deal-stages { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.deal-stage {
  flex: none; height: 32px; padding: 0 14px; border-radius: 16px; white-space: nowrap;
  background: #fff; border: 1px solid var(--ant-border); color: var(--ant-text-secondary);
  display: inline-flex; align-items: center; font-size: 13px;
}
.deal-stage.is-done { color: #08979c; border-color: #87e8de; background: #f6fffd; }
.deal-stage.is-current { background: #08979c; border-color: #08979c; color: #fff; }
.info-card .check { margin-top: 8px; }
.info-card h2 + h2, .info-card .check + h2 { margin-top: 16px; }
.head-actions form { display: inline-flex; margin: 0; }
.head-actions form > input[type="submit"],
.head-actions form > button[type="submit"] { margin-top: 0; }
.btn-ghost { background: #fff; color: var(--ant-text); border-color: var(--ant-border); }
.btn-ghost:hover { color: var(--ant-primary); border-color: var(--ant-primary); }
.btn-danger, button.btn-danger { background: var(--ant-error); border-color: var(--ant-error); color: #fff; }
.btn-danger:hover { background: #ff7875; border-color: #ff7875; color: #fff; }
.btn-small { height: 24px; padding: 0 7px; font-size: 12px; line-height: 22px; }
a.btn { text-decoration: none; }

.filters { background: #fff; border: 1px solid var(--ant-border-secondary); border-radius: 8px; padding: 12px 16px; box-shadow: var(--ant-card-shadow); align-items: flex-end; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.list-toolbar .btn-primary { border-radius: 20px; padding: 0 16px; }
.filters.filters-plain { background: transparent; border: 0; box-shadow: none; padding: 0; margin-left: auto; flex: 1; justify-content: flex-end; }
.filters.filters-plain > input, .filters.filters-plain > select { background: #fff; }
.filters > input, .filters > select, .filters .field, .filters .page-size { width: auto; min-width: 180px; flex: 0 1 220px; }
.filters .field input, .filters .field select, .filters .page-size select { width: 100%; min-width: 0; }
.filters .page-size { min-width: 120px; flex-basis: 120px; }
label.field:has(> input[type="checkbox"]),
label.field:has(> input[type="radio"]) {
  flex-direction: row; align-items: center; gap: 8px; min-height: 32px;
}
label.field:has(> input[type="checkbox"]) input,
label.field:has(> input[type="radio"]) input { width: 16px; flex: none; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field span, .field > label, label.field > span { color: var(--ant-text); }
.field > span { font-weight: 500; }
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
select,
textarea {
  font: inherit;
  color: var(--ant-text);
  background: #fff;
  border: 1px solid var(--ant-border);
  border-radius: var(--ant-radius);
  padding: 4px 11px;
  width: 100%;
  min-height: 32px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:hover, select:hover, textarea:hover { border-color: var(--ant-primary-hover); }
input:focus, select:focus, textarea:focus {
  border-color: var(--ant-primary);
  box-shadow: 0 0 0 2px rgba(5, 145, 255, 0.1);
  outline: none;
}
textarea { min-height: 88px; resize: vertical; padding: 8px 11px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--ant-primary); }
.form-grid { grid-template-columns: 1fr 1fr; }
.check-field { flex-direction: row; align-items: center; gap: 8px; }
.form-errors, .flash { border-radius: 8px; padding: 9px 12px; border: 1px solid transparent; }
.form-errors, .flash-alert { background: #fff2f0; border-color: #ffccc7; color: var(--ant-text); }
.flash-notice { background: #f6ffed; border-color: #b7eb8f; color: var(--ant-text); }
.hint { color: var(--ant-text-tertiary); font-size: 13px; margin: 0; }
.field-hint { color: var(--ant-primary); font-size: 13px; margin: 0; }

.table-wrap { overflow-x: auto; padding: 0; }
turbo-frame#results:has(> .table-wrap):not(:has(> .card ~ .card)):not(:has(> .kanban)) { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--ant-border-secondary); border-radius: 8px; box-shadow: var(--ant-card-shadow); overflow: hidden; min-width: 0; max-width: 100%; }
turbo-frame#results:has(> .table-wrap):not(:has(> .card ~ .card)):not(:has(> .kanban)) > .card { border: 0; box-shadow: none; border-radius: 0; background: transparent; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--ant-border-secondary); vertical-align: middle; }
th { color: var(--ant-text-secondary); font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; background: #fafafa; }
.sort-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ant-text-secondary); font-weight: 600; }
.sort-link.is-active { color: var(--ant-text); }
.sort-mark { width: 10px; height: 14px; position: relative; flex: none; }
.sort-mark::before, .sort-mark::after { content: ""; position: absolute; left: 1px; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.sort-mark::before { top: 0; border-bottom: 5px solid #d9d9d9; }
.sort-mark::after { bottom: 0; border-top: 5px solid #d9d9d9; }
.sort-link.is-active.is-asc .sort-mark::before { border-bottom-color: var(--ant-primary); }
.sort-link.is-active.is-desc .sort-mark::after { border-top-color: var(--ant-primary); }
.contact-card .avatar { width: 56px; height: 56px; font-size: 20px; margin: 0 auto 12px; }
.contact-card .hint { margin-bottom: 4px; }
.contact-mail { margin: 0 0 12px; color: var(--ant-text-secondary); font-size: 13px; word-break: break-all; }
.contact-card .company-foot { justify-content: center; }
tr:hover td { background: #fafafa; }
.table-wrap table tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 4px; padding: 0 8px; font-size: 12px; line-height: 22px;
  background: #fafafa; color: var(--ant-text); border: 1px solid var(--ant-border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-hot { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
.badge-warn { background: #fffbe6; color: #d48806; border-color: #ffe58f; }
.badge-bad { background: #fff2f0; color: #cf1322; border-color: #ffccc7; }
.badge-ok { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.badge-info { background: #e6f4ff; color: #0958d9; border-color: #91caff; }
.badge-muted { background: #fafafa; color: var(--ant-text-secondary); border-color: var(--ant-border); }
button.inline-value.badge.badge-hot, button.inline-value.badge.badge-hot:hover { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
button.inline-value.badge.badge-warn, button.inline-value.badge.badge-warn:hover { background: #fffbe6; color: #d48806; border-color: #ffe58f; }
button.inline-value.badge.badge-bad, button.inline-value.badge.badge-bad:hover { background: #fff2f0; color: #cf1322; border-color: #ffccc7; }
button.inline-value.badge.badge-ok, button.inline-value.badge.badge-ok:hover { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
button.inline-value.badge.badge-info, button.inline-value.badge.badge-info:hover { background: #e6f4ff; color: #0958d9; border-color: #91caff; }
button.inline-value.badge.badge-muted, button.inline-value.badge.badge-muted:hover { background: #fafafa; color: var(--ant-text-secondary); border-color: var(--ant-border); }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-col { min-width: 260px; width: 260px; background: #fafafa; border: 1px solid var(--ant-border-secondary); border-radius: 8px; padding: 12px; }
.kanban-col h2 { font-size: 14px; margin-bottom: 8px; }
.deal-card { padding: 12px; margin-bottom: 8px; cursor: grab; border-radius: 8px; }
.deal-card strong { display: block; }
.deal-card small { color: var(--ant-text-tertiary); }

.record-hero { display: flex; align-items: center; gap: 16px; }
.record-hero h1 { margin: 0; font-size: 24px; line-height: 32px; }
.record-hero .avatar-lg { width: 64px; height: 64px; border-radius: 8px; font-size: 28px; }
.record-owner { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--ant-text-secondary); font-size: 14px; }
.record-hero .head-actions { margin-left: auto; }
.record-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.record-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.record-section { padding: 0; overflow: hidden; }
.record-section-head, .record-section-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; }
.record-section-head { border-bottom: 1px solid var(--ant-border-secondary); }
.record-section-head h2, .info-card h2 { margin: 0; font-size: 16px; }
.record-section .table-wrap { border: 0; box-shadow: none; border-radius: 0; }
.record-section-foot { border-top: 1px solid var(--ant-border-secondary); justify-content: center; }
.record-add { padding: 0 20px 16px; }
.record-add summary { cursor: pointer; color: var(--ant-primary); text-align: center; list-style: none; }
.record-add summary::-webkit-details-marker { display: none; }
.record-add[open] summary { margin-bottom: 12px; }
.note-list { display: flex; flex-direction: column; }
.record-section .note-list { padding: 0 20px; }
.note-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--ant-border-secondary); }
.note-row:last-child { border-bottom: 0; }
.note-row p { margin: 4px 0 0; }
.info-card { padding: 8px 0 4px; }
.info-card h2 { padding: 8px 20px 12px; }
.info-row { display: grid; grid-template-columns: 16px 1fr; gap: 4px 12px; padding: 10px 20px; border-top: 1px solid var(--ant-border-secondary); }
.info-mark { grid-row: span 2; width: 16px; height: 16px; margin-top: 2px; border-radius: 4px; background: var(--ant-primary-bg); }
.info-label { color: var(--ant-text-tertiary); font-size: 12px; }
.info-value { font-weight: 600; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border-left: 2px solid var(--ant-primary); padding-left: 12px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar { background: #f5f5f5; border-radius: 100px; height: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ant-primary); }
.check { list-style: none; padding: 0; margin: 0; }
.check li { padding: 6px 0; }
.check li.done { color: #389e0d; }
.line-row { display: grid; grid-template-columns: 2fr 80px 120px 90px; gap: 8px; margin-bottom: 8px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; color: var(--ant-text-secondary); width: 100%; padding: 12px 16px; background: #fff; border-top: 1px solid var(--ant-border-secondary); }
.pager-loose { background: transparent; border: 0; padding: 4px 0 0; }
.columns-host { position: relative; display: flex; justify-content: flex-end; margin-left: auto; }
.list-toolbar .columns-host { margin-left: 0; }
.columns-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  background: #fff; border: 1px solid var(--ant-border-secondary); border-radius: 8px;
  box-shadow: var(--ant-card-shadow); padding: 8px; min-width: 200px; max-height: 280px; overflow: auto;
}
.columns-option { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 14px; cursor: pointer; }
.columns-option input { width: 16px; height: 16px; min-height: 0; padding: 0; }
.view-switch { display: inline-flex; margin-left: auto; background: #f5f5f5; border-radius: 8px; padding: 2px; gap: 2px; }
.view-switch label { position: relative; display: inline-flex; margin: 0; }
.view-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; }
.view-switch span { height: 28px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 6px; cursor: pointer; color: var(--ant-text-secondary); font-size: 14px; }
.view-switch input:checked + span { background: #fff; color: var(--ant-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.view-switch input:focus-visible + span { outline: 2px solid var(--ant-primary); outline-offset: 1px; }
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.company-card { background: #fff; border: 1px solid var(--ant-border-secondary); border-radius: 8px; box-shadow: var(--ant-card-shadow); padding: 20px 16px 0; text-align: center; display: flex; flex-direction: column; min-width: 0; }
.company-logo { width: 56px; height: 56px; border-radius: 8px; margin: 0 auto 12px; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.company-card h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; line-height: 1.4; }
.company-card h2 a { color: var(--ant-text); text-decoration: none; }
.company-card h2 a:hover { color: var(--ant-primary); }
.company-amount { font-size: 20px; font-weight: 600; margin: 4px 0 16px; }
.company-foot { display: flex; justify-content: space-between; gap: 12px; text-align: left; border-top: 1px solid var(--ant-border-secondary); padding: 12px 0; margin-top: auto; }
.company-foot .hint { margin-bottom: 8px; }
.company-owner { text-align: right; }
.company-owner .avatar { margin-left: auto; }
.avatar-stack { display: flex; align-items: center; min-height: 28px; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid #fff; box-sizing: content-box; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-more { background: #f5f5f5 !important; color: var(--ant-text-secondary) !important; font-size: 11px; width: auto; min-width: 28px; padding: 0 4px; }
.stat-top { display: flex; align-items: center; gap: 8px; }
.stat-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--ant-primary-bg); color: var(--ant-primary);
}
.stat-icon svg { width: 16px; height: 16px; }
.activity-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.activity-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--ant-border-secondary); }
.activity-list li:last-child { border-bottom: 0; }
.activity-mark { width: 36px; height: 36px; border-radius: 8px; background: #fff7e6; color: #d46b08; display: grid; place-items: center; font-weight: 600; flex: none; }
.pager-links { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-size { margin-left: auto; flex: none; min-width: 120px; }
.page-size select { width: auto; min-width: 120px; }
.title-line { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title-line h1, .page-head h1 { margin: 0; }
.page-purpose { margin: 0; color: var(--ant-text-secondary); font-size: 14px; font-weight: 400; }
.auth-card form, .otp-form { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.otp-row { display: flex; align-items: center; gap: 8px; }
.otp-row input { flex: 1 1 auto; width: 1%; min-width: 0; }
.otp-row .btn { flex: none; height: 32px; }
.empty { padding: 32px 16px; text-align: center; color: var(--ant-text-tertiary); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--ant-border-secondary); margin-bottom: 16px; }
button.tab {
  height: 40px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; box-shadow: none; color: var(--ant-text-secondary);
}
button.tab[aria-selected="true"] { color: var(--ant-primary); border-bottom-color: var(--ant-primary); font-weight: 600; }
button.tab:hover { color: var(--ant-primary); background: transparent; }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.tab-panel[hidden] { display: none; }
button.inline-value:not(.badge) {
  height: auto; min-height: 0; padding: 0 2px; border: 0; border-bottom: 1px dashed var(--ant-border);
  border-radius: 0; background: transparent; box-shadow: none; color: inherit; line-height: inherit;
}
button.inline-value:not(.badge):hover { color: var(--ant-primary); border-bottom-color: var(--ant-primary); background: transparent; }
button.inline-value.badge { height: 22px; min-height: 0; cursor: pointer; }
.inline-editor { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-editor select, .inline-editor input { width: auto; min-width: 140px; }
.approval-list { display: flex; flex-direction: column; gap: 12px; }
.approval-list .card h2 { margin-bottom: 4px; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; background: var(--ant-fill); }
.auth-story {
  background: linear-gradient(160deg, #0958d9 0%, #1677ff 55%, #4096ff 100%);
  color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-story h1 { font-size: 40px; line-height: 1.2; max-width: 16ch; color: #fff; font-weight: 600; }
.auth-story p { color: rgba(255, 255, 255, 0.85); }
.auth-panel { display: grid; place-items: center; padding: 32px; }
.auth-card { width: min(420px, 100%); padding: 32px 28px; display: flex; flex-direction: column; gap: 12px; }
.auth-card h1 { margin-bottom: 4px; }
.demo-list { font-size: 13px; color: var(--ant-text-secondary); }
.demo-list code { color: var(--ant-text); background: var(--ant-fill); padding: 0 4px; border-radius: 4px; }

.portal-shell { min-height: 100vh; background: var(--ant-fill); }
.portal-bar {
  background: var(--ant-primary); color: white;
  padding: 0 24px; height: 64px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--ant-header-shadow);
}
.portal-bar a, .portal-bar button { color: #fff; }
.portal-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.65); }
.portal-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 24px; background: #fff; border-bottom: 1px solid var(--ant-border-secondary); }
.portal-nav a { padding: 6px 12px; border-radius: var(--ant-radius); color: var(--ant-text); }
.portal-nav a:hover { background: var(--ant-primary-bg); color: var(--ant-primary); }

.module-fields > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
}
.module-fields > summary::-webkit-details-marker { display: none; }
.module-fields[open] > summary { margin-bottom: 12px; }
.field-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.field-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-builder textarea { min-height: 72px; }

.inline-field { min-width: 140px; }
.inline-display {
  background: transparent;
  border: 1px dashed transparent;
  box-shadow: none;
  height: auto;
  min-height: 24px;
  padding: 0 6px;
  color: inherit;
  font-weight: 400;
  justify-content: flex-start;
}
.inline-display:hover:not(:disabled) { border-color: var(--ant-primary); background: #fff; color: var(--ant-text); }
.inline-display:disabled { cursor: default; color: inherit; border-color: transparent; background: transparent; box-shadow: none; }
.inline-editor { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.inline-editor .ant-picker, .inline-editor select, .inline-editor input[type="text"], .inline-editor input[type="number"] { min-width: 160px; }
.inline-error { color: var(--ant-error); }

.ant-picker { position: relative; display: inline-flex; align-items: center; width: 100%; }
.ant-picker-input {
  padding-right: 32px;
  cursor: pointer;
  background: #fff;
}
.ant-picker-suffix {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; padding: 0; border: 0; background: transparent; box-shadow: none;
  color: var(--ant-text-tertiary); min-height: 0;
}
.ant-picker-suffix:hover { color: var(--ant-text-secondary); background: transparent; border: 0; }
.ant-picker-dropdown {
  z-index: 40;
  width: 280px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
  padding: 8px 12px 12px;
}
.ant-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.ant-picker-header button {
  width: 28px; height: 28px; padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--ant-text-secondary);
}
.ant-picker-header button:hover { background: var(--ant-fill); color: var(--ant-text); }
.ant-picker-weekdays, .ant-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.ant-picker-weekdays span { color: var(--ant-text-tertiary); font-size: 12px; line-height: 28px; }
.ant-picker-cell {
  width: 32px; height: 28px; margin: 0 auto; padding: 0;
  border: 0; background: transparent; box-shadow: none;
  border-radius: 4px; color: var(--ant-text); font-size: 14px;
}
.ant-picker-cell:hover { background: var(--ant-fill); color: var(--ant-text); }
.ant-picker-cell.is-out { color: var(--ant-text-tertiary); }
.ant-picker-cell.is-today { border: 1px solid var(--ant-primary); }
.ant-picker-cell.is-selected, .ant-picker-cell.is-selected:hover { background: var(--ant-primary); color: #fff; }
.ant-picker-footer { margin-top: 8px; text-align: center; }
.ant-picker-footer button { border: 0; background: transparent; box-shadow: none; color: var(--ant-primary); height: 24px; }

.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
  width: 44px; height: 22px; border-radius: 100px; background: rgba(0, 0, 0, 0.25);
  position: relative; transition: background 0.2s; flex: none;
}
.switch-ui::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: left 0.2s;
  box-shadow: 0 2px 4px rgba(0, 35, 11, 0.2);
}
.switch input:checked + .switch-ui { background: var(--ant-primary); }
.switch input:checked + .switch-ui::after { left: 24px; }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 2px rgba(5, 145, 255, 0.1); }

.matrix-wrap { overflow-x: auto; }
.matrix td, .matrix th { white-space: nowrap; }
.matrix label { display: inline-flex; align-items: center; gap: 4px; color: var(--ant-text); font-weight: 400; }
.matrix input[type="radio"] { width: 16px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.config-drawer-backdrop {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(0, 21, 41, 0.2);
}
button.config-drawer-tab {
  position: fixed; top: 50%; right: 0; z-index: 41;
  width: 28px; height: 64px; margin: 0; padding: 0;
  border-radius: 8px 0 0 8px;
  border: 1px solid var(--ant-border); border-right: none;
  background: #fff; color: var(--ant-text-secondary);
  box-shadow: -2px 0 8px rgba(0, 21, 41, 0.08);
  transform: translateY(-50%);
  transition: right 0.22s ease, color 0.2s, border-color 0.2s;
}
button.config-drawer-tab:hover { color: var(--ant-primary); border-color: var(--ant-primary); background: #fff; }
.config-drawer.is-open .config-drawer-tab { right: 280px; }
.config-drawer-tab svg { display: block; transition: transform 0.22s ease; }
.config-drawer.is-open .config-drawer-tab svg { transform: rotate(180deg); }
.config-drawer-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: 280px; background: #fff;
  border-left: 1px solid var(--ant-border-secondary);
  box-shadow: -6px 0 16px rgba(0, 21, 41, 0.08);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 12px;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  overflow: auto;
}
.config-drawer.is-open .config-drawer-panel { transform: translateX(0); }
.config-drawer-panel nav { display: flex; flex-direction: column; gap: 2px; }
.config-drawer-panel nav a {
  display: flex; align-items: center; min-height: 40px;
  padding: 8px 12px; border-radius: var(--ant-radius); color: var(--ant-text);
}
.config-drawer-panel nav a:hover,
.config-drawer-panel nav a[aria-current="page"] { background: var(--ant-primary-bg); color: var(--ant-primary); }

@media (max-width: 980px) {
  .app-shell, .auth-shell, .stat-grid, .two-col, .split, .form-grid, .record-layout, .quote-parties { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .nav-link { white-space: nowrap; height: 36px; }
  .brand { height: auto; padding: 12px 16px; }
  .auth-story { padding: 32px; }
  .auth-story h1 { font-size: 32px; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
  .line-row, .bar-row { grid-template-columns: 1fr; }
  .who { width: 100%; justify-content: flex-end; }
}
