:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #18201d;
  --muted: #66736d;
  --line: #dbe2de;
  --accent: #176b5b;
  --accent-2: #d88f34;
  --danger: #b43f3f;
  --shadow: 0 18px 45px rgba(24, 32, 29, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(23, 107, 91, 0.09), rgba(216, 143, 52, 0.08)),
    var(--bg);
}

.login-card {
  width: min(100%, 460px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #18201d;
  color: #ffffff;
}

.login-brand img {
  width: 74px;
  height: 44px;
  object-fit: contain;
}

.login-brand strong,
.login-brand span {
  display: block;
}

.login-brand span,
.login-card p {
  color: var(--muted);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 34px;
  line-height: 1.05;
}

.login-card p {
  margin: 0;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.login-card input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 800;
}

.login-card input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(23, 107, 91, 0.12);
}

.login-submit {
  min-height: 56px;
  justify-content: center;
}

.login-error {
  min-height: 22px;
  color: var(--danger) !important;
  font-weight: 800;
}

.app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.18s ease;
}

body.sidebar-collapsed .app {
  grid-template-columns: 86px minmax(0, 1fr);
}

.sidebar {
  background: #18201d;
  color: #f8fbf9;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: relative;
  min-width: 0;
  transition: padding 0.18s ease;
}

.sidebar-toggle {
  position: absolute;
  top: 16px;
  right: -18px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  padding: 0 0 3px;
}

.sidebar-toggle:hover {
  background: #f4f8f5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 64px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #ffffff;
  font-weight: 800;
  flex: 0 0 auto;
}

.brand-mark img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-panel small {
  color: rgba(248, 251, 249, 0.66);
  margin-top: 2px;
}

