:root {
  --bg: #f4f6f8;
  --ink: #1e2930;
  --muted: #66747c;
  --line: #dfe5dd;
  --panel: #ffffff;
  --green: #2f7d57;
  --green-dark: #1f5c42;
  --blue: #2f6f9f;
  --amber: #b87521;
  --red: #b9493f;
  --shadow: 0 18px 50px rgba(31, 43, 36, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfcfd, var(--bg));
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 56px);
  backdrop-filter: blur(18px);
  background: rgba(246, 247, 242, 0.82);
  border-bottom: 1px solid rgba(223, 229, 221, 0.7);
}
.brand, .topbar nav { display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 800; font-size: 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: conic-gradient(from 160deg, var(--green), #9bc37f, var(--blue), var(--green));
}
.topbar nav a { color: var(--muted); font-size: 14px; }
.admin-link, .admin-entry { color: var(--green-dark) !important; font-weight: 800; }
main { min-height: calc(100vh - 72px); }

.flash-wrap { max-width: 1120px; margin: 18px auto 0; padding: 0 18px; }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 8px; background: #fff; border: 1px solid var(--line); }
.flash.success { border-color: #a4d4b7; color: #1f6f44; }
.flash.danger { border-color: #efb3a8; color: #a33a2a; }
.flash.warning { border-color: #e7c784; color: #8a5a13; }

.hero {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: clamp(28px, 5vw, 80px);
  align-items: center;
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(38px, 7vw, 86px) 18px 42px;
}
.eyebrow { margin: 0 0 12px; color: var(--green); font-weight: 800; letter-spacing: 0; }
.hero h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(40px, 7vw, 86px);
  line-height: 1.02;
  letter-spacing: 0;
}
.lead { max-width: 580px; color: var(--muted); font-size: 18px; line-height: 1.8; }
.login-panel, .auth-panel, .panel {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(223,229,221,0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-panel, .auth-panel { padding: 28px; }
.login-panel h2, .auth-panel h1 { margin: 0 0 20px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
}
input:focus { outline: 2px solid rgba(47,125,87,0.18); border-color: var(--green); }
.login-panel label, .auth-panel label { margin-bottom: 14px; }
.primary, .secondary, .danger-soft {
  border: 0;
  border-radius: 8px;
  padding: 11px 15px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-dark); }
.secondary { background: #eef3ec; color: var(--green-dark); border: 1px solid #d7e3d4; }
.danger-soft { background: #fff0ed; color: var(--red); border: 1px solid #f1c4bd; }
.login-panel .primary, .auth-panel .primary { width: 100%; }
.login-links { display: flex; justify-content: space-between; margin-top: 18px; color: var(--blue); font-size: 14px; }
.text-link { display: block; text-align: center; margin-top: 16px; color: var(--blue); }

.home-instruments { display: grid; grid-template-columns: 230px minmax(260px, 360px); gap: 16px; align-items: stretch; margin-top: 28px; }
.clock-face, .month-card, .side-clock {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 12px 28px rgba(31, 43, 36, 0.08);
}
.clock-face { display: grid; align-content: center; gap: 8px; padding: 22px; }
.clock-face span, .side-clock span, .month-title span { color: var(--muted); font-size: 13px; }
.clock-face strong, .side-clock strong { font-size: 40px; line-height: 1; letter-spacing: 0; }
.clock-face small, .side-clock small { color: var(--green-dark); }
.month-card { padding: 16px; }
.month-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-grid span {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
  background: #f7f9f5;
  font-size: 13px;
}
.calendar-grid.weekdays span { aspect-ratio: auto; background: transparent; color: var(--muted); font-weight: 800; padding-bottom: 3px; }
.calendar-grid .outside { color: #a9b3b7; background: #fbfcfd; }
.calendar-grid .today { background: var(--green); color: #fff; font-weight: 900; }
.mini-calendar, .heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 360px; margin-top: 28px; }
.heat { display: block; aspect-ratio: 1; border-radius: 5px; background: #e5eadf; }
.level-1 { background: #a8d38e; }
.level-2 { background: #5fa66c; }
.level-3 { background: #276a47; }
.feature-band {
  max-width: 1160px; margin: 0 auto 42px; padding: 0 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.feature-band div { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 6px; }
.feature-band span { color: var(--muted); }

.auth-page { min-height: calc(100vh - 88px); display: grid; place-items: center; padding: 28px 18px; }
.auth-panel { width: min(460px, 100%); }
.auth-panel p { color: var(--muted); }
.code-row { display: grid; grid-template-columns: 1fr 128px; gap: 10px; align-items: end; }

.dashboard-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 20px;
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}
.sidebar {
  position: sticky; top: 88px; align-self: start;
  padding: 24px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(150deg, #1f5c42, #2f6f9f);
}
.sidebar h1 { margin: 0 0 24px; font-size: 30px; line-height: 1.15; }
.side-clock {
  color: var(--ink);
  display: grid;
  gap: 7px;
  padding: 16px;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.96);
}
.side-clock strong { font-size: 32px; }
.stat-grid, .admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid div, .admin-stats div {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 14px;
}
.stat-grid strong, .admin-stats strong { display: block; font-size: 26px; }
.stat-grid span, .admin-stats span { color: rgba(255,255,255,0.78); font-size: 13px; }
.admin-entry { display: block; margin-top: 18px; padding: 12px; border-radius: 8px; background: #fff; text-align: center; }
.content-stack { display: grid; gap: 18px; }
.panel { padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head span { color: var(--muted); font-size: 14px; }
.goal-form { display: grid; grid-template-columns: minmax(180px, 1fr) 130px 130px 118px 90px; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.check input { width: auto; }
.goal-list, .session-list { display: grid; gap: 10px; }
.goal-row, .session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}
.session-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.goal-row strong, .session-row strong { display: block; margin-bottom: 5px; }
.goal-row em, .session-row em {
  display: inline-block;
  margin-left: 8px;
  font-style: normal;
  color: var(--red);
  font-size: 12px;
}
.goal-row span, .session-row span, .empty, .timeline span { color: var(--muted); font-size: 14px; }
.muted { opacity: 0.58; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.timeline { margin: 0; padding-left: 22px; }
.timeline li { margin-bottom: 10px; }
.timeline strong { margin-right: 8px; color: var(--green-dark); }

.admin-shell { max-width: 1260px; margin: 0 auto; padding: 24px 18px 80px; display: grid; gap: 18px; }
.admin-hero { display: flex; justify-content: space-between; align-items: center; }
.admin-hero h1 { margin: 0; font-size: 42px; }
.admin-stats { grid-template-columns: repeat(4, 1fr); }
.admin-stats div { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.admin-stats span { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
th { color: var(--muted); font-weight: 800; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { display: flex; gap: 6px; }
.actions input { width: 130px; padding: 9px; }
.system-line { color: var(--muted); }
.mobile-nav { display: none; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-head h2 { margin: 10px 0 6px; }
.login-head p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-avatar {
  width: 54px;
  height: 54px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(140deg, var(--green), var(--blue));
}

@media (max-width: 880px) {
  .topbar { padding: 14px 16px; }
  .topbar nav { gap: 10px; }
  .hero { grid-template-columns: 1fr; padding-top: 30px; }
  .hero h1 { font-size: 44px; }
  .home-instruments { grid-template-columns: 1fr; }
  .feature-band, .dashboard-shell, .split { grid-template-columns: 1fr; }
  .dashboard-shell { padding-bottom: 92px; }
  .sidebar { position: static; }
  .goal-form, .goal-row, .session-row { grid-template-columns: 1fr; }
  .panel-head { display: grid; align-items: start; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .code-row { grid-template-columns: 1fr; }
  .mobile-nav {
    display: flex;
    position: fixed;
    left: 12px; right: 12px; bottom: 12px;
    justify-content: space-around;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.94);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
}

@media (max-width: 520px) {
  .hero h1 { font-size: 36px; }
  .clock-face strong { font-size: 34px; }
  .login-links { display: grid; gap: 10px; justify-items: center; }
  .feature-band { gap: 18px; }
  .admin-hero { display: grid; gap: 14px; align-items: start; }
  .admin-hero h1 { font-size: 34px; }
  .admin-stats { grid-template-columns: 1fr; }
  .calendar-grid { gap: 4px; }
}
