:root {
  --red: #b91c1c;
  --red-dark: #7f1d1d;
  --red-soft: #fff1f2;
  --ink: #211d1f;
  --muted: #6b6367;
  --line: #eadadd;
  --bg: #f8f5f6;
  --white: #fff;
  --shadow: 0 24px 70px rgba(60, 7, 17, .24);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Tahoma, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }

.topbar { min-height: 76px; background: #fff; border-bottom: 3px solid var(--red); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 4%; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 13px; align-items: center; min-width: 0; }
.brand-logo { width: 48px; height: 48px; border-radius: 13px; object-fit: contain; background: #fff; padding: 4px; box-shadow: 0 5px 18px rgba(56, 9, 17, .16); flex: 0 0 auto; }
.brand strong { display: block; }
.brand small { display: block; color: var(--muted); margin-top: 5px; }
.userbox { display: flex; gap: 18px; align-items: center; }
.userbox form { margin: 0; }
.link-button { border: 0; background: none; color: var(--red); cursor: pointer; }

.login-page { min-height: 100vh; min-height: 100dvh; background: #6f1519; }
.login-page .topbar { display: none; }
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(28px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); position: relative; isolation: isolate; background: #6f1519 url("../img/login-background.jpg") center / cover no-repeat fixed; }
.login-shell::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(135deg, rgba(85, 8, 16, .88), rgba(127, 29, 29, .58) 48%, rgba(255, 255, 255, .18)); backdrop-filter: blur(2px); }
.login-card { width: min(460px, 100%); background: rgba(255, 255, 255, .975); border: 1px solid rgba(255, 255, 255, .75); border-radius: 24px; padding: 28px 30px 24px; text-align: center; box-shadow: var(--shadow); }
.login-logo { width: 84px; height: 84px; object-fit: contain; border-radius: 18px; background: #fff; padding: 6px; margin: 0 auto 13px; box-shadow: 0 8px 26px rgba(49, 6, 13, .2); }
.login-heading h1 { color: var(--red-dark); font-size: clamp(1.45rem, 5vw, 1.85rem); margin: 0 0 7px; }
.school-title { color: var(--red); font-weight: 800; font-size: .95rem; line-height: 1.8; margin: 0; }
.login-help { color: var(--muted); font-size: .88rem; line-height: 1.8; margin: 8px 0 0; }
.form-stack { display: grid; gap: 8px; margin-top: 20px; text-align: right; }
.form-stack label { font-size: .9rem; font-weight: 700; color: #42393d; }
.form-stack input { width: 100%; min-height: 52px; border: 1px solid #ddcdd0; border-radius: 11px; padding: 12px 14px; color: var(--ink); background: #fff; text-align: right; outline: none; transition: border-color .15s, box-shadow .15s; }
.form-stack input::placeholder { color: #9c9296; }
.form-stack input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(185, 28, 28, .11); }
.password-field { position: relative; }
.password-field input { padding-left: 54px; }
.password-toggle { position: absolute; left: 7px; top: 7px; bottom: 7px; width: 42px; border: 0; border-radius: 8px; background: var(--red-soft); color: var(--red-dark); cursor: pointer; display: grid; place-items: center; }
.eye-icon { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }
.primary-button { min-height: 54px; margin-top: 8px; border: 0; border-radius: 11px; padding: 13px; background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 8px 20px rgba(185, 28, 28, .23); transition: transform .15s, box-shadow .15s; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 11px 25px rgba(185, 28, 28, .3); }
.primary-button:active { transform: translateY(0); }
.alert { margin-top: 16px; background: #fff0f1; border: 1px solid #f1b8be; color: #8d1019; border-radius: 10px; padding: 11px 12px; font-size: .86rem; line-height: 1.7; text-align: right; }
.registration-note { margin-top: 19px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); line-height: 1.9; }
.login-actions { display: grid; gap: 11px; margin-top: 14px; }
.secondary-button { min-height: 50px; border-radius: 11px; padding: 12px 14px; display: grid; place-items: center; color: var(--red-dark); background: #fff0f1; border: 1px solid #e6aeb4; font-weight: 800; text-decoration: none; transition: transform .15s, box-shadow .15s, background .15s; }
.secondary-button:hover { transform: translateY(-1px); background: #ffe5e8; box-shadow: 0 8px 18px rgba(127, 29, 29, .12); }
.secondary-button--light { background: #fff; border-color: #ddcdd0; color: #51464b; }
.login-links { margin-top: 16px; }
.login-links a { color: var(--red-dark); font-weight: 700; text-decoration: none; }
.form-stack p { display: grid; gap: 6px; margin: 0; }
.form-stack select { width: 100%; min-height: 52px; border: 1px solid #ddcdd0; border-radius: 11px; padding: 10px 14px; background: #fff; }
.form-stack .errorlist { color: #8d1019; margin: 0; padding-right: 18px; font-size: .8rem; }

.app-layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 76px); }
.sidebar { background: #241f22; padding: 28px 18px; display: flex; flex-direction: column; gap: 9px; }
.sidebar a, .sidebar span { color: #eee; text-decoration: none; padding: 14px 16px; border-radius: 10px; }
.sidebar a.active { background: var(--red); }
.sidebar .coming { color: #9e969a; }
.content { padding: 36px; max-width: 1500px; width: 100%; margin: auto; }
.welcome { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.welcome h1 { margin: 0 0 8px; }
.welcome p { margin: 0; color: var(--muted); }
.owner-badge { background: #fee8ea; color: var(--red-dark); border: 1px solid #efbbc0; border-radius: 999px; padding: 10px 16px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; }
.stats article, .panel { background: #fff; border: 1px solid var(--line); border-radius: 17px; padding: 22px; box-shadow: 0 7px 20px rgba(50, 20, 25, .05); }
.stats strong { display: block; color: var(--red); font-size: 30px; margin-bottom: 8px; }
.stats span { color: var(--muted); }
.panel { margin-top: 22px; }
.panel h2 { margin-top: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips span { background: #f3edef; border-radius: 999px; padding: 8px 13px; }
.message-stack { display: grid; gap: 10px; margin-bottom: 18px; }
.notice { border: 1px solid var(--line); border-radius: 12px; padding: 12px 15px; background: #fff; }
.notice--success { border-color: #a7d7b5; background: #effaf2; color: #17612e; }
.notice--error { border-color: #efbbc0; background: var(--red-soft); color: var(--red-dark); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0 0 7px; }
.page-heading p { margin: 0; color: var(--muted); }
.action-button { display: inline-grid; place-items: center; min-height: 46px; padding: 11px 18px; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; text-decoration: none; font-weight: 800; cursor: pointer; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(230px, 1fr)); gap: 16px; }
.feature-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 7px 20px rgba(50, 20, 25, .05); }
.feature-card__head { display: flex; justify-content: space-between; gap: 12px; padding: 15px 17px; background: var(--red); color: #fff; }
.feature-card p { padding: 0 17px; color: var(--muted); }
.card-actions { display: flex; border-top: 1px solid var(--line); }
.card-actions a { flex: 1; padding: 12px 16px; text-align: center; color: var(--red-dark); font-weight: 700; text-decoration: none; }
.empty-state { padding: 28px; border: 1px dashed #d5c3c7; border-radius: 14px; background: #fff; color: var(--muted); }
.data-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 15px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th, .data-table td { padding: 14px 16px; text-align: right; border-bottom: 1px solid var(--line); }
.data-table th { background: #f7edef; color: var(--red-dark); }
.data-table tr:last-child td { border-bottom: 0; }
.form-panel { max-width: 900px; }
.entity-form { display: grid; gap: 16px; }
.entity-form p { display: grid; gap: 7px; margin: 0; }
.entity-form label { font-weight: 700; }
.entity-form input, .entity-form select, .entity-form textarea { width: 100%; border: 1px solid #ddcdd0; border-radius: 10px; padding: 11px 13px; background: #fff; }
.entity-form input:focus, .entity-form select:focus, .entity-form textarea:focus { outline: 0; border-color: var(--red); box-shadow: 0 0 0 3px rgba(185, 28, 28, .1); }
.entity-form .errorlist { margin: 0; color: var(--red-dark); }
.section-tabs { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 20px; }
.section-tabs a { padding: 10px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 700; }
.section-tabs a.active { background: var(--red); border-color: var(--red); color: #fff; }
.compact-stats { grid-template-columns: repeat(5, minmax(130px, 1fr)); }

@media (max-width: 850px) {
  .brand small { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { padding: 10px 14px; flex-direction: row; overflow-x: auto; gap: 7px; position: sticky; top: 76px; z-index: 4; }
  .sidebar a, .sidebar span { white-space: nowrap; padding: 10px 13px; }
  .sidebar .coming { display: none; }
  .content { padding: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .welcome { align-items: flex-start; gap: 18px; flex-direction: column; }
  .topbar { padding-inline: 18px; }
  .userbox > span { display: none; }
  .card-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .compact-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .login-shell { padding-block: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-bottom)); background-attachment: scroll; }
  .login-card { border-radius: 18px; padding: 22px 17px 18px; }
  .login-logo { width: 72px; height: 72px; border-radius: 15px; }
  .login-help { font-size: .82rem; }
  .form-stack { margin-top: 16px; }
  .form-stack input { min-height: 56px; font-size: 16px; }
  .primary-button { min-height: 56px; }
  .registration-note { margin-top: 16px; }
  .stats { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .action-button { width: 100%; }
  .card-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 12px 24px; }
  .section-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 5px; }
  .section-tabs a { white-space: nowrap; }
}

@media (max-width: 360px) {
  .login-shell { padding-inline: 10px; }
  .login-card { padding-inline: 13px; }
  .school-title { font-size: .86rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