.brand-title,
.sidebar-panel,
.logout-button,
.nav-item {
  transition:
    opacity 0.18s ease,
    width 0.18s ease,
    padding 0.18s ease,
    font-size 0.18s ease;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  text-align: left;
  color: rgba(248, 251, 249, 0.78);
  background: transparent;
  padding: 12px 14px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.logout-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(248, 251, 249, 0.9);
  text-align: left;
  font-weight: 800;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

body.sidebar-collapsed .sidebar {
  padding: 24px 12px;
  align-items: center;
}

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .brand-title,
body.sidebar-collapsed .sidebar-panel,
body.sidebar-collapsed .logout-button {
  display: none;
}

body.sidebar-collapsed .brand-mark {
  width: 58px;
  height: 42px;
}

body.sidebar-collapsed .nav {
  width: 100%;
}

body.sidebar-collapsed .nav-item {
  min-height: 48px;
  padding: 0;
  text-align: center;
  font-size: 0;
  display: grid;
  place-items: center;
}

body.sidebar-collapsed .nav-item::after {
  content: attr(data-short);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

body.sidebar-collapsed .sidebar-toggle {
  right: -18px;
}

.panel-label {
  color: #f1c27d;
  font-size: 13px;
}

.sidebar-panel strong {
  display: block;
  margin: 6px 0;
  font-size: 22px;
}

.main {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.compact-topbar {
  justify-content: flex-end;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

.topbar p,
.modal-head p {
  color: var(--muted);
  margin-top: 6px;
}

.actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.danger-button {
  background: #fff2f0;
  color: var(--danger);
  border-color: #f0cbc6;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 25px;
  background: var(--surface-2);
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.sync-status {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.sync-status[data-status="ok"] {
  color: var(--accent);
}

.sync-status[data-status="error"] {
  color: var(--danger);
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 320px);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
  min-height: 62vh;
}

.task-strip {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.task-strip-head,
.task-strip-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}

.task-strip-head span,
.task-strip-empty span {
  color: var(--muted);
  font-size: 13px;
}

.task-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

.task-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  text-align: left;
}

.task-item:hover {
  border-color: rgba(23, 107, 91, 0.45);
  box-shadow: 0 10px 24px rgba(24, 32, 29, 0.08);
}

.task-item span {
  display: grid;
  gap: 5px;
}

.task-item small,
.task-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.task-item.today {
  border-left-color: var(--accent-2);
  background: #fffaf0;
}

.task-item.overdue {
  border-left-color: var(--danger);
  background: #fff6f4;
}

.task-item.birthday {
  border-left-color: #c88a1d;
  background: #fff8e8;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.compact-head {
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 24px;
}

.section-head p {
  color: var(--muted);
  margin-top: 6px;
}

.agent-picker {
  min-width: 240px;
}

.search-field {
  min-width: min(360px, 100%);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.admin-card,
.agent-score article,
.plan-card,
.report-grid article,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.admin-card {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-card h3 {
  margin: 0;
  font-size: 18px;
}

.admin-card p {
  margin-top: 6px;
  color: var(--muted);
}

.admin-note {
  color: var(--muted);
}

.employee-form {
  align-content: start;
}

.employee-list-card,
.permissions-card {
  align-content: start;
}

.permissions-card {
  grid-row: span 2;
}

.employee-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
  gap: 12px;
  min-width: 0;
}

.employee-form-row.employee-form-wide {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.employee-form-row .primary-button {
  width: 100%;
  min-width: 0;
}

.employee-tabs-field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.employee-tabs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.employee-tab-option,
.employee-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  color: var(--text);
}

.employee-tab-option {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 800;
}

.employee-editor {
  display: grid;
  align-items: stretch;
  min-width: 0;
}

.employee-editor-head,
.employee-editor-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.employee-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  min-width: 0;
}

.employee-editor-grid label,
.employee-editor-grid input,
.employee-editor-grid select {
  min-width: 0;
  width: 100%;
}

.employee-editor-actions {
  justify-content: flex-end;
}

.employee-editor-actions .compact-button {
  min-width: 150px;
  white-space: normal;
}

.compact-button {
  min-height: auto;
  padding: 10px 14px;
}

.stage-form,
.source-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.stage-list,
.source-list {
  display: grid;
  gap: 8px;
}

.stage-row,
.source-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto 36px;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.production-stage-row {
  grid-template-columns: minmax(220px, 1fr) auto 34px 34px 36px;
}

.stage-row span,
.source-row span {
  color: var(--muted);
  font-size: 13px;
  align-self: center;
  white-space: nowrap;
}

.stage-move-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
}

.stage-move-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  opacity: 0.45;
}

.employee-list,
.permissions-list {
  display: grid;
  gap: 8px;
}

.employee-row,
.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.employee-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.employee-row.employee-editor {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  justify-content: stretch;
  gap: 14px;
  min-width: 0;
}

.permission-row {
  align-items: flex-start;
}

.permission-row strong {
  min-width: 110px;
}

.permission-row span {
  color: var(--muted);
}

.icon-mini-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #fff2f0;
  color: var(--danger);
  font-size: 20px;
  font-weight: 800;
}

.icon-mini-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  opacity: 0.45;
}

.summary-card span,
.agent-score span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-card strong,
.agent-score strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.summary-card small,
.admin-card footer,
.empty-state p {
  color: var(--muted);
}

.admin-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-card-top strong {
  font-size: 18px;
}

.admin-card-top span {
  color: var(--accent);
  font-weight: 800;
}

.agent-progress {
  display: grid;
  gap: 8px;
}

.agent-progress div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

.agent-progress span {
  color: var(--muted);
}

.agent-score {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.agent-directory {
  display: grid;
  gap: 12px;
}

.agent-form-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.referral-agent-list {
  display: grid;
  gap: 8px;
}

.referral-agent-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto 36px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.referral-agent-row small,
.referral-agent-row em {
  display: block;
  color: var(--muted);
  font-style: normal;
  margin-top: 3px;
}

.referral-agent-row span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.production-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.production-filters .agent-picker {
  min-width: 220px;
}

.production-filters .search-field {
  min-width: 300px;
}

#productionScore {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.stage-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.stage-chip strong {
  color: var(--ink);
  font-size: 16px;
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
}

