:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #65758b;
  --line: #d8e1ee;
  --line-soft: #edf2f8;
  --nav: #152033;
  --nav-soft: #1e2a42;
  --brand: #1f6feb;
  --brand-dark: #1557c0;
  --green: #057a55;
  --red: #c83232;
  --amber: #ad6b00;
  --shadow: 0 12px 34px rgba(18, 31, 54, .08);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

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

button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(31, 111, 235, .28);
  outline-offset: 1px;
}

.hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.82), rgba(243,246,251,.95)),
    radial-gradient(circle at 20% 20%, rgba(31,111,235,.10), transparent 34%),
    var(--bg);
}

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

.brand {
  color: var(--brand);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand.small {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
  color: #fff;
  font-size: 18px;
}

.brand.small strong {
  display: block;
  line-height: 1.2;
}

.brand.small em {
  display: block;
  margin-top: 3px;
  color: #aab7cc;
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.login-panel h1 {
  margin: 18px 0 8px;
  font-size: 28px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  overflow-y: auto;
}

nav {
  display: grid;
  gap: 4px;
  padding: 0 12px 18px;
}

.nav-btn {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: flex-start;
  padding: 0 14px;
  background: transparent;
  color: #c7d1e1;
  text-align: left;
  font-weight: 600;
}

.nav-btn:hover {
  background: var(--nav-soft);
  color: #fff;
}

.nav-btn.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #344055;
}

.ghost:hover {
  border-color: #b9c7da;
  background: #f8fafc;
}

#logoutBtn {
  width: calc(100% - 24px);
  margin: 0 12px 20px;
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: #d6dfed;
}

#logoutBtn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.user-box {
  min-width: 148px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344055;
  text-align: right;
  line-height: 1.5;
}

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

#content {
  padding: 24px 28px 48px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.stat {
  min-height: 132px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.stat span {
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 18px;
  color: var(--brand);
  font-size: 36px;
  line-height: 1;
}

.panel {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: #fbfcfe;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
}

.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.primary {
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  background: var(--brand-dark);
}

.danger {
  padding: 0 12px;
  border: 1px solid #ffd0d0;
  background: #fff4f4;
  color: var(--red);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #516174;
  background: #f7f9fd;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #1f2937;
}

tbody tr:hover {
  background: #f9fbff;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cell-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 99px;
  background: #edf5ff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

dialog {
  width: min(780px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, .42);
}

#modalForm {
  padding: 0;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.modal-head h2 {
  margin: 0;
  font-size: 19px;
}

.icon {
  width: 34px;
  min-height: 34px;
  background: transparent;
  color: #64748b;
  font-size: 24px;
}

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

#modalFields {
  max-height: min(68vh, 680px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px 22px;
  overflow-y: auto;
}

label {
  display: grid;
  gap: 7px;
  color: #344055;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #c8d4e4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 500;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aebed2;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.55;
}

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

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 22px;
  border-top: 1px solid var(--line-soft);
}

.error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fff4f4;
  color: #a62323;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  #modalFields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  #content {
    padding: 18px;
  }

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

/* UI refactor layer based on the dashboard reference */
.login-view {
  grid-template-columns: minmax(320px, 520px) minmax(360px, 430px);
  gap: 52px;
}

.login-copy {
  color: #0b1b35;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.login-logo strong {
  display: block;
  font-size: 26px;
}

.login-logo em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-style: normal;
}

.login-copy h1 {
  max-width: 520px;
  margin: 0 0 18px;
  font-size: 44px;
  line-height: 1.15;
}

.login-copy p {
  max-width: 500px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.login-feature-grid {
  display: grid;
  max-width: 460px;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 32px;
}

.login-feature-grid span {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.76);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .05);
  font-weight: 800;
}

.sidebar {
  background: linear-gradient(180deg, #102141 0%, #07162c 100%);
}

nav {
  gap: 0;
  padding: 0 14px 18px;
}

.nav-group {
  display: grid;
  gap: 4px;
  padding: 10px 0 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.nav-group:first-child {
  border-top: 0;
}

.nav-group-title {
  padding: 4px 12px 8px;
  color: #7e91ae;
  font-size: 12px;
  font-weight: 700;
}

.nav-btn {
  gap: 10px;
}

.nav-btn.active {
  background: linear-gradient(135deg, #2f7bff 0%, #1d5fef 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(31, 111, 235, .28);
}

.nav-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  font-size: 14px;
}

.dashboard-cards {
  margin-bottom: 20px;
}

.stat {
  position: relative;
  overflow: hidden;
}

.stat i {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #2f7bff, #1d5fef);
  color: #fff;
  font-style: normal;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(31, 111, 235, .22);
}

.stat span {
  display: block;
  margin-top: 14px;
}

.stat small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.stat.purple i { background: linear-gradient(135deg, #8b5cf6, #5b4ff3); }
.stat.orange i { background: linear-gradient(135deg, #ff9b32, #f97316); }
.stat.red i { background: linear-gradient(135deg, #ff6b6b, #ef4444); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr 1.2fr;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-head.compact {
  min-height: 58px;
  padding: 14px 18px;
}

.panel-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.list-panel {
  padding: 8px 18px 16px;
}

.todo-row,
.feedback-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.todo-row {
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
}

.feedback-row {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.todo-row:last-child,
.feedback-row:last-child {
  border-bottom: 0;
}

.todo-row strong,
.feedback-row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.todo-row em,
.feedback-row em {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.todo-row time,
.feedback-row time {
  color: var(--muted);
  font-size: 12px;
}

.avatar-dot,
.face-dot {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #edf5ff;
  color: var(--brand);
  font-weight: 900;
}

.face-dot {
  background: #e9fbf3;
  color: var(--green);
}

.status {
  min-width: 62px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--brand);
  font-size: 12px;
  text-align: center;
}

.status.warn { background: #fff7ed; color: #c76a00; }
.status.done { background: #ecfdf3; color: var(--green); }
.status.doing { background: #f1f5ff; color: var(--brand); }

.ai-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 18px;
}

.ai-metrics div {
  padding: 0 14px;
  border-right: 1px solid var(--line-soft);
}

.ai-metrics div:last-child {
  border-right: 0;
}

.ai-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.ai-metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.chart-empty,
.empty-block {
  margin: 0 18px 18px;
  padding: 34px 16px;
  border: 1px dashed #cfdae8;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-block {
  margin: 8px 0 0;
  padding: 26px 12px;
}

.study-grid {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 22px;
  padding: 20px;
}

.ring-card {
  display: grid;
  width: 168px;
  height: 168px;
  place-items: center;
  justify-self: center;
  align-self: center;
  border-radius: 50%;
  background: conic-gradient(#2563eb 0 35%, #10b981 35% 68%, #f59e0b 68% 86%, #8b5cf6 86% 100%);
  color: #fff;
  box-shadow: 0 12px 30px rgba(31, 111, 235, .16);
}

.ring-card strong {
  display: block;
  margin-top: 28px;
  font-size: 28px;
}

.ring-card span {
  display: block;
  margin-top: -28px;
  font-size: 13px;
}

.mini-bars {
  display: grid;
  align-content: center;
  gap: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.bar-row em {
  height: 10px;
  border-radius: 999px;
  background: #eef3f9;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7bff, #1d5fef);
}

.warning-list {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a5a00;
}

@media (max-width: 980px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-copy {
    display: none;
  }

  .dashboard-grid,
  .study-grid {
    grid-template-columns: 1fr;
  }
}
