:root {
  color-scheme: light;
  --navy: #001d41;
  --navy-deep: #0f3260;
  --blue: #284776;
  --teal: #173d70;
  --teal-dark: #0f3260;
  --gold: #fdc348;
  --gold-soft: #ffdea5;
  --bg: #f9f9ff;
  --surface: #fff;
  --text: #172635;
  --muted: #555962;
  --line: #c4c6d0;
  --soft: #f0f3ff;
  --danger: #b42318;
  --ok: #067647;
  --amber: #a64b08;
  --radius: 12px;
  font-family:
    "Sarabun",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Noto Sans Thai",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}
button {
  -webkit-tap-highlight-color: transparent;
}
.hidden {
  display: none !important;
}

.top {
  color: #fff;
  background: var(--navy);
  border-bottom: 4px solid #d5aa55;
}

.top-inner {
  display: flex;
  max-width: 1280px;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: auto;
  padding: 14px 28px;
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: none;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}
.brand {
  overflow: hidden;
  font-size: clamp(18px, 2.2vw, 23px);
  font-weight: 750;
  text-overflow: ellipsis;
}
.sub {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}
.user-box {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
#userName {
  font-weight: 600;
}

.wrap {
  max-width: 1280px;
  margin: 28px auto;
  padding: 0 28px 48px;
}
.card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(24, 59, 91, 0.035);
}
.login {
  max-width: 500px;
  margin: 56px auto;
  padding: 32px;
}
.login h2 {
  margin: 0 0 6px;
  font-size: 24px;
}
.section-title {
  margin: 0 0 5px;
  font-size: 19px;
  line-height: 1.35;
}
h3.section-title {
  font-size: 17px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  margin: 16px 0;
}
.field label {
  color: #34495c;
  font-size: 13px;
  font-weight: 700;
}
.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c5d0da;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.field textarea {
  min-height: 82px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(22, 117, 109, 0.15);
}
.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.btn:hover {
  background: var(--teal-dark);
}
.btn:focus-visible,
.tab:focus-visible,
.chip:focus-visible,
.link:focus-visible {
  outline: 3px solid #e3b95f;
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.58;
  cursor: wait;
}
.btn.secondary {
  border-color: #cbd6df;
  background: #fff;
  color: var(--navy);
}
.btn.secondary:hover {
  background: #f0f4f7;
}
.btn.danger {
  background: var(--danger);
}
.btn.warn {
  background: var(--amber);
}
.btn.small {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 12px;
}
.full {
  width: 100%;
}
.error,
.success {
  min-height: 18px;
  margin-top: 10px;
  font-size: 13px;
}
.error {
  color: var(--danger);
}
.success {
  color: var(--ok);
}
.hint {
  margin: 12px 0;
  padding: 11px 13px;
  border: 1px solid #c7e6df;
  border-radius: 8px;
  background: #f0f8f6;
  color: #185b55;
  font-size: 13px;
}
.note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.person-select {
  max-width: 520px;
  margin-bottom: 16px;
}
.person-select .field { margin: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metric {
  min-height: 116px;
  padding: 18px 20px;
  border-top: 3px solid #8da7b8;
  box-shadow: none;
}
.metric:first-child {
  border-top-color: var(--teal);
}
.metric .label {
  color: var(--muted);
  font-size: 13px;
}
.metric .value {
  margin-top: 9px;
  font-size: clamp(22px, 2.4vw, 29px);
  font-weight: 750;
  letter-spacing: -0.3px;
  overflow-wrap: anywhere;
}
.metric .subv {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #e9eef2;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab {
  min-height: 44px;
  flex: 1 0 auto;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #405466;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  background: rgba(255, 255, 255, 0.7);
}
.tab.on {
  border-color: var(--line);
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(20, 40, 60, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.5fr);
  align-items: start;
  gap: 18px;
}
.layout2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}
.layout > *,
.layout2 > * {
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf1f4;
  color: #435466;
  font-size: 12px;
  font-weight: 700;
}
.pill.ok {
  background: #e3f4ea;
  color: #067647;
}
.pill.wd {
  background: #fff2d6;
  color: #8a4b08;
}
.pill.cancel {
  background: #fde9e7;
  color: #a4231a;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e8edf1;
  text-align: left;
}
tr:last-child td {
  border-bottom: 0;
}
th {
  background: var(--soft);
  color: #46596b;
  font-weight: 700;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr.cx td {
  opacity: 0.58;
  text-decoration: line-through;
}
tr.cx td:last-child,
tr.cx td .pill {
  text-decoration: none;
}
tr.click {
  cursor: pointer;
}
tr.click:hover td {
  background: #f5f9fb;
}
.empty {
  padding: 26px 10px;
  color: var(--muted);
  text-align: center;
}
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.link:hover {
  text-decoration: underline;
}

.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search-row .input {
  max-width: 360px;
}
.bulk-top {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.bulk-top .field {
  min-width: 170px;
  margin: 0;
}
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip {
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.chip:hover {
  border-color: var(--teal);
  background: #f3f9f8;
}
.bgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}
.brow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e8edf1;
}
.brow .nm {
  min-width: 0;
  flex: 1;
}
.brow .nm b {
  display: block;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brow input {
  width: 104px;
  min-height: 42px;
  padding: 7px 9px;
  text-align: right;
}
.bfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.bfoot b {
  color: var(--teal-dark);
  font-size: 21px;
}

.bars .b {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 9px 0;
  font-size: 13px;
}
.bars .b .m {
  width: 58px;
  flex: none;
  color: var(--muted);
}
.bars .b .t {
  flex: 1;
}
.bars .bi,
.bars .bw {
  min-width: 2px;
  height: 11px;
  border-radius: 6px;
}
.bars .bi {
  background: var(--teal);
}
.bars .bw {
  margin-top: 3px;
  background: #e7aa7c;
}
.bars .b .v {
  width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.legend {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 4px 0 10px;
  border-radius: 3px;
  vertical-align: -1px;
}
.legend i:first-child {
  margin-left: 0;
}
svg.chart {
  display: block;
  width: 100%;
  height: auto;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.stat small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.stat b {
  font-size: 15px;
  overflow-wrap: anywhere;
}
.print-only {
  display: none;
}

.ov {
  position: fixed;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 30, 48, 0.52);
  inset: 0;
}
.modal {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}
.modal h2 {
  margin: 0 0 8px;
  font-size: 19px;
}
.modal p {
  margin: 0;
  white-space: pre-line;
}
.modal .acts {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal .acts .btn {
  flex: 1;
}
.toast {
  position: fixed;
  z-index: 90;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--navy-deep);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast.bad {
  background: var(--danger);
}
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sp 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes sp {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .top-inner {
    min-height: 78px;
    padding-inline: 20px;
  }
  .wrap {
    padding-inline: 20px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .layout,
  .layout2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .bgrid {
    grid-template-columns: minmax(0, 1fr);
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  body {
    font-size: 14px;
  }
  .top-inner {
    min-height: 72px;
    gap: 10px;
    padding: 11px 14px;
  }
  .brand-lockup {
    gap: 10px;
  }
  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 19px;
  }
  .brand {
    font-size: 17px;
  }
  .sub {
    font-size: 11px;
  }
  .user-box {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
  }
  .user-box .btn {
    min-height: 36px;
    padding: 5px 9px;
  }
  .wrap {
    margin: 18px auto;
    padding: 0 12px 28px;
  }
  .login {
    margin: 24px auto;
    padding: 23px 19px;
  }
  .login h2 {
    font-size: 21px;
  }
  .card {
    padding: 17px;
    border-radius: 10px;
  }
  .section-head {
    align-items: flex-start;
    gap: 10px;
  }
  .section-title {
    font-size: 18px;
  }
  .section-head > .toolbar {
    justify-content: flex-end;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 14px;
  }
  .metric {
    min-height: 96px;
    padding: 13px;
  }
  .metric .label {
    font-size: 12px;
  }
  .metric .value {
    margin-top: 6px;
    font-size: clamp(18px, 5vw, 23px);
  }
  .tabs {
    gap: 3px;
    margin: 0 -12px 14px;
    padding: 5px 12px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
  .tab {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 13px;
  }
  .two {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .field {
    margin: 13px 0;
  }
  .btn {
    min-height: 46px;
  }
  .btn.small {
    min-height: 38px;
  }
  .table-wrap {
    margin-inline: -2px;
  }
  table {
    font-size: 12px;
  }
  th,
  td {
    padding: 9px 9px;
  }
  td > .muted,
  .hide-sm {
    display: none;
  }
  .bulk-top {
    align-items: stretch;
    gap: 10px;
  }
  .bulk-top .field {
    min-width: calc(50% - 5px);
    flex: 1;
  }
  .bulk-top > .btn {
    align-self: end;
  }
  .brow input {
    width: 94px;
  }
  .bfoot {
    align-items: stretch;
  }
  .bfoot > .btn {
    flex: 1;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 10px;
  }
  .bars .b {
    gap: 7px;
  }
  .bars .b .m {
    width: 48px;
  }
  .bars .b .v {
    width: 70px;
    font-size: 12px;
  }
  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
    text-align: center;
  }
}

@media (max-width: 370px) {
  .brand {
    max-width: 190px;
    font-size: 15px;
  }
  .user-box .btn {
    font-size: 11px;
  }
  .metric {
    padding: 11px;
  }
  .metric .value {
    font-size: 18px;
  }
  .section-head {
    flex-direction: column;
  }
  .bulk-top .field {
    min-width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }
  .top,
  .tabs,
  #appHead,
  #metrics,
  .noprint,
  #v-entry,
  #v-bulk,
  #v-students,
  #v-summary,
  .toast {
    display: none !important;
  }
  .wrap {
    max-width: none;
    margin: 0;
    padding: 0;
  }
  .card {
    break-inside: avoid;
    box-shadow: none;
  }
  .print-only {
    display: block;
    margin-bottom: 12px;
  }
  .layout2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Application shell */
.top {
  position: sticky;
  z-index: 30;
  top: 0;
}

.top-inner {
  max-width: 1600px;
}

.wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.app-shell:not(.hidden) {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  align-items: start;
  gap: 30px;
}

.app-sidebar {
  position: sticky;
  top: 112px;
  min-width: 0;
}

.nav-caption {
  margin: 0 0 10px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: visible;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.tab {
  display: flex;
  min-height: 48px;
  flex: none;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px;
  color: #485b6d;
  text-align: left;
  white-space: normal;
}

.tab:hover {
  background: #f5f8fa;
}

.tab.on {
  border-color: transparent;
  background: #eaf3f2;
  color: var(--teal-dark);
  box-shadow: none;
}

.tab-icon {
  width: 21px;
  height: 21px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.tab-label-short {
  display: none;
}

.sidebar-note {
  margin: 14px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.app-content {
  min-width: 0;
}

#appHead {
  align-items: center;
  margin-bottom: 20px;
}

#appHead .section-title {
  font-size: 25px;
}

#v-entry.layout {
  grid-template-columns: minmax(300px, .82fr) minmax(0, 1.5fr);
}

@media (max-width: 1050px) and (min-width: 701px) {
  .wrap {
    padding-right: 22px;
    padding-left: 22px;
  }
  .app-shell:not(.hidden) {
    grid-template-columns: 196px minmax(0, 1fr);
    gap: 20px;
  }
}

@media (max-width: 900px) and (min-width: 701px) {
  .app-shell:not(.hidden) {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 16px;
  }
  .tab {
    gap: 9px;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 13px;
  }
  #v-entry.layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .top-inner {
    min-height: 64px;
    padding: 8px 14px;
  }
  .brand-lockup {
    gap: 9px;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }
  .brand {
    max-width: 56vw;
    font-size: 15px;
  }
  .sub {
    overflow: hidden;
    max-width: 58vw;
    margin-top: 0;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-box {
    gap: 0;
  }
  #userName {
    display: none;
  }
  .user-box .btn {
    min-height: 36px;
    padding: 5px 9px;
    font-size: 11px;
  }
  .wrap {
    margin: 0 auto;
    padding: 18px 14px calc(94px + env(safe-area-inset-bottom));
  }
  .app-shell:not(.hidden) {
    display: block;
  }
  .app-sidebar {
    display: contents;
  }
  .nav-caption,
  .sidebar-note {
    display: none;
  }
  .tabs {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    overflow: visible;
    margin: 0;
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255,255,255,.97);
    box-shadow: 0 -5px 20px rgba(24,59,91,.08);
    backdrop-filter: blur(12px);
  }
  .tab {
    min-width: 0;
    min-height: 54px;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 4px 1px;
    border-radius: 8px;
    color: #647586;
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
  }
  .tab:hover {
    background: #f5f8fa;
  }
  .tab.on {
    background: #edf5f4;
  }
  .tab-icon {
    width: 20px;
    height: 20px;
  }
  .tab-label-full {
    display: none;
  }
  .tab-label-short {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  #appHead {
    align-items: center;
    margin-bottom: 14px;
  }
  #appHead .section-title {
    font-size: 21px;
  }
  #appHead .muted {
    font-size: 12px;
  }
  #refreshBtn {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 12px;
  }
  .grid {
    gap: 9px;
    margin-bottom: 15px;
  }
  .metric {
    min-height: 88px;
    padding: 12px;
    border-top-width: 2px;
    border-radius: 10px;
  }
  .metric .label {
    font-size: 11px;
  }
  .metric .value {
    margin-top: 5px;
    font-size: clamp(18px, 5vw, 23px);
  }
  #v-entry.layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .app-content > .card,
  #v-entry > .card {
    padding: 16px;
    border-radius: 10px;
  }
  .section-head {
    margin-bottom: 14px;
  }
  .section-title {
    font-size: 17px;
  }
  .field {
    margin: 12px 0;
  }
  .two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .note {
    font-size: 11px;
  }
  .tabs .tab:focus-visible {
    outline-offset: -2px;
  }
  .toast {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

@media print {
  .app-sidebar {
    display: none !important;
  }
  .app-shell:not(.hidden) {
    display: block;
  }
  .wrap {
    max-width: none;
    padding: 0;
  }
}

body.login-mode {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 12% 18%, rgba(253,195,72,.12), transparent 34rem),
    var(--bg);
}

body.login-mode .top {
  display: none;
}

body.login-mode .wrap {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  max-width: 1600px;
  align-items: center;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) clamp(20px, 5vw, 76px) max(28px, env(safe-area-inset-bottom));
}

.login-layout {
  display: grid;
  width: 100%;
  max-width: 560px;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 32px;
  margin: auto;
}

.login-hero {
  display: grid;
  min-width: 0;
  gap: 20px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.login-logo {
  display: block;
  width: 90px;
  height: 90px;
  flex: none;
  padding: 7px;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 4px 14px rgba(0,29,65,.1);
}

.login-kicker {
  margin: 0 0 3px;
  color: var(--navy-deep);
  font-size: 15px;
  font-weight: 700;
}

.login-hero h1 {
  margin: 0;
  color: var(--navy);
  font-family: "Noto Serif Thai", "Sarabun", serif;
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 700;
  line-height: 1.35;
}

.login-lede {
  max-width: 440px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 14px;
}

.login-layout .login {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border-color: rgba(0,29,65,.1);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,29,65,.1), 0 0 0 1px rgba(196,198,208,.25);
}

.login .card-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  color: var(--navy);
}

