:root {
  --bg: #f3f5f7;
  --ink: #172033;
  --muted: #5c6778;
  --line: #e3e8ee;
  --nav: #172033;
  --wait: #8a3d00;
  --wait-bg: #fff1df;
  --paid: #0d6b3d;
  --paid-bg: #e5f7ee;
  --study: #163e86;
  --study-bg: #e7f0ff;
  --bad: #8d1d1d;
  --bad-bg: #ffe4e4;
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(420px, 100%); background: white; border-radius: 16px; padding: 28px; border: 1px solid var(--line); }
.login h1 { font-size: 28px; }
label { display: grid; gap: 6px; margin-top: 14px; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: white; }
textarea { min-height: 80px; resize: vertical; }
.primary, .ghost { border-radius: 999px; padding: 10px 16px; }
.primary { background: var(--ink); color: white; border: 0; }
.ghost { background: white; border: 1px solid var(--line); }
.error { color: var(--bad); min-height: 1.2em; }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: white; padding: 22px 12px; }
.nav h1 { font-size: 20px; padding: 0 12px 8px; }
.nav .who { color: #c5d0e0; font-size: 13px; padding: 0 12px 16px; }
.nav button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  color: white;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 4px;
}
.nav button.active { background: white; color: var(--ink); }
.nav button b { font-weight: 700; }
.nav .sync { margin-top: 18px; }
.main { padding: 22px 24px 48px; min-width: 0; }
.board { display: flex; gap: 10px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.column { width: 250px; flex: 0 0 250px; background: #e7edf4; border-radius: 14px; padding: 10px; min-height: 180px; }
.column.over { outline: 2px solid #163e86; }
.column h3 { font-size: 15px; display: flex; justify-content: space-between; }
.column p { color: var(--muted); font-size: 12px; min-height: 2.6em; margin: 4px 0 8px; }
.kcard { background: white; border-radius: 12px; padding: 10px; margin-top: 8px; cursor: grab; box-shadow: 0 1px 0 rgba(23,32,51,.06); }
.kcard .phone { font-weight: 700; margin-top: 4px; }
.kcard .nophone { color: #8a3d00; font-weight: 700; margin-top: 4px; }
.kcard .social { color: var(--muted); font-size: 12px; }
.kempty { color: var(--muted); font-size: 13px; padding: 8px 2px; }
.marks { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.modal-back { position: fixed; inset: 0; background: rgba(23, 32, 51, .45); display: grid; place-items: center; z-index: 30; padding: 20px; }
.modal { width: min(960px, 100%); max-height: min(90vh, 920px); overflow: auto; background: #f7f9fb; border-radius: 18px; padding: 18px; }
.modal .timeline { max-height: 280px; overflow: auto; }
.modal .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.top h2 { font-size: 28px; letter-spacing: -0.03em; }
.muted { color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button, .search { border-radius: 999px; }
.filters button { border: 1px solid var(--line); background: white; padding: 8px 12px; }
.filters button.active { background: var(--ink); color: white; border-color: var(--ink); }
.search { border: 1px solid var(--line); padding: 10px 14px; width: min(360px, 100%); background: white; }

.home { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 14px; }
.card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card.wait { border-top: 6px solid #e07a1f; }
.card.study { border-top: 6px solid #2f6fed; }
.card.paid { border-top: 6px solid #1c9b5a; }
.card h3 { font-size: 18px; margin-bottom: 4px; }
.card .lead { min-height: 2.6em; margin-bottom: 10px; }
.line { display: grid; gap: 2px; width: 100%; text-align: left; background: transparent; border: 0; border-top: 1px solid var(--line); padding: 10px 0; }
.line strong { font-size: 15px; }
.more { margin-top: 8px; }

.main { min-width: 0; }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 16px; overflow: hidden; table-layout: fixed; }
th { text-align: left; font-size: 12px; letter-spacing: 0.02em; color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line); background: #f8fafc; }
td { padding: 12px; border-bottom: 1px solid #eef2f6; vertical-align: top; overflow-wrap: anywhere; }
tr.clickable { cursor: pointer; }
tr.clickable:hover, tr.active { background: #f4f8ff; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 700; }
.pill.wait { background: var(--wait-bg); color: var(--wait); }
.pill.paid { background: var(--paid-bg); color: var(--paid); }
.pill.study { background: var(--study-bg); color: var(--study); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.calm { background: #eef1f4; color: var(--muted); }
.empty-state { background: white; border: 1px dashed var(--line); border-radius: 16px; padding: 28px; }
.empty-state strong { display: block; font-size: 18px; margin-bottom: 6px; }

.detail { margin-top: 16px; }
.detail h3 { margin: 16px 0 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.forms { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.staff-list { display: grid; gap: 12px; margin-top: 12px; }
.check { align-content: end; }
.check input { width: auto; margin-right: 8px; }
.forms form, .block { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.timeline { display: grid; gap: 8px; }
.fact { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
@media (max-width: 980px) {
  .shell, .home, .forms, .grid { grid-template-columns: 1fr; }
  .nav { padding-bottom: 8px; }
}