.plan-panel {
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.source-plan h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.plan-summary,
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  align-content: start;
}

.plan-card span,
.report-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.plan-card strong,
.report-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.plan-card small,
.report-grid small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.report-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.receivable-forecast {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5faf8;
}

.receivable-forecast:empty {
  display: none;
}

.receivable-forecast-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.receivable-forecast-head h3 {
  margin: 0;
  font-size: 18px;
}

.receivable-forecast-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.receivable-forecast-head > span {
  color: var(--accent);
  font-size: 20px;
  font-weight: 900;
  white-space: nowrap;
}

.receivable-month-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.receivable-month-card {
  min-height: 92px;
  padding: 12px;
  border: 1px solid #cfe5dc;
  border-radius: 8px;
  background: var(--surface);
}

.receivable-month-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.receivable-month-card strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.receivable-month-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.receivable-month-card.is-empty {
  opacity: 0.65;
}

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.period-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.period-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.custom-period {
  display: none;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.custom-period.active {
  display: grid;
}

.report-grid {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  margin-bottom: 16px;
}

.report-chart {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-chart:empty {
  display: none;
}

.report-chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.report-chart-head h3 {
  margin: 0;
  font-size: 18px;
}

.report-chart-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.report-chart-totals {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.report-chart-totals span {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.monthly-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(44px, 1fr));
  gap: 8px;
  min-height: 150px;
  align-items: end;
}

.monthly-bar-wrap {
  display: grid;
  grid-template-rows: auto 110px auto;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.monthly-bar-value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.monthly-bar-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 110px;
  padding: 0 7px;
  border-radius: 8px;
  background: var(--surface-2);
}

.monthly-bar {
  width: 100%;
  min-height: 8px;
  border-radius: 7px 7px 2px 2px;
  background: var(--accent);
}

.monthly-bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.report-table th,
.report-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-2);
}

.report-table tr:last-child td {
  border-bottom: 0;
}

.report-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.muted-cell {
  color: var(--muted);
}

.table-button {
  border: 0;
  border-radius: 8px;
  min-height: 34px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 800;
}

.accounting-table {
  min-width: 920px;
}

.accounting-row-soon {
  background: #f0faf4;
  box-shadow: inset 4px 0 0 #1f9d55;
}

.accounting-row-soon td {
  border-color: #cfeedd;
}

.accounting-row-overdue {
  background: #fff3f1;
  box-shadow: inset 4px 0 0 #c23b3b;
}

.accounting-row-overdue td {
  border-color: #f1c8c2;
}

.accounting-row-refund {
  background: #fff8f2;
  box-shadow: inset 4px 0 0 #c56a2a;
}

.accounting-row-refund td {
  border-color: #f0d4bd;
}

.refund-pending,
.refund-paid,
.termination-tag {
  font-weight: 900;
}

.refund-pending,
.termination-tag {
  color: var(--danger);
}

.refund-paid {
  color: var(--accent);
}

.agent-board {
  grid-auto-columns: minmax(300px, 1fr);
}

.empty-state {
  display: grid;
  gap: 8px;
  min-height: 220px;
  align-content: center;
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 62vh;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
}

.column-title-row {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.column-title {
  font-weight: 800;
}

.column-stage-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stage-action-button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.stage-action-button:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.stage-action-button.danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}