.login-head-icon {
  width: 30px;
  height: 30px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.login .card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.login .card-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.login .card-body {
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.login .field {
  gap: 6px;
  margin: 0;
}

.login .field label {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.input-wrap {
  position: relative;
}

.input-wrap > svg:first-child {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  fill: none;
  stroke: #667487;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  pointer-events: none;
}

.login .input-wrap input {
  width: 100%;
  min-height: 48px;
  padding: 10px 48px 10px 43px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.login .input-wrap input:focus {
  border-color: var(--navy-deep);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,29,65,.12);
}

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667487;
  cursor: pointer;
}

.pw-toggle:hover,
.pw-toggle[aria-pressed="true"] {
  background: var(--soft);
  color: var(--navy);
}

.pw-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.pw-toggle .eye-closed,
.pw-toggle[aria-pressed="true"] .eye-open {
  display: none;
}

.pw-toggle[aria-pressed="true"] .eye-closed {
  display: block;
}

.login .error {
  margin: -5px 0 -7px;
  font-size: 13px;
}

.login .error:empty {
  display: none;
}

.login .btn {
  min-height: 50px;
  border-radius: 9px;
  background: var(--navy);
  box-shadow: 0 4px 12px rgba(0,29,65,.16);
  font-size: 15px;
}

.login .btn:hover {
  background: var(--navy-deep);
}

.login-assist {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy-deep);
  font-size: 12px;
  font-weight: 600;
}

.login-assist svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: var(--navy-deep);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.login .note {
  margin: -7px 0 0;
  padding-top: 12px;
  border-top: 1px solid #e8e9ef;
  font-size: 11px;
}

@media (min-width: 1024px) {
  body.login-mode .wrap {
    padding-right: clamp(48px, 7vw, 112px);
    padding-left: clamp(48px, 7vw, 112px);
  }
  .login-layout {
    max-width: 1220px;
    grid-template-columns: minmax(0, 1.05fr) minmax(390px, .9fr);
    gap: clamp(48px, 7vw, 108px);
  }
  .login-hero {
    gap: 24px;
  }
  .login-brand {
    align-items: flex-start;
    text-align: left;
  }
  .login-logo {
    width: 104px;
    height: 104px;
  }
  .login-hero h1 {
    font-size: clamp(34px, 3.2vw, 44px);
  }
  .login-lede {
    margin-right: 0;
    margin-left: 0;
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  body.login-mode .wrap {
    align-items: start;
    padding: max(22px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  }
  .login-layout {
    max-width: 460px;
    gap: 20px;
  }
  .login-hero {
    gap: 13px;
  }
  .login-brand {
    gap: 8px;
  }
  .login-logo {
    width: 72px;
    height: 72px;
    padding: 5px;
  }
  .login-kicker {
    font-size: 13px;
  }
  .login-hero h1 {
    font-size: 25px;
    line-height: 1.3;
  }
  .login-lede {
    margin-top: 5px;
    font-size: 12px;
  }
  .login-layout .login {
    border-radius: 12px;
  }
  .login .card-head {
    padding: 14px 16px;
  }
  .login .card-body {
    gap: 14px;
    padding: 17px 16px;
  }
  .login-form {
    gap: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login .input-wrap input {
    transition: none;
  }
}
