:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #17191c;
  --muted: #777d86;
  --line: #e7e9ed;
  --dark: #191b1f;
  --radius: 18px;
  --shadow: 0 18px 60px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

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

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

button { cursor: pointer; }

.app-shell {
  width: min(1460px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

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

.topbar h1 {
  margin: 5px 0 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  color: #8d939c;
}

.muted {
  color: var(--muted);
  margin: 0;
}

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

.primary, .ghost, .danger {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 750;
}

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

.primary:hover { background: #2d3035; }

.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.danger {
  background: #fff0f0;
  color: #b42318;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px auto;
  gap: 12px;
  margin-bottom: 14px;
}

.search, select, dialog input, dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: .16s ease;
}

.search:focus, select:focus, dialog input:focus, dialog textarea:focus {
  border-color: #b3b7bf;
  box-shadow: 0 0 0 3px rgba(25, 27, 31, .06);
}

.counter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 14px;
}

.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  color: #8b9098;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }

.fio-cell { font-weight: 750; }

.link-button, .row-edit, .icon-btn {
  background: none;
  border: 0;
  color: inherit;
}

.link-button {
  padding: 0;
  text-align: left;
  font-weight: inherit;
}

.row-edit {
  color: #6f7580;
  font-size: 13px;
}

.note-cell {
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #5d626a;
}

.date-cell {
  white-space: nowrap;
  color: #4f555d;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #f0f1f3;
}

.badge.green { background: #eaf7ef; color: #267244; }
.badge.blue { background: #edf3ff; color: #3a63a8; }
.badge.gray { background: #f1f2f4; color: #656b73; }
.badge.violet { background: #f2edff; color: #7051b5; }

.empty {
  padding: 64px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 42px;
  color: #b1b6be;
}

.empty h3 { margin-bottom: 6px; }
.empty p { margin-top: 0; color: var(--muted); }

.hidden { display: none !important; }

dialog {
  width: min(600px, calc(100% - 28px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .22);
}

dialog::backdrop {
  background: rgba(12, 14, 18, .45);
  backdrop-filter: blur(3px);
}

dialog form {
  padding: 24px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

.dialog-head h2 {
  margin: 5px 0 0;
  letter-spacing: -.03em;
}

.icon-btn {
  font-size: 30px;
  line-height: 1;
  color: #777d86;
}

dialog label {
  display: block;
  margin-bottom: 16px;
}

dialog label span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

dialog textarea {
  resize: vertical;
  min-height: 110px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}

.spacer { flex: 1; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at top left, #fff 0, transparent 32%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 {
  margin: 18px 0 6px;
  letter-spacing: -.04em;
}

.brand {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: #191b1f;
  color: #fff;
  border-radius: 16px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.login-form {
  margin-top: 24px;
}

.login-form label {
  display: block;
  margin-bottom: 14px;
}

.login-form label span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.login-form .primary { width: 100%; margin-top: 4px; }

.alert {
  margin-top: 18px;
  background: #fff0f0;
  color: #b42318;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
}

@media (max-width: 800px) {
  .app-shell {
    width: min(100% - 22px, 1460px);
    padding-top: 22px;
  }

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

  .topbar-actions {
    justify-content: space-between;
  }

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

  .counter {
    justify-content: flex-start;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