.stage-action-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.column-count {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.add-stage-column {
  min-height: 180px;
  justify-content: center;
  padding: 10px;
  background: transparent;
  border-style: dashed;
}

.add-stage-button {
  width: 100%;
  min-height: 116px;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.add-stage-button span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 30px;
  line-height: 1;
}

.add-stage-button strong {
  font-size: 15px;
}

.add-stage-button:hover {
  border-color: var(--accent);
}

.cards {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 0 10px 12px;
}

.cards.drag-over {
  background: rgba(23, 107, 91, 0.08);
  outline: 2px dashed rgba(23, 107, 91, 0.28);
  outline-offset: -7px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 10px 24px rgba(24, 32, 29, 0.06);
}

.client-card.task-today {
  border-left-color: var(--accent-2);
  background: #fffaf0;
}

.client-card.task-overdue {
  border-left-color: var(--danger);
  background: #fff6f4;
}

.error-card {
  border-left-color: var(--danger);
}

.client-card:active {
  cursor: grabbing;
}

.client-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.client-name {
  font-weight: 800;
  line-height: 1.25;
}

.tag {
  height: 24px;
  border-radius: 999px;
  background: #f8ead6;
  color: #805116;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.client-meta {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.client-note {
  color: #3d4944;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.client-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.edit-card {
  border: 0;
  background: #edf7f4;
  color: var(--accent);
  border-radius: 8px;
  min-height: 30px;
  padding: 0 10px;
  font-weight: 800;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(24, 32, 29, 0.42);
}

.modal-card {
  width: min(860px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full-field {
  grid-column: 1 / -1;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.modal-tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.modal-tab.active {
  color: var(--accent);
  border-color: var(--accent);
}

.client-tab-panel {
  display: none;
  gap: 14px;
}

.client-tab-panel.active {
  display: grid;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.installment-builder {
  display: none;
  grid-column: 1 / -1;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23, 107, 91, 0.2);
  border-radius: 8px;
  background: #f4faf7;
}

.installment-builder.active {
  display: grid;
}

.installment-builder-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.installment-builder-head strong {
  color: var(--accent);
}

.installment-builder-head span {
  color: var(--muted);
  font-size: 13px;
}

.installment-generate {
  align-self: end;
}

.installment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.installment-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4faf7;
  padding: 12px;
}

.installment-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.installment-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.installment-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.installment-toolbar strong {
  color: var(--muted);
}

.installment-payment-rows {
  display: grid;
  gap: 10px;
}

.installment-payment-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) 40px;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.installment-payment-delete {
  background: #fff2f0;
  color: var(--danger);
  border-color: #f0cbc6;
}

.termination-block {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(194, 59, 59, 0.24);
  border-radius: 8px;
  background: #fff8f7;
}

.termination-toggle {
  width: max-content;
}

.termination-fields {
  display: none;
  gap: 12px;
}

.termination-block.active .termination-fields {
  display: grid;
}

.hidden-field {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.task-panel {
  display: grid;
  gap: 14px;
}

.task-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 107, 91, 0.16);
  border-radius: 8px;
  background: #f4faf7;
}

.task-panel-head strong {
  color: var(--accent);
}

.task-panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}

.check-label-inline {
  width: fit-content;
}

.check-label input {
  width: auto;
  min-width: 18px;
  height: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

.modal-actions {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 1280px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .permissions-card {
    grid-row: auto;
  }
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    flex-direction: column;
  }

  .actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .actions button {
    flex: 1 1 150px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid,
  .plan-layout,
  .agent-score {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .employee-form-row,
  .employee-form-row.employee-form-wide,
  .employee-editor-grid,
  .agent-form-row,
  .stage-form,
  .stage-row,
  .source-form,
  .source-row,
  .referral-agent-row {
    grid-template-columns: 1fr;
  }

  .report-grid,
  .plan-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-head {
    flex-direction: column;
  }

  .search-field,
  .production-filters .search-field {
    min-width: 0;
    width: 100%;
  }

  .report-controls {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .metrics,
  .admin-grid,
  .plan-layout,
  .source-grid,
  .plan-summary,
  .report-grid,
  .agent-score,
  .task-list,
  .form-grid,
  .installment-summary,
  .installment-payment-row {
    grid-template-columns: 1fr;
  }

  .board {
    grid-auto-columns: minmax(260px, 88vw);
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}
