:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-muted: #f9f9fb;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-strong: #515154;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --accent-dark: #005bb8;
  --accent-soft: #e8f2ff;
  --green: #147a45;
  --green-soft: #e8f7ee;
  --amber: #946200;
  --amber-soft: #fff4d8;
  --rose: #b42318;
  --rose-soft: #fff0ee;
  --violet: #6155c7;
  --violet-soft: #f0efff;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.04), 0 18px 42px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.05), 0 24px 48px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
    system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-sprite {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.login-card h1 {
  font-size: 36px;
}

.login-card label,
.staff-create label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-card input,
.staff-create input,
.staff-create select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
}

.form-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--rose);
  font-size: 14px;
}

.icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  flex: 0 0 auto;
}

.app-shell {
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 780px;
  margin-bottom: 0;
  font-size: 46px;
  font-weight: 760;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 3px;
  font-size: 19px;
  font-weight: 720;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 720;
  letter-spacing: 0;
}

.topbar-actions,
.dialog-actions,
.dialog-actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

.button {
  padding: 0 14px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.button:active,
.icon-button:active {
  transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.22);
  outline-offset: 2px;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.22);
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary,
.compact {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted-strong);
}

.danger {
  border-color: rgba(180, 35, 24, 0.18);
  background: var(--rose-soft);
  color: var(--rose);
}

.compact {
  min-height: 34px;
  padding: 0 11px;
  font-size: 14px;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 104px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
  backdrop-filter: blur(18px);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric strong {
  display: block;
  margin-top: 13px;
  font-size: 34px;
  font-weight: 740;
  line-height: 1;
  letter-spacing: 0;
}

.metric.urgent {
  background: var(--rose-soft);
  border-color: rgba(180, 35, 24, 0.12);
}

.metric.partner-metric {
  background: var(--violet-soft);
  border-color: rgba(97, 85, 199, 0.12);
}

.metric.money {
  background: var(--amber-soft);
  border-color: rgba(148, 98, 0, 0.14);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto repeat(2, 170px) 190px 210px 170px;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.search-field {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--muted);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.search-field:focus-within {
  border-color: rgba(0, 113, 227, 0.38);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.09);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-field input::placeholder,
textarea::placeholder,
input::placeholder {
  color: #9b9ba1;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(232, 232, 237, 0.72);
}

.segment {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong);
  font-weight: 650;
}

.segment:hover {
  background: rgba(255, 255, 255, 0.55);
}

.segment.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
}

.toolbar select {
  min-height: 44px;
  padding: 0 12px;
}

.toolbar select:hover,
.form-grid input:hover,
.form-grid select:hover,
.form-grid textarea:hover {
  border-color: var(--line-strong);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 14px;
  align-items: start;
}

.people-area,
.side-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.people-area {
  min-height: 560px;
  overflow: hidden;
}

.side-panel {
  position: sticky;
  top: 20px;
  overflow: hidden;
  padding-bottom: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.people-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.person-card {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) minmax(150px, 0.8fr) minmax(180px, 0.9fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 92px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.person-card:hover,
.person-card:focus-visible {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.person-card:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.22);
  outline-offset: 2px;
}

.person-main {
  min-width: 0;
}

.person-name {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 720;
}

.person-meta,
.money-line,
.date-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.person-details {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f1f3;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.pill.client {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill.student,
.pill.payment-paid {
  background: var(--green-soft);
  color: var(--green);
}

.pill.client-stage-potential {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.client-stage-current {
  background: var(--green-soft);
  color: var(--green);
}

.pill.client-stage-past {
  background: #f1f1f3;
  color: var(--muted-strong);
}

.pill.partner {
  background: var(--violet-soft);
  color: var(--violet);
}

.pill.payment-partial {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.payment-unpaid,
.pill.due {
  background: var(--rose-soft);
  color: var(--rose);
}

.pill.telegram-in_channel {
  background: var(--green-soft);
  color: var(--green);
}

.pill.telegram-not_in_channel {
  background: var(--rose-soft);
  color: var(--rose);
}

.pill.telegram-unknown {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.telegram-not_connected {
  background: #f1f1f3;
  color: var(--muted-strong);
}

.pill.review-invite-positive {
  background: var(--green-soft);
  color: var(--green);
}

.pill.review-invite-negative {
  background: var(--rose-soft);
  color: var(--rose);
}

.pill.review-invite-waiting {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.review-invite-has_request {
  background: #f1f1f3;
  color: var(--muted-strong);
}

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

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted-strong);
}

.reminders-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.reminder-item {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
}

.reminder-item strong {
  overflow-wrap: anywhere;
  font-weight: 720;
}

.reminder-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  display: none;
  max-width: 470px;
  margin: 74px auto;
  padding: 0 24px;
  text-align: center;
}

.empty-state p {
  margin-bottom: 22px;
  color: var(--muted);
}

.person-dialog {
  width: min(860px, calc(100vw - 28px));
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(24px);
}

.person-dialog::backdrop {
  background: rgba(29, 29, 31, 0.28);
  backdrop-filter: blur(5px);
}

.person-dialog form {
  padding: 24px;
}

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

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

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

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  font-weight: 520;
}

.form-grid textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 20px;
}

.staff-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.staff-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
}

.staff-item div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.staff-item strong {
  overflow-wrap: anywhere;
}

.staff-item span,
.staff-note {
  color: var(--muted);
  font-size: 13px;
}

.staff-create {
  display: grid;
  grid-template-columns: 1fr 1fr 170px;
  gap: 14px;
}

.staff-note {
  max-width: 420px;
  margin-bottom: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 4;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(29, 29, 31, 0.92);
  color: white;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  backdrop-filter: blur(14px);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .people-area {
    min-height: auto;
  }

  .side-panel {
    position: static;
  }
}

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

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

  h1 {
    font-size: 34px;
    line-height: 1.08;
  }

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

  .topbar-actions .button {
    width: 100%;
  }

  .user-badge,
  .topbar-actions .icon-button {
    width: 100%;
  }

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

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

  .person-card {
    grid-template-columns: 1fr;
  }

  .card-actions {
    justify-content: flex-start;
  }

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

  .staff-create {
    grid-template-columns: 1fr;
  }

  .empty-state {
    margin: 54px auto;
  }

  .dialog-actions,
  .dialog-actions-right {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions .button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .summary-grid,
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 18px;
  }

  h1 {
    font-size: 31px;
  }
}
