:root {
  --p: #0d9488;      /* primary teal */
  --p-hover: #0f766e;
  --pc: #ffffff;     /* primary content */
  --s: #4f46e5;      /* secondary indigo */
  --sc: #ffffff;
  --a: #d97706;      /* accent amber */
  --ac: #ffffff;
  --su: #16a34a;     /* success */
  --wa: #d97706;     /* warning */
  --er: #dc2626;     /* error */
  --b1: #ffffff;     /* base-100 */
  --b2: #f6f7f8;     /* base-200 */
  --b3: #e7e9ec;     /* base-300 */
  --bc: #1f2937;     /* base-content */
  --bc-60: rgba(31, 41, 55, 0.6);
  --bc-50: rgba(31, 41, 55, 0.5);
  --bc-30: rgba(31, 41, 55, 0.3);
  --radius-box: 1rem;
  --radius-btn: 0.75rem;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
}

html[data-theme="dark"] {
  --p: #2dd4bf;
  --p-hover: #5eead4;
  --pc: #052e2b;
  --s: #818cf8;
  --sc: #1e1b4b;
  --a: #fbbf24;
  --ac: #451a03;
  --su: #4ade80;
  --wa: #fbbf24;
  --er: #f87171;
  --b1: #161b22;
  --b2: #0d1117;
  --b3: #2a313c;
  --bc: #e6e9ef;
  --bc-60: rgba(230, 233, 239, 0.65);
  --bc-50: rgba(230, 233, 239, 0.5);
  --bc-30: rgba(230, 233, 239, 0.3);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--b2);
  color: var(--bc);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
svg { display: block; }
button { font-family: inherit; }
input { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--b2);
  gap: 1rem;
}
.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--b1);
  border: 1px solid var(--b3);
  border-radius: var(--radius-box);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  padding: 2rem 1.75rem;
}
.login-logo {
  width: 3rem; height: 3rem;
  border-radius: var(--radius-btn);
  background: var(--p); color: var(--pc);
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.95rem;
  margin: 0 auto 1rem;
}
.login-card h2 { margin: 0; text-align: center; font-size: 1.15rem; font-weight: 800; }
.login-card > p.sub { margin: 0.35rem 0 1.5rem; text-align: center; font-size: 0.8rem; color: var(--bc-60); }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.4rem; }
.input-wrap { position: relative; }
.text-input {
  width: 100%; padding: 0.65rem 0.85rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--b3);
  background: var(--b1); color: var(--bc);
  font-size: 0.9rem; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.text-input:focus { border-color: var(--p); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15); }
.input-wrap .text-input { padding-right: 2.5rem; }
.toggle-eye {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--bc-50); cursor: pointer;
  width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 0.5rem;
}
.toggle-eye:hover { background: var(--b3); }
.field-row { display: flex; align-items: center; justify-content: space-between; margin: -0.25rem 0 1.25rem; font-size: 0.78rem; }
.remember { display: flex; align-items: center; gap: 0.4rem; color: var(--bc-60); }
.remember input { accent-color: var(--p); }
.forgot-link { color: var(--p); font-weight: 700; background: none; border: none; cursor: pointer; font-size: 0.78rem; padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  border: none; border-radius: var(--radius-btn); padding: 0.7rem 1rem;
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--p); color: var(--pc); }
.btn-primary:hover { background: var(--p-hover); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8rem; }

.login-error {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(220, 38, 38, 0.1); color: var(--er);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-btn); padding: 0.6rem 0.75rem;
  font-size: 0.78rem; font-weight: 600; margin-bottom: 1rem;
}
.login-hint { margin: 1.25rem 0 0; text-align: center; font-size: 0.72rem; color: var(--bc-50); }
.login-shake { animation: shake 0.35s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.install-banner {
  width: 100%; max-width: 22rem;
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--b1); border: 1px solid var(--b3);
  border-radius: var(--radius-box); padding: 0.85rem 1rem;
  box-shadow: var(--shadow-card);
}
.install-banner-icon {
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-btn);
  background: rgba(13,148,136,0.12); color: var(--p);
  display: grid; place-items: center; flex-shrink: 0;
}
.install-banner-text { flex: 1; min-width: 0; }
.install-banner-text .title { margin: 0; font-size: 0.85rem; font-weight: 700; }
.install-banner-text .sub { margin: 0.1rem 0 0; font-size: 0.72rem; color: var(--bc-50); }

