@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --brand-soft: #ccfbf1;
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #14b8a6;
  --blue: #0284c7;
  --blue-soft: #e0f2fe;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning-soft: #fffbeb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.primary-button,
.secondary-button,
.primary-link,
.secondary-link,
.logout-link {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button,
.primary-link {
  background: linear-gradient(135deg, var(--brand), #0891b2);
  color: #fff;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.25);
}

.primary-button:hover,
.primary-link:hover {
  background: linear-gradient(135deg, var(--brand-dark), #0e7490);
  transform: translateY(-1px);
}

.secondary-button,
.secondary-link {
  background: var(--panel-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-button:hover,
.secondary-link:hover {
  background: #fff;
  border-color: #cbd5e1;
}

.logout-link {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

button.danger {
  background: var(--danger);
  color: #fff;
}

.compact-button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 32px;
  align-items: center;
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0;
}

.login-intro {
  display: grid;
  gap: 14px;
}

.login-intro h1 {
  font-size: 48px;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -0.03em;
}

.login-intro p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.login-card,
.panel,
.hero-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 32px;
}

.login-card h2,
.section-title h2,
.page-header h2,
.hero-panel h1 {
  margin: 0;
  letter-spacing: -0.02em;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.error {
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 14px;
  font-weight: 600;
}

.success {
  border: 1px solid #99f6e4;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 14px;
  margin: 0;
  font-weight: 700;
}

/* Admin layout */
.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, var(--sidebar) 0%, #111827 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  padding: 6px 8px;
}

.brand span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #0891b2);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-list a:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.nav-list a.is-active {
  background: rgba(20, 184, 166, 0.15);
  color: #5eead4;
  box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.workspace {
  min-width: 0;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar div {
  display: grid;
  gap: 4px;
}

.topbar strong {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.topbar span,
.section-title p,
.page-header p,
.hero-panel p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1240px, calc(100% - 40px));
  margin: 28px auto 56px;
  display: grid;
  gap: 22px;
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 28px;
  background: linear-gradient(135deg, #ffffff 0%, #f0fdfa 100%);
}

.hero-panel div:first-child {
  display: grid;
  gap: 12px;
}

.hero-panel h1 {
  max-width: 720px;
  font-size: 32px;
  line-height: 1.15;
}

.hero-panel p {
  max-width: 760px;
  margin: 0;
  line-height: 1.6;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stats,
.two-col {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.two-col {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: start;
}

.stats article {
  display: grid;
  gap: 8px;
  padding: 22px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stats span,
.stats small {
  color: var(--muted);
  font-size: 13px;
}

.stats strong {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.panel {
  padding: 24px;
  display: grid;
  gap: 20px;
}

.section-title,
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.section-title div,
.page-header div {
  display: grid;
  gap: 6px;
}

.section-title p,
.page-header p {
  max-width: 560px;
  margin: 0;
  line-height: 1.55;
  font-size: 14px;
}

.page-header h2 {
  font-size: 26px;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.page-actions p {
  flex: 1 1 280px;
  margin: 0;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-page-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--panel);
  z-index: 1;
}

.form-page-actions .primary-button {
  min-width: 140px;
}

.role-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}

.role-fields[hidden] {
  display: none;
}

.role-fields-title {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0 4px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.security-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.stack,
.ticket-list {
  display: grid;
  gap: 14px;
}

/* Plans page */
.plans-panel {
  gap: 24px;
}

.add-card {
  border: 2px solid #99f6e4;
  border-radius: 14px;
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
  padding: 22px;
  display: grid;
  gap: 18px;
  box-shadow: 0 12px 30px rgba(13, 148, 136, 0.1);
}

.add-card-head {
  display: grid;
  gap: 4px;
}

.add-card-head strong {
  font-size: 18px;
  color: var(--brand-dark);
}

.add-card-head span {
  color: var(--muted);
  font-size: 14px;
}

.add-plan-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.add-plan-wide {
  grid-column: span 2;
}

.add-plan-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  display: grid;
  gap: 8px;
}

.empty-state strong {
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.empty-state .primary-button {
  justify-self: center;
  margin-top: 8px;
}

.users-panel {
  gap: 24px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.users-table td,
.users-table th {
  color: var(--ink);
}

.users-table .cell-id {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.users-table .cell-name {
  color: var(--ink);
  font-weight: 700;
}

.muted-inline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f8fafc;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--panel-soft);
}

.table-input {
  min-width: 120px;
  padding: 9px 12px;
  font-size: 14px;
}

.table-input-price {
  min-width: 100px;
  max-width: 140px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
  background: var(--panel-soft);
  color: var(--muted);
}

.role-teacher,
.status-active,
.status-answered {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.role-student,
.status-open {
  background: var(--blue-soft);
  color: #0369a1;
}

.role-parent,
.status-passive,
.status-closed {
  background: var(--panel-soft);
  color: var(--muted);
}

.role-super_admin {
  background: var(--warning-soft);
  color: #92400e;
}

.muted {
  margin: 0;
}

.ticket-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  background: var(--panel-soft);
}

.ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.ticket-head div {
  display: grid;
  gap: 4px;
}

.ticket-card span,
.reply {
  color: var(--muted);
  font-size: 13px;
}

.ticket-card p {
  margin: 0;
  line-height: 1.55;
}

.reply {
  border-left: 3px solid var(--brand);
  padding: 12px 14px;
  background: #fff;
  border-radius: 0 10px 10px 0;
}

.ticket-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  gap: 14px;
  align-items: end;
}

@media (max-width: 1040px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-list a {
    white-space: nowrap;
  }

  .stats,
  .grid-form,
  .security-form,
  .two-col,
  .add-plan-form,
  .ticket-form {
    grid-template-columns: 1fr 1fr;
  }

  .add-plan-wide {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .login-shell,
  .stats,
  .grid-form,
  .security-form,
  .two-col,
  .add-plan-form,
  .ticket-form {
    grid-template-columns: 1fr;
  }

  .add-plan-wide {
    grid-column: auto;
  }

  .login-intro h1 {
    font-size: 34px;
  }

  .topbar,
  .hero-panel,
  .section-title,
  .page-header,
  .page-actions,
  .ticket-head {
    align-items: stretch;
    flex-direction: column;
  }

  .role-fields {
    grid-template-columns: 1fr;
  }

  .form-page-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    position: static;
  }

  .hero-panel h1 {
    font-size: 24px;
  }

  .quick-actions {
    flex-direction: column;
  }

  th,
  td {
    white-space: nowrap;
  }
}
