.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(16, 42, 55, 0.92), rgba(21, 94, 117, 0.76)),
    linear-gradient(180deg, #f8fafb, #e7eef2);
}

.login-panel {
  position: relative;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f9fbfc);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
  padding: 28px;
  overflow: hidden;
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, var(--gold), var(--primary), var(--blue));
}

.login-panel h1 {
  margin: 6px 0 8px;
  font-size: 1.75rem;
  line-height: 1.25;
}

.login-brand {
  margin-bottom: 22px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 14px;
  background: #ffffff;
  color: #0f172a;
  border-right: 1px solid #e2e8f0;
  box-shadow: 4px 0 20px rgba(15, 23, 42, 0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.login-brand {
  color: var(--text);
  border-bottom-color: var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #2563eb, #d97706);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.22);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.brand strong {
  display: block;
  font-size: 1.1rem;
  color: #0f172a;
  font-weight: 800;
}

.brand span {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 500;
}

.login-brand span {
  color: var(--muted);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: 0 3px 8px rgba(2, 132, 199, 0.2);
}

.user-card strong {
  display: block;
  font-size: 0.88rem;
  color: #0f172a;
  font-weight: 700;
}

.user-card span:last-child {
  color: #0284c7;
  font-size: 0.74rem;
  font-weight: 600;
}

.sidebar-user-logout {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-user-logout:hover {
  background: #ffe4e6;
  border-color: #fda4af;
  transform: scale(1.05);
}

.nav-tabs {
  display: grid;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-tabs::-webkit-scrollbar {
  width: 4px;
}

.nav-tabs::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 999px;
}

.nav-tab,
.ghost-button,
.primary-button,
.icon-button {
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.nav-tab {
  justify-content: flex-start;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  color: #475569;
  font-weight: 600;
  font-size: 0.88rem;
}

.nav-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.nav-tab.active {
  background: #f0f9ff;
  color: #0284c7;
  font-weight: 700;
  box-shadow: inset 3px 0 0 #0284c7;
}

.nav-tab:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.sidebar-footer {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.ghost-button {
  width: 100%;
  padding: 8px 12px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  font-size: 0.82rem;
  font-weight: 600;
}

.ghost-button:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.ghost-button.danger,
#logoutButton {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.ghost-button.danger:hover,
#logoutButton:hover {
  background: #ffe4e6;
  color: #9f1239;
  border-color: #fda4af;
}

.main {
  min-width: 0;
  padding: 16px 22px;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(16px);
}

.topbar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-branding {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.topbar-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 3px 6px 3px 8px;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.76rem;
  display: grid;
  place-items: center;
}

.user-info-mini {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info-mini strong {
  font-size: 0.78rem;
  color: #0f172a;
}

.user-info-mini span {
  font-size: 0.68rem;
  color: #0284c7;
  font-weight: 600;
}

.topbar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topbar-logout-btn:hover {
  background: #ffe4e6;
  border-color: #fda4af;
  transform: translateY(-1px);
}

.topbar h1 {
  margin: 0 0 1px;
  font-size: 1.25rem;
  line-height: 1.25;
  color: #0f172a;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 0.76rem;
  line-height: 1.3;
}

.status-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #64748b;
  padding: 1px 9px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill.status-ready {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.status-pill.status-time {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
  font-family: "JetBrains Mono", "Noto Sans Thai", monospace;
}

.status-pill[data-mode="saving"] {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.status-pill[data-mode="saved"] {
  color: #15803d;
  background: #dcfce7;
  border-color: #86efac;
}

.status-pill[data-mode="local"] {
  color: #be123c;
  background: #ffe4e6;
  border-color: #fecdd3;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.saved-pulse {
  animation: savedPulseAnim 0.8s ease;
}

@keyframes savedPulseAnim {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); background: #bbf7d0; border-color: #4ade80; }
  100% { transform: scale(1); }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 8px;
  border-radius: 999px;
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 4px 0;
  width: fit-content;
}

/* --- The Frame: High-Precision Single-Row Executive Toolbar --- */
.topbar-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.topbar-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-action-group.assess-group {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-action-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
  margin: 0 2px;
  flex-shrink: 0;
}

.action-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.action-field.assessment-field {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.action-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  flex-shrink: 0;
  margin: 0;
}

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

.select-elongated {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 32px;
  font-weight: 600;
  font-size: 0.78rem;
  color: #0f172a;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-elongated:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2.5px rgba(2, 132, 199, 0.14);
  outline: none;
}

.select-compact {
  height: 32px;
  font-weight: 600;
  font-size: 0.76rem;
  color: #0f172a;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 6px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.select-compact:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2.5px rgba(2, 132, 199, 0.14);
  outline: none;
}

.select-grade {
  min-width: 54px;
  text-align: center;
  color: #0284c7;
  background: #f0f9ff;
  border-color: #bae6fd;
}

.select-room {
  min-width: 64px;
  text-align: center;
}

.select-year {
  min-width: 64px;
  text-align: center;
}

.select-term {
  min-width: 44px;
  text-align: center;
}

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

.select-label {
  display: block;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

select,
input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 94, 117, 0.14);
}