/* ---------- App shell ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--b1) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--b3);
}
.header-inner {
  max-width: 80rem; margin: 0 auto; padding: 0.75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.logo {
  flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-btn);
  background: var(--p); color: var(--pc);
  display: grid; place-items: center; font-weight: 800; font-size: 0.85rem;
}
.brand-text h1 { margin: 0; font-size: 1rem; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { margin: 0; font-size: 0.75rem; color: var(--bc-60); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.icon-btn {
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius-btn); border: none;
  background: transparent; display: grid; place-items: center; cursor: pointer;
  color: var(--bc); transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--b3); }
.icon-swap { position: relative; width: 20px; height: 20px; }
.icon-swap svg { position: absolute; inset: 0; transition: opacity 0.15s ease, transform 0.15s ease; }
.avatar {
  width: 2rem; height: 2rem; border-radius: 999px; background: var(--s); color: var(--sc);
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; flex-shrink: 0; border: none; cursor: pointer;
}
.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); min-width: 11rem;
  background: var(--b1); border: 1px solid var(--b3); border-radius: var(--radius-btn);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14); padding: 0.4rem; z-index: 40;
}
.user-menu-name { padding: 0.5rem 0.6rem 0.3rem; font-size: 0.75rem; font-weight: 700; color: var(--bc-60); border-bottom: 1px solid var(--b3); margin-bottom: 0.3rem; }
.user-menu a, .user-menu button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 0.55rem 0.6rem; border-radius: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--er); cursor: pointer;
}
.user-menu a:hover, .user-menu button:hover { background: var(--b3); }

main { flex: 1; max-width: 80rem; width: 100%; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
.section-title { margin: 0 0 1rem; font-size: 1.125rem; font-weight: 800; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.card { background: var(--b1); border: 1px solid var(--b3); border-radius: var(--radius-box); box-shadow: var(--shadow-card); }
.stat-card { padding: 1rem; }
.stat-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--bc-60); }
.stat-value { display: block; font-size: 1.5rem; font-weight: 800; margin: 0.15rem 0; }
.stat-hint { display: block; font-size: 0.75rem; font-weight: 600; color: var(--bc-50); }
.stat-hint.up { color: var(--su); }

.menu-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.menu-card { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.menu-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, 0.1); }
.menu-icon { flex-shrink: 0; width: 3rem; height: 3rem; border-radius: var(--radius-btn); display: grid; place-items: center; }
.menu-body { min-width: 0; flex: 1; }
.menu-title-row { display: flex; align-items: center; gap: 0.5rem; }
.menu-title-row h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.menu-desc { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--bc-60); }
.menu-arrow { flex-shrink: 0; color: var(--bc-30); margin-top: 0.3rem; }

.badge { display: inline-flex; align-items: center; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; border: 1px solid var(--b3); color: var(--bc-60); white-space: nowrap; }
.badge-primary { background: var(--p); color: var(--pc); border-color: var(--p); }

.bottom-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.panel { padding: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.link-primary { color: var(--p); font-size: 0.75rem; font-weight: 700; }

.activity-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.5rem 0; }
.activity-dot { margin-top: 0.4rem; width: 0.45rem; height: 0.45rem; border-radius: 999px; background: var(--p); flex-shrink: 0; }
.activity-text { margin: 0; font-size: 0.875rem; }
.activity-time { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--bc-50); }

.exam-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.85rem; border: 1px solid var(--b3); border-radius: var(--radius-btn); margin-bottom: 0.6rem; }
.exam-item:last-child { margin-bottom: 0; }
.exam-title { margin: 0; font-size: 0.875rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-meta { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--bc-50); }
.badge-outline { background: transparent; flex-shrink: 0; }

footer { border-top: 1px solid var(--b3); background: var(--b1); padding: 1rem; text-align: center; font-size: 0.75rem; color: var(--bc-50); }

@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 768px) { .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) {
  .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner, main { padding-left: 2rem; padding-right: 2rem; }
}
