:root {
  color-scheme: light;
  --ink: #13201f;
  --muted: #64706d;
  --paper: #f7f4ee;
  --surface: #ffffff;
  --line: #d9ded8;
  --brand: #173f3a;
  --brand-soft: #dcebe5;
  --teal: #0e766e;
  --amber: #b76e00;
  --rose: #ad3854;
  --blue: #315d96;
  --shadow: 0 16px 42px rgba(19, 32, 31, 0.12);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 63, 58, 0.08), transparent 280px),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

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

.mobile-frame {
  width: min(100%, 1120px);
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 28px);
  background: rgba(247, 244, 238, 0.92);
  border-bottom: 1px solid rgba(217, 222, 216, 0.78);
  backdrop-filter: blur(18px);
}

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

.mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--brand);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
}

.brand-subtitle,
.caption,
.muted {
  color: var(--muted);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

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

.content {
  width: 100%;
  padding: 16px clamp(14px, 4vw, 28px) calc(88px + var(--safe-bottom));
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: clamp(20px, 6vw, 56px);
}

.login-panel {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 34px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel .mark {
  margin-bottom: 18px;
}

.login-panel h1,
.view-head h1,
.section-title {
  margin: 0;
  line-height: 1.08;
}

.login-panel h1 {
  font-size: clamp(1.6rem, 6vw, 2.35rem);
}

.login-panel p {
  margin: 10px 0 20px;
  color: var(--muted);
  line-height: 1.55;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.field span,
.field label {
  font-size: 0.82rem;
  font-weight: 750;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #c8d0ca;
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffdf9;
  padding: 11px 12px;
  outline: none;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 118, 110, 0.16);
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--ink);
  background: #e7ece8;
  cursor: pointer;
  font-weight: 800;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn.primary {
  color: #ffffff;
  background: var(--brand);
}

.btn.warning {
  color: #ffffff;
  background: var(--amber);
}

.btn.danger {
  color: #ffffff;
  background: var(--rose);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--radius);
}

.status {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 700;
}

.status.error {
  color: #84223a;
  background: #f8dde5;
}

.view-head {
  display: grid;
  gap: 10px;
  margin: 4px 0 18px;
}

.view-head h1 {
  font-size: clamp(1.55rem, 7vw, 2.5rem);
}

.view-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.panel {
  grid-column: span 12;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(19, 32, 31, 0.06);
}

.panel.compact {
  padding: 12px;
}

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

.metric {
  min-height: 94px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfaf6;
}

.metric strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf9;
}

.list-item.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.list-item strong {
  line-height: 1.2;
}

.caption {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.tag.amber {
  color: #714300;
  background: #f7e2bf;
}

.tag.blue {
  color: #264b78;
  background: #dce8f7;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.step-dot {
  min-height: 7px;
  border-radius: 999px;
  background: #d5dbd7;
}

.step-dot.active {
  background: var(--brand);
}

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

.segment button {
  min-height: 40px;
  border-radius: var(--radius);
  background: #e7ece8;
  color: var(--ink);
  font-weight: 800;
}

.segment button.active {
  color: #ffffff;
  background: var(--brand);
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
}

.class-tile {
  min-height: 118px;
  display: grid;
  gap: 8px;
  align-content: start;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf9;
  cursor: pointer;
}

.class-tile.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 118, 110, 0.15);
}

.two-col {
  display: grid;
  gap: 12px;
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(255, 253, 249, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav button {
  min-width: 0;
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}

.nav button.active {
  color: var(--brand);
  background: var(--brand-soft);
}

.nav .nav-icon {
  font-size: 1rem;
  line-height: 1;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed #c7d0c9;
  border-radius: var(--radius);
  background: #fbfaf6;
}

.progress-line {
  height: 10px;
  border-radius: 999px;
  background: #e7ece8;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.hide-mobile {
  display: none;
}

@media (min-width: 720px) {
  .content {
    padding-bottom: 96px;
  }

  .dashboard-grid .span-4 {
    grid-column: span 4;
  }

  .dashboard-grid .span-5 {
    grid-column: span 5;
  }

  .dashboard-grid .span-6 {
    grid-column: span 6;
  }

  .dashboard-grid .span-7 {
    grid-column: span 7;
  }

  .dashboard-grid .span-8 {
    grid-column: span 8;
  }

  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hide-mobile {
    display: inline-flex;
  }
}

@media (min-width: 980px) {
  .nav {
    position: sticky;
    bottom: auto;
    order: -1;
    grid-row: 1 / 2;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(19, 32, 31, 0.06);
  }

  .mobile-frame {
    grid-template-rows: auto auto 1fr;
  }

  .content {
    padding-top: 22px;
  }
}
