:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --text: #1d2430;
  --muted: #667085;
  --line: #d9dee8;
  --surface: #ffffff;
  --surface-soft: #eef4f8;
  --accent: #1967d2;
  --accent-soft: #e8f0fe;
  --danger: #b42318;
  --ok: #087443;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 248, 250, 0.96);
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  width: min(380px, 100%);
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(29, 36, 48, 0.16);
}

.form-error {
  margin: 0;
  color: var(--danger);
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.user-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.user-tools label {
  min-width: 180px;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 720;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.sync-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 16px;
}

.metric {
  min-height: 76px;
  padding: 14px 16px;
  background: var(--surface);
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric strong {
  font-size: 26px;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}

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

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

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

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

.outbox-panel,
.notifications-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}

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

.notification-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.notification-item p {
  margin: 0;
}

.payment-found {
  display: block;
  margin-top: 6px;
  color: var(--ok);
  font-weight: 700;
  font-size: 12px;
}

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

.outbox-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.8fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.outbox-item.pending {
  border-color: #fdb022;
  background: #fffcf5;
}

.employee-form {
  display: flex;
  align-items: end;
  gap: 8px;
}

.employee-form input {
  min-width: 180px;
}

.employee-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.employee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
}

.employee-chip small {
  color: var(--muted);
}

.import-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.import-controls label {
  min-width: 110px;
}

.import-controls input {
  min-width: 0;
  width: 110px;
}

.import-status {
  color: var(--muted);
}

.import-runs {
  display: grid;
  gap: 6px;
}

.import-run {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(4, auto);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.import-run strong {
  color: var(--text);
}

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

.dashboard-panel {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.dashboard-panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

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

.breakdown-row {
  display: grid;
  gap: 5px;
}

.breakdown-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7ec;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.assignment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 16px;
}

.assignment-bar > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assignment-bar span {
  color: var(--muted);
}

.assignment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.row-check {
  width: 16px;
  height: 16px;
  min-width: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

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

.task-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(140px, 0.8fr) minmax(120px, 0.6fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.task-row.overdue {
  border-color: #fda29b;
  background: #fff6f5;
}

.task-title {
  display: grid;
  gap: 3px;
}

.task-title span {
  color: var(--muted);
}

.task-actions {
  display: flex;
  justify-content: end;
  gap: 6px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

label.search {
  flex: 1;
}

select,
input,
textarea {
  height: 36px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 0 10px;
}

input {
  width: 100%;
}

textarea {
  width: 240px;
  min-width: 240px;
  height: 60px;
  padding: 8px 10px;
  resize: vertical;
}

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

table {
  width: 100%;
  min-width: 2100px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  line-height: 1.35;
}

tr.final-success td {
  background: #f0fdf4;
}

tr.final-fail td {
  background: #fff1f0;
}

.client {
  display: grid;
  gap: 3px;
}

.client span,
.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.status.renewed {
  background: #dcfae6;
  color: var(--ok);
}

.status.churned,
.status.ignored {
  background: #fee4e2;
  color: var(--danger);
}

.cell-input {
  min-width: 0;
  width: 130px;
}

.employee-cell {
  display: grid;
  gap: 6px;
}

.employee-input.unassigned {
  border-color: #f79009;
  background: #fffaeb;
}

.employee-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fffaeb;
  color: #b54708;
  font-size: 12px;
}

.assign-button {
  height: 28px;
  width: fit-content;
  border: 1px solid #f79009;
  border-radius: 6px;
  background: #fffaeb;
  color: #b54708;
  cursor: pointer;
  padding: 0 8px;
}

.assign-self-button {
  height: 28px;
  width: fit-content;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  padding: 0 8px;
}

.cell-select {
  min-width: 146px;
  width: 146px;
}

.cell-date {
  min-width: 172px;
  width: 172px;
}

.checks {
  display: grid;
  gap: 7px;
  min-width: 112px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.checks input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
}

body[data-role="manager"] .employee-col,
body[data-role="manager"] .team-revenue-panel {
  display: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  min-width: 16px;
}

.stacked-fields {
  display: grid;
  gap: 6px;
  min-width: 130px;
}

.stacked-fields select,
.stacked-fields input {
  min-width: 0;
  width: 130px;
}

.row-actions {
  display: grid;
  gap: 6px;
  min-width: 96px;
}

.save-button {
  height: 32px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.save-button[disabled] {
  cursor: default;
  opacity: 0.55;
}

.save-state {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.save-state.error {
  color: var(--danger);
}

.save-state.ok {
  color: var(--ok);
}

.secondary-button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  justify-content: flex-end;
  background: rgba(29, 36, 48, 0.35);
}

.drawer.open {
  display: flex;
}

.drawer-panel {
  width: min(620px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  box-shadow: -12px 0 34px rgba(29, 36, 48, 0.18);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.drawer-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.drawer-body {
  display: grid;
  gap: 24px;
  padding: 22px;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.fact {
  min-height: 62px;
  padding: 10px 12px;
  background: var(--surface);
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-table {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.detail-table th,
.detail-table td {
  padding: 9px 10px;
}

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

.detail-form {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.detail-form input,
.detail-form textarea {
  width: 100%;
}

.detail-form textarea {
  min-width: 0;
  height: 72px;
}

.detail-form button {
  width: fit-content;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.list-item p {
  margin: 4px 0 0;
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.empty {
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .section-head,
  .assignment-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .assignment-actions {
    justify-content: start;
  }

  .user-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .task-row {
    grid-template-columns: 1fr;
  }

  .task-actions {
    justify-content: start;
  }

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

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

  .import-controls,
  .employee-form,
  .outbox-item,
  .import-run {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .employee-form {
    flex-direction: column;
  }

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

  select,
  input,
  textarea {
    min-width: 0;
  }
}
