:root {
  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #17222a;
  --muted: #63717a;
  --line: #d9e0dc;
  --line-strong: #c6d0ca;
  --teal: #18756f;
  --teal-soft: #dff0ec;
  --coral: #cf5b4c;
  --coral-soft: #f8e3df;
  --amber: #d99a28;
  --amber-soft: #f6ebcf;
  --blue: #4c5e92;
  --blue-soft: #e4e8f4;
  --ok: #287d4b;
  --danger: #b23b32;
  --shadow: 0 14px 30px rgba(23, 34, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(246, 248, 245, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

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

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(23, 34, 42, 0.14);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.session-badge {
  display: grid;
  min-width: 190px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.session-badge strong,
.session-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-badge strong {
  font-size: 13px;
}

.session-badge span {
  color: var(--muted);
  font-size: 12px;
}

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

.login-panel {
  width: min(100%, 430px);
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 18px;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-inline span,
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(24, 117, 111, 0.16);
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

.sidebar {
  position: sticky;
  top: 73px;
  height: calc(100vh - 73px);
  padding: 18px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

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

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav button:hover {
  background: var(--surface-soft);
}

.nav button.active {
  background: var(--ink);
  color: #fff;
}

.nav-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin: 16px 10px 8px;
  text-transform: uppercase;
}

.content {
  min-width: 0;
  padding: 24px;
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.page-head p {
  max-width: 850px;
  margin: 6px 0 0;
  color: var(--muted);
}

.section-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

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

.section-head.compact {
  margin-bottom: 8px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.metric-card {
  min-height: 112px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1;
}

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

.metric-card.teal {
  border-top: 4px solid var(--teal);
}

.metric-card.coral {
  border-top: 4px solid var(--coral);
}

.metric-card.amber {
  border-top: 4px solid var(--amber);
}

.metric-card.blue {
  border-top: 4px solid var(--blue);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

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

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

.panel.soft {
  background: var(--surface-soft);
  box-shadow: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 5px;
}

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

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

.btn {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.btn:hover {
  border-color: var(--teal);
}

.btn.primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.btn.dark {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lesson-list,
.entity-list {
  display: grid;
  gap: 10px;
}

.lesson-item,
.entity-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.lesson-item:hover,
.entity-item:hover {
  border-color: var(--line-strong);
}

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

.lesson-title,
.entity-title {
  margin: 0;
  font-weight: 760;
}

.lesson-meta,
.entity-meta,
.muted {
  color: var(--muted);
}

.lesson-meta,
.entity-meta {
  margin-top: 3px;
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.chip.teal {
  background: var(--teal-soft);
  border-color: #b9ddd5;
}

.chip.coral {
  background: var(--coral-soft);
  border-color: #efc2ba;
}

.chip.amber {
  background: var(--amber-soft);
  border-color: #ecd59d;
}

.chip.blue {
  background: var(--blue-soft);
  border-color: #c6cde4;
}

.chip.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status-planned .status-dot {
  background: var(--blue);
}

.status-completed .status-dot,
.status-finished .status-dot {
  background: var(--ok);
}

.status-postponed .status-dot,
.status-waiting_confirmation .status-dot {
  background: var(--amber);
}

.status-cancelled .status-dot {
  background: var(--danger);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

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

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  text-transform: uppercase;
}

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

.progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  background: var(--surface-soft);
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--teal-soft);
  border: 1px solid #b9ddd5;
  border-radius: 8px;
}

.notice.error {
  background: var(--coral-soft);
  border-color: #efc2ba;
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.calendar-day {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-date {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-date::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

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

.mini-stat {
  min-height: 80px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.rating {
  color: var(--amber);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .metric-grid,
  .three-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    padding: 12px 14px;
  }

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 10px 14px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-kicker {
    display: none;
  }

  .nav button {
    min-width: 150px;
  }

  .content {
    padding: 16px 14px 24px;
  }

  .page-head {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .filters,
  .form-grid,
  .availability-grid {
    grid-template-columns: 1fr;
  }

  .lesson-item,
  .entity-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand-title {
    font-size: 16px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .top-actions,
  .toolbar,
  .btn-row {
    align-items: stretch;
    flex-direction: column;
  }

  .field-inline {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }

  .btn {
    width: 100%;
  }
}
