:root {
  --navy: #081c33;
  --navy-soft: #102d4b;
  --blue: #145cff;
  --paper: #f4f6f7;
  --white: #fff;
  --ink: #101820;
  --muted: #66737e;
  --line: #d9dfe3;
  --line-soft: #e9edef;
  --signal: #ff562b;
  --warning: #b35b00;
  --success: #1f8a5b;
  --danger: #c43c3c;
  --sidebar: 216px;
  --topbar: 68px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; overflow-x: hidden; color: var(--ink); background: var(--paper); font: 14px/1.45 "Manrope", "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, label[aria-label] { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; background: var(--white); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.crm-topbar { position: sticky; z-index: 30; top: 0; display: flex; height: var(--topbar); align-items: center; justify-content: space-between; padding: 0 24px; color: var(--white); background: var(--navy); border-bottom: 1px solid rgb(255 255 255 / 12%); }
.crm-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.crm-brand > span:last-child { display: grid; line-height: 1.15; }
.crm-brand strong { font-size: 14px; font-weight: 700; }
.crm-brand small { margin-top: 4px; color: rgb(255 255 255 / 58%); font-size: 10px; text-transform: uppercase; }
.crm-mark { position: relative; display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgb(255 255 255 / 68%); font: 600 11px "IBM Plex Mono", monospace; }
.crm-mark::after { content: ""; position: absolute; width: 8px; height: 2px; margin: 24px 0 0 17px; background: var(--signal); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-button, .primary-button, .secondary-button, .danger-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; border-radius: 5px; transition: background 220ms ease, color 220ms ease, border-color 220ms ease, transform 220ms var(--ease); }
.icon-button { width: 40px; color: inherit; background: transparent; border: 1px solid rgb(255 255 255 / 22%); }
.icon-button:hover { background: rgb(255 255 255 / 10%); }
.primary-button { padding: 0 15px; color: var(--white); background: var(--signal); font-weight: 700; }
.primary-button:hover { background: #e94823; transform: translateY(-1px); }
.secondary-button { padding: 0 15px; color: var(--ink); background: var(--white); border: 1px solid var(--line); font-weight: 650; }
.secondary-button:hover { border-color: #a8b1b8; }
.danger-button { padding: 0 14px; color: var(--danger); background: #fff4f4; border: 1px solid #f0caca; }
.topbar-actions label.icon-button { cursor: pointer; }

.crm-layout { display: grid; min-height: calc(100vh - var(--topbar)); grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.crm-sidebar { position: sticky; top: var(--topbar); display: flex; height: calc(100vh - var(--topbar)); flex-direction: column; justify-content: space-between; padding: 18px 12px; background: var(--white); border-right: 1px solid var(--line); }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-link { display: flex; width: 100%; min-height: 42px; align-items: center; gap: 11px; padding: 0 12px; color: var(--muted); background: transparent; border-radius: 5px; text-align: left; transition: color 180ms ease, background 180ms ease; }
.sidebar-link:hover { color: var(--ink); background: var(--paper); }
.sidebar-link.is-active { color: var(--navy); background: #eaf0f6; font-weight: 700; }
.sidebar-status { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--muted); border-top: 1px solid var(--line-soft); }
.sidebar-status div { display: grid; }
.sidebar-status strong { color: var(--ink); font-size: 11px; }
.sidebar-status small { font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgb(31 138 91 / 12%); }

.crm-main { min-width: 0; padding: 28px 30px 42px; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.workspace-kicker { margin-bottom: 5px; color: var(--muted); font: 500 10px "IBM Plex Mono", monospace; text-transform: uppercase; }
.workspace-heading h1 { margin-bottom: 0; font: 600 clamp(26px, 3vw, 38px)/1.1 "Onest", sans-serif; }
.pricing-stage { display: grid; justify-items: end; color: var(--muted); font-size: 11px; }
.pricing-stage strong { color: var(--navy); font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--white); }
.metrics article { min-width: 0; padding: 16px 18px; border-right: 1px solid var(--line); }
.metrics article:last-child { border-right: 0; }
.metrics span, .metrics small { display: block; color: var(--muted); font-size: 10px; }
.metrics strong { display: block; margin: 5px 0 2px; overflow-wrap: anywhere; color: var(--navy); font: 650 clamp(20px, 2.2vw, 29px)/1.1 "Onest", sans-serif; }
.metrics .metric-alert strong { color: var(--danger); }

.crm-toolbar { display: flex; gap: 10px; margin: 18px 0 14px; }
.crm-toolbar label { min-width: 0; }
.crm-toolbar select, .search-field { height: 42px; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 5px; }
.crm-toolbar select { min-width: 170px; padding: 0 34px 0 11px; }
.search-field { display: flex; flex: 1; align-items: center; gap: 9px; padding: 0 12px; }
.search-field svg { flex: 0 0 auto; color: var(--muted); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }

.board-scroll { display: grid; min-width: 0; grid-auto-columns: minmax(258px, 1fr); grid-auto-flow: column; gap: 12px; overflow-x: auto; overscroll-behavior-inline: contain; padding-bottom: 14px; scrollbar-width: thin; }
.pipeline-column { display: flex; min-height: 420px; flex-direction: column; background: #edf0f2; border-top: 3px solid #b7c0c7; }
.pipeline-column[data-group="active"] { border-top-color: var(--signal); }
.pipeline-column[data-group="done"] { border-top-color: var(--success); }
.pipeline-column[data-group="lost"] { border-top-color: #a7afb5; }
.column-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; padding: 13px 13px 11px; border-bottom: 1px solid #d7dde0; }
.column-heading h2 { margin-bottom: 2px; font-size: 13px; font-weight: 750; }
.column-heading small { color: var(--muted); font-size: 10px; }
.column-count { display: grid; min-width: 25px; height: 25px; place-items: center; color: var(--muted); background: var(--white); border-radius: 50%; font: 600 10px "IBM Plex Mono", monospace; }
.column-cards { display: grid; align-content: start; gap: 8px; padding: 9px; }
.column-empty { padding: 18px 12px; color: #8a969e; font-size: 11px; text-align: center; }

.deal-card { min-width: 0; padding: 13px; background: var(--white); border: 1px solid #dde2e5; border-radius: 6px; transition: border-color 200ms ease, transform 220ms var(--ease), box-shadow 220ms ease; }
.deal-card:hover { border-color: #b8c2c9; transform: translateY(-1px); box-shadow: 0 8px 20px rgb(8 28 51 / 7%); }
.deal-card.is-overdue { border-left: 3px solid var(--danger); }
.deal-card-top, .deal-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.deal-service { overflow: hidden; color: var(--blue); font: 500 9px "IBM Plex Mono", monospace; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.deal-amount { flex: 0 0 auto; color: var(--navy); font-size: 12px; font-weight: 750; }
.deal-card h3 { margin: 12px 0 4px; overflow-wrap: anywhere; font: 650 16px/1.25 "Onest", sans-serif; }
.deal-project { display: -webkit-box; min-height: 34px; margin-bottom: 12px; overflow: hidden; color: var(--muted); font-size: 11px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.next-action { display: grid; gap: 2px; min-width: 0; }
.next-action span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.next-action time { color: var(--muted); font-size: 9px; }
.next-action.is-overdue time { color: var(--danger); font-weight: 700; }
.card-actions { display: flex; gap: 3px; flex: 0 0 auto; }
.card-actions button { display: grid; width: 29px; height: 29px; place-items: center; color: var(--muted); background: transparent; border-radius: 4px; }
.card-actions button:hover { color: var(--navy); background: var(--paper); }
.card-actions svg { width: 15px; height: 15px; }

.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; font-weight: 650; text-transform: uppercase; }
td { font-size: 12px; }
td strong { display: block; font-size: 13px; }
td small { color: var(--muted); }
.table-status { display: inline-flex; padding: 4px 7px; color: var(--navy); background: #eaf0f6; border-radius: 3px; font-size: 10px; }
.table-date.is-overdue { color: var(--danger); font-weight: 700; }
.table-edit { color: var(--blue); background: transparent; }
.table-actions { display: flex; gap: 9px; }

.empty-state { max-width: 440px; margin: 70px auto 0; text-align: center; }
.empty-state svg { width: 34px; height: 34px; margin: 0 auto 15px; color: #9aa5ad; }
.empty-state h2 { margin-bottom: 6px; font: 600 22px "Onest", sans-serif; }
.empty-state p { color: var(--muted); }

.deal-dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; color: var(--ink); background: var(--white); border: 0; border-radius: 7px; box-shadow: 0 24px 80px rgb(8 28 51 / 28%); }
.deal-dialog::backdrop { background: rgb(8 28 51 / 58%); backdrop-filter: blur(2px); }
.deal-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading p { margin-bottom: 4px; color: var(--signal); font: 500 9px "IBM Plex Mono", monospace; text-transform: uppercase; }
.dialog-heading h2 { margin-bottom: 0; font: 600 25px "Onest", sans-serif; }
.dialog-heading .icon-button { color: var(--muted); border-color: var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid label { display: grid; gap: 6px; color: #4d5962; font-size: 11px; font-weight: 650; }
.field-wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; min-width: 0; padding: 10px 11px; color: var(--ink); background: #fbfcfc; border: 1px solid var(--line); border-radius: 4px; outline: 0; font-size: 13px; font-weight: 450; }
.form-grid input, .form-grid select { height: 42px; }
.form-grid textarea { resize: vertical; }
.form-grid :is(input, select, textarea):focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(20 92 255 / 9%); }
.dialog-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }

.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(360px, calc(100% - 36px)); padding: 11px 14px; color: var(--white); background: var(--navy); border-radius: 5px; box-shadow: 0 14px 40px rgb(8 28 51 / 20%); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 220ms var(--ease); }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  :root { --sidebar: 72px; }
  .sidebar-link { justify-content: center; padding: 0; }
  .sidebar-link span, .sidebar-status div { display: none; }
  .sidebar-status { justify-content: center; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  :root { --topbar: 62px; }
  .crm-topbar { padding: 0 14px; }
  .crm-brand small { display: none; }
  .topbar-actions .icon-button { display: none; }
  .primary-button { padding-inline: 12px; }
  .crm-layout { display: block; }
  .crm-sidebar { position: sticky; z-index: 20; top: var(--topbar); width: 100%; height: 50px; padding: 5px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; }
  .sidebar-link { min-height: 39px; justify-content: center; }
  .sidebar-link { gap: 6px; padding-inline: 4px; font-size: 12px; }
  .sidebar-link span { display: none; }
  .sidebar-status { display: none; }
  .crm-main { padding: 20px 14px 32px; }
  .workspace-heading { align-items: start; }
  .pricing-stage { max-width: 120px; text-align: right; }
  .metrics article { padding: 13px; }
  .crm-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-field { grid-column: 1 / -1; }
  .crm-toolbar select { width: 100%; min-width: 0; }
  .board-scroll { width: calc(100vw - 28px); grid-auto-columns: minmax(270px, calc(100vw - 54px)); }
  .deal-dialog form { padding: 18px 15px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
  .dialog-actions > span { display: none; }
  .dialog-actions .danger-button { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 390px) {
  .crm-brand strong { font-size: 12px; }
  .topbar-actions .primary-button span { display: none; }
  .topbar-actions .primary-button { width: 40px; padding: 0; }
  .workspace-heading { display: grid; }
  .pricing-stage { justify-items: start; max-width: none; text-align: left; }
}

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