:root {
  color-scheme: light;
  --navy: #073a55;
  --navy-2: #0c526f;
  --blue: #006fb0;
  --cyan: #00a9d6;
  --ink: #173247;
  --muted: #657b8b;
  --line: #dbe6ed;
  --soft: #f1f6f9;
  --surface: #ffffff;
  --danger: #b42318;
  --success: #16794c;
  --warning: #9a6700;
  --shadow: 0 14px 38px rgba(12, 48, 70, .12);
  --orange: #f28c28;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--soft); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: linear-gradient(180deg, #f8fbfd 0, var(--soft) 420px); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--navy); font-size: clamp(1.35rem, 2.8vw, 1.8rem); line-height: 1.1; }
h2 { margin: 0; color: var(--navy); font-size: 1.25rem; }
h3 { margin: 0; font-size: 1rem; }

.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, rgba(0, 169, 214, .16), transparent 32%), linear-gradient(145deg, #052c43, #0a5671); }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid rgba(255,255,255,.65); border-radius: 24px; background: rgba(255,255,255,.97); box-shadow: 0 28px 70px rgba(0,0,0,.24); }
.login-card h1 { margin-bottom: 10px; font-size: 1.75rem; }
.login-card > .muted { margin: 0 0 24px; }
.brand-mark { display: grid; width: 46px; height: 46px; place-items: center; margin-bottom: 18px; border-radius: 14px; color: white; background: linear-gradient(135deg, var(--navy), var(--cyan)); font-size: 1.35rem; font-weight: 900; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 72px; padding: 12px max(18px, calc((100vw - 1500px) / 2)); border-bottom: 1px solid rgba(213, 226, 234, .9); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.profile-badge { max-width: 260px; overflow: hidden; padding: 7px 10px; border-radius: 99px; color: var(--navy); background: #e9f4f8; font-size: .78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.tabs { position: sticky; z-index: 19; top: 72px; display: flex; gap: 4px; padding: 0 max(18px, calc((100vw - 1500px) / 2)); border-bottom: 1px solid var(--line); background: white; overflow-x: auto; }
.tab { flex: 0 0 auto; padding: 14px 16px 12px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 750; }
.tab.active { color: var(--blue); border-bottom-color: var(--cyan); }
.count { display: inline-grid; min-width: 20px; height: 20px; place-items: center; margin-left: 4px; padding: 0 5px; border-radius: 99px; color: white; background: var(--blue); font-size: .7rem; }
.view { width: min(1680px, 100%); margin: 0 auto; padding: 22px 18px 44px; }

.filter-panel { display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(135px, .8fr)) auto auto; align-items: end; gap: 10px; margin-bottom: 16px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 5px 18px rgba(20, 51, 74, .05); }
label { display: grid; gap: 6px; color: #405b6d; font-size: .8rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #bfd0db; border-radius: 10px; color: var(--ink); background: white; outline: none; transition: border-color .18s, box-shadow .18s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,111,176,.12); }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-field .icon-button { position: absolute; top: 4px; right: 4px; }
.button { min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; transition: transform .15s, background .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { color: white; background: var(--navy); }
.button.primary:hover { background: var(--navy-2); }
.button.ghost { border-color: var(--line); color: var(--ink); background: white; }
.button.danger { color: var(--danger); border-color: #f1b7b2; background: #fff6f5; }
.button.small { min-height: 34px; padding: 6px 10px; font-size: .78rem; }
.button.wide { width: 100%; }
.icon-button { display: inline-grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 10px; color: var(--ink); background: transparent; font-size: 1.2rem; }
.icon-button:hover { background: var(--soft); }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: .82rem; }
.stack { display: grid; gap: 15px; }

.board-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.summary-row { display: flex; gap: 8px; margin: 0; overflow-x: auto; scrollbar-width: thin; }
.summary-chip { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: white; font-size: .77rem; font-weight: 700; }
.summary-chip strong { color: var(--navy); }
.drag-help { flex: 0 0 auto; margin: 0; color: var(--muted); font-size: .78rem; font-weight: 700; }
.drag-help span { display: inline-grid; width: 24px; height: 24px; place-items: center; margin-right: 4px; border-radius: 7px; color: var(--blue); background: #e8f5fb; }
.board-frame { overflow-x: auto; padding: 2px 2px 14px; scrollbar-color: #94adbc transparent; scrollbar-width: thin; }
.board-frame::-webkit-scrollbar { height: 10px; }
.board-frame::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 99px; background: #94adbc; background-clip: padding-box; }
.board { display: grid; grid-auto-columns: minmax(278px, 310px); grid-auto-flow: column; gap: 13px; min-width: max-content; padding: 0; scroll-snap-type: x proximity; }
.stage-column { height: calc(100vh - 300px); min-height: 420px; max-height: 760px; padding: 10px; overflow: hidden; border: 1px solid #d5e1e8; border-top: 4px solid #9db7c6; border-radius: 14px; background: #eaf1f5; scroll-snap-align: start; transition: border-color .18s, background .18s, box-shadow .18s, transform .18s; }
.stage-column:nth-child(2) { border-top-color: #3c9bd1; }
.stage-column:nth-child(3) { border-top-color: #f2b544; }
.stage-column:nth-child(4) { border-top-color: #7a78cc; }
.stage-column:nth-child(5) { border-top-color: #e17a35; }
.stage-column:nth-child(6) { border-top-color: #20a07a; }
.stage-column:nth-child(7) { border-top-color: #c75050; }
.stage-header { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 10px; margin: 0 3px 9px; }
.stage-header h2 { font-size: .84rem; letter-spacing: .01em; line-height: 1.25; }
.stage-kicker { display: block; margin-bottom: 2px; color: #78909f; font-size: .58rem; font-weight: 850; letter-spacing: .14em; }
.stage-total { display: grid; min-width: 25px; height: 25px; place-items: center; border-radius: 99px; color: var(--navy); background: white; font-size: .72rem; font-weight: 800; }
.stage-cards { display: grid; height: calc(100% - 57px); min-height: 0; align-content: start; gap: 10px; padding: 1px 4px 10px 1px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #9bb0bd transparent; scrollbar-width: thin; }
.stage-cards::-webkit-scrollbar { width: 7px; }
.stage-cards::-webkit-scrollbar-thumb { border-radius: 99px; background: #9bb0bd; }
.drop-placeholder { display: none; min-height: 88px; place-items: center; border: 2px dashed var(--cyan); border-radius: 12px; color: var(--blue); background: rgba(255,255,255,.66); font-size: .8rem; font-weight: 800; }
.stage-column.drag-over { border-color: var(--cyan); background: #e2f5fb; box-shadow: 0 0 0 3px rgba(0,169,214,.15), 0 16px 30px rgba(7,58,85,.12); transform: translateY(-2px); }
.stage-column.drag-over .drop-placeholder { display: grid; }
.proposal-card { padding: 12px; border: 1px solid #d4e0e7; border-left: 4px solid var(--blue); border-radius: 13px; background: white; box-shadow: 0 4px 12px rgba(20, 51, 74, .07); cursor: pointer; transition: transform .16s, box-shadow .16s, opacity .16s; }
.proposal-card[draggable="true"] { cursor: grab; }
.proposal-card[draggable="true"]:active { cursor: grabbing; }
.proposal-card:hover { transform: translateY(-2px); box-shadow: 0 9px 20px rgba(20,51,74,.12); }
.proposal-card.won { border-left-color: var(--success); }
.proposal-card.lost { border-left-color: var(--danger); }
.proposal-card.dragging { opacity: .38; transform: rotate(1.2deg) scale(.98); }
.saving-movement { pointer-events: none; opacity: .7; }
.dragging-proposal, .dragging-proposal * { cursor: grabbing !important; user-select: none; }
.proposal-card-top, .proposal-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.proposal-card-top { margin-bottom: 10px; }
.drag-handle { color: #91a6b4; font-size: 1.05rem; line-height: 1; }
.proposal-id { color: var(--blue); font-size: .74rem; font-weight: 850; }
.status-pill, .priority-pill { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 99px; background: #edf5fa; font-size: .66rem; font-weight: 850; text-transform: uppercase; }
.status-pill.won { color: var(--success); background: #e8f7ee; }
.status-pill.lost { color: var(--danger); background: #fff0ef; }
.proposal-card h3 { display: -webkit-box; margin-bottom: 7px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.client-name { margin: 0 0 12px; color: var(--muted); font-size: .8rem; }
.card-task { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px; border-radius: 9px; color: #405b6d; background: #f2f7fa; font-size: .72rem; }
.card-task strong, .card-task small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-task small { margin-top: 2px; color: var(--muted); }
.card-task-count { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 7px; color: white; background: var(--orange); font-weight: 850; }
.card-task.empty { color: #718795; }
.card-task.empty > span:first-child { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 7px; color: var(--success); background: #e4f6ec; font-weight: 900; }
.proposal-value { color: var(--navy); font-weight: 850; }
.proposal-meta { color: var(--muted); font-size: .72rem; text-align: right; }
.card-actions { display: flex; gap: 5px; margin: 11px -4px -4px; padding-top: 9px; border-top: 1px solid #edf2f5; }
.card-action { flex: 1; min-height: 31px; padding: 5px 6px; border: 0; border-radius: 8px; color: #486273; background: transparent; font-size: .7rem; font-weight: 800; }
.card-action:hover { color: var(--navy); background: #edf5f8; }
.card-action.move { color: var(--blue); }
.card-action.task { color: var(--success); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading > .muted { margin: 0; }
.task-list { display: grid; gap: 10px; }
.task-card { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 4px 14px rgba(20,51,74,.05); }
.priority-bar { align-self: stretch; border-radius: 99px; background: #9aadb9; }
.priority-bar.MED { background: #e6a700; }.priority-bar.ALT { background: #e17218; }.priority-bar.URG { background: #c43126; }.priority-bar.BAI { background: #4f9c70; }
.task-main h3 { margin-bottom: 5px; }
.task-main p { margin: 2px 0; color: var(--muted); font-size: .8rem; }
.task-actions { display: flex; gap: 7px; }
.task-overdue { color: var(--danger) !important; font-weight: 750; }

.form-card { display: grid; gap: 20px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 13px; color: var(--navy); font-size: 1rem; font-weight: 850; }
.fieldset-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fieldset-heading legend { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.span-2 { grid-column: span 2; }
.proposal-items { display: grid; gap: 12px; }
.item-card { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #f8fbfc; }
.item-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.form-actions, .modal-actions { display: flex; justify-content: flex-end; gap: 9px; }
.notice { margin-bottom: 14px; padding: 12px 14px; border-radius: 11px; font-size: .83rem; }
.notice.warning { color: #664400; border: 1px solid #f0cf7d; background: #fff9e8; }
.checkbox { display: flex; grid-template-columns: auto 1fr; align-items: start; gap: 8px; }
.checkbox input { width: 18px; min-height: 18px; }

.modal { width: min(820px, calc(100% - 26px)); max-height: 90vh; padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(5,30,44,.63); backdrop-filter: blur(3px); }
.small-modal { width: min(520px, calc(100% - 26px)); }
.modal-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; border-bottom: 1px solid var(--line); background: white; }
.modal-content { padding: 20px; }
.modal-actions { position: sticky; bottom: 0; padding: 14px 20px; border-top: 1px solid var(--line); background: white; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.detail-cell { padding: 11px; border-radius: 10px; background: var(--soft); }
.detail-cell span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.detail-section { margin-top: 22px; }
.detail-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.history-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history-list li { padding: 10px 12px; border-left: 3px solid var(--cyan); background: var(--soft); font-size: .8rem; }
.history-list small { display: block; margin-top: 3px; color: var(--muted); }

.empty-state { display: grid; place-items: center; padding: 56px 20px; color: var(--muted); text-align: center; }
.empty-state > span { font-size: 2rem; }.empty-state h2 { margin: 10px 0 4px; }.empty-state p { margin: 0; }
.load-more { display: block; margin: 18px auto 0; }
.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); padding: 12px 15px; border-radius: 11px; color: white; background: var(--navy); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: none; }.toast.error { background: var(--danger); }.toast.success { background: var(--success); }
.loading { position: relative; pointer-events: none; opacity: .62; }

@media (max-width: 1080px) {
  .filter-panel { grid-template-columns: repeat(3, 1fr); }
  .search-field { grid-column: span 2; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .topbar { min-height: 66px; padding: 10px 14px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 1.3rem; }
  .profile-badge { max-width: 128px; }
  .topbar-actions .button { min-width: auto; padding: 8px 10px; }
  .tabs { top: 66px; padding: 0 10px; }
  .view { padding: 15px 12px 34px; }
  .filter-panel { grid-template-columns: repeat(2, 1fr); padding: 12px; }
  .filter-panel .button { width: 100%; }
  .search-field { grid-column: span 2; }
  .board-toolbar { align-items: flex-start; }
  .drag-help { display: none; }
  .board-frame { margin: 0 -12px; padding: 2px 12px 14px; }
  .board { grid-auto-columns: minmax(86vw, 86vw); grid-auto-flow: column; min-width: max-content; }
  .stage-column { height: calc(100dvh - 245px); min-height: 420px; max-height: 680px; }
  .stage-cards:empty { min-height: 34px; }
  .drag-handle { display: none; }
  .task-card { grid-template-columns: 7px 1fr; }
  .task-actions { grid-column: 2; flex-wrap: wrap; }
  .section-heading { align-items: flex-start; }
  .section-heading > .muted { display: none; }
  .form-card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-content { padding: 15px; }
  .form-actions { position: sticky; bottom: 0; margin: 0 -14px -14px; padding: 12px 14px; border-top: 1px solid var(--line); background: white; }
}

@media (max-width: 420px) {
  .login-card { padding: 25px 20px; }
  .profile-badge { display: none; }
  .filter-panel { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}

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