:root {
  color-scheme: light;
  --ink: #382719;
  --muted: #806b58;
  --line: #f0dcc7;
  --blue: #cf641d;
  --orange: #e87924;
  --surface: #fff;
  --page: #fff8f1;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body.home-page {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 92% 4%, #ffe5cb 0, transparent 34rem), var(--page);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 18px;
  line-height: 1.6;
}
body.document-form-page, body.register-page {
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 18px;
  line-height: 1.65;
}
body.document-form-page header { background: linear-gradient(105deg, #a9440c, #db6518 58%, #f49a45); }
body.document-form-page main > a { color: #c95c16; font-size: 17px; }
body.document-form-page main > div > p:first-child { color: #c95c16; font-size: 17px; }
body.document-form-page main h1 { color: #4b2d18; font-size: clamp(2rem, 4vw, 2.7rem); }
body.document-form-page main > div > p:last-child { font-size: 18px; }
body.document-form-page label { font-size: 17px !important; }
body.document-form-page input:not([type=hidden]), body.document-form-page select, body.document-form-page textarea { min-height: 54px; font: inherit; font-size: 18px; }
body.document-form-page input:focus, body.document-form-page select:focus, body.document-form-page textarea:focus { border-color: #e87924; --tw-ring-color: #ffedd5; }
body.document-form-page button[type=submit] { background: #e87924; font-size: 18px; }
body.document-form-page button[type=submit]:hover { background: #c95c16; }
body.document-form-page main > div { border-color: #f0dcc7; }
body.archive-page { color: var(--ink); background: var(--page); font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; font-size: 18px; line-height: 1.6; }
body.archive-page .archive-header { background: linear-gradient(105deg, #a9440c, #db6518 58%, #f49a45); }
body.archive-page .archive-active { background: #e87924 !important; color: white !important; }
body.archive-page .archive-accent { color: #c95c16 !important; }
body.archive-page .archive-primary { background: #e87924 !important; }
body.archive-page .archive-primary:hover { background: #c95c16 !important; }
body.archive-page .archive-stat { border-color: #f0dcc7 !important; }
body.archive-page .dataTables_wrapper { font-size: 16px; }
body.archive-page .dataTables_wrapper .dataTables_filter input, body.archive-page .dataTables_wrapper .dataTables_length select { min-height: 42px; font: inherit; font-size: 16px; }
body.archive-page .dataTables_wrapper .dataTables_paginate .paginate_button.current { background: #e87924 !important; color: white !important; border-color: #e87924 !important; }
body.archive-page .dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: #ffedd5 !important; color: #a9440c !important; border-color: #ffedd5 !important; }
body.archive-page table.dataTable thead th { font-size: 16px; }
body.archive-page table.dataTable tbody td { font-size: 16px; }
a { color: inherit; text-decoration: none; }
.home-header { color: #fff; background: linear-gradient(105deg, #a9440c 0%, #db6518 58%, #f49a45 100%); box-shadow: 0 8px 24px rgba(155, 71, 16, .2); }
.home-header-inner { width: min(1160px, calc(100% - 40px)); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.home-brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 700; font-size: 20px; letter-spacing: .01em; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: #fff; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25); }
.home-actions { display: flex; align-items: center; gap: 8px; }
.history-link { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; color: #fff8f1; font-size: 16px; transition: background .18s ease; }
.history-link:hover { background: rgba(255,255,255,.15); }
.login-link { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border: 1px solid rgba(255,255,255,.65); border-radius: 10px; color: #fff; font-size: 15px; font-weight: 700; transition: background .18s ease; }
.login-link:hover { color: #17324d; background: #fff; }
.user-greeting { max-width: 180px; overflow: hidden; color: #fff0df; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.home-main { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 28px; }
.home-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.school-name { margin: 0 0 5px; color: var(--blue); font-size: 17px; font-weight: 700; }
.home-intro h1 { margin: 0; color: #4b2d18; font-size: clamp(32px, 3.5vw, 42px); line-height: 1.25; letter-spacing: -.025em; }
.intro-copy { margin: 9px 0 0; color: var(--muted); font-size: 17px; }
.academic-year { display: grid; gap: 1px; min-width: 145px; padding: 10px 17px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.82); box-shadow: 0 3px 12px rgba(28,76,112,.04); }
.academic-year span { color: var(--muted); font-size: 12px; }
.academic-year strong { color: #c95c16; font-size: 25px; }
.register-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.register-card { min-height: 184px; padding: 19px 20px 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 5px 18px rgba(23,65,101,.055); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.register-card:hover { transform: translateY(-3px); border-color: #abd2eb; box-shadow: 0 12px 25px rgba(23,65,101,.11); }
.register-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.register-icon { display: grid; width: 43px; height: 43px; place-items: center; border-radius: 13px; font-size: 20px; font-weight: 700; }
.card-action { color: #8499aa; font-size: 12px; }
.register-blue .register-icon { color: #a5460e; background: #ffe9d5; }
.register-sky .register-icon { color: #b65312; background: #fff0df; }
.register-teal .register-icon { color: #a94d19; background: #fce8d9; }
.register-orange .register-icon { color: #9d4c0e; background: #ffefd1; }
.register-label { margin: 15px 0 0; color: #71563e; font-size: 16px; font-weight: 700; }
.register-count { margin: 1px 0 0; color: #4b2d18; font-size: 40px; font-weight: 700; line-height: 1.2; letter-spacing: -.035em; }
.register-foot { margin: 3px 0 0; color: #927960; font-size: 14px; }
.recent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin-top: 23px; }
.recent-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 5px 18px rgba(23,65,101,.045); }
.recent-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 19px; border-bottom: 1px solid #eaf1f6; }
.recent-card-header h2 { margin: 0; color: #4b2d18; font-size: 19px; }
.recent-card-header p { margin: 2px 0 0; color: #927960; font-size: 14px; }
.recent-card-header > a { flex: 0 0 auto; color: var(--blue); font-size: 15px; font-weight: 700; }
.recent-list { padding: 0 19px; }
.recent-row { display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 13px 0; border-bottom: 1px solid #eef3f7; }
.recent-row:last-child { border-bottom: 0; }
.document-number { flex: 0 0 auto; padding: 4px 9px; border-radius: 7px; color: #9d4c0e; background: #fff0df; font-size: 14px; font-weight: 700; }
.recent-details { min-width: 0; }
.document-topic { margin: 0; overflow: hidden; color: #4b3523; font-size: 16px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { margin: 3px 0 0; color: #806b58; font-size: 14px; }
.empty-state { margin: 0; padding: 34px 15px; color: #927960; font-size: 16px; text-align: center; }
.home-footer { padding: 22px 8px 0; color: #927960; font-size: 14px; text-align: center; }
.login-main { display: grid; min-height: calc(100vh - 72px); place-items: center; padding: 35px 20px; }
.login-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 16px 46px rgba(23,65,101,.12); }
.login-mark { display: inline-flex; padding: 7px 13px; border-radius: 999px; color: #a5460e; background: #ffe9d5; font-size: 14px; font-weight: 700; }
.login-card h1 { margin: 17px 0 4px; color: #4b2d18; font-size: 32px; }
.login-description { margin: 0 0 22px; color: var(--muted); font-size: 16px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 5px; color: #5d4028; font-size: 16px; font-weight: 700; }
.login-form input { width: 100%; min-height: 53px; padding: 11px 14px; border: 1px solid #e2c8af; border-radius: 10px; outline: none; background: #fffdfb; color: var(--ink); font: inherit; font-size: 18px; }
.login-form input:focus { border-color: #e87924; box-shadow: 0 0 0 4px rgba(232,121,36,.17); }
.login-form button { min-height: 54px; margin-top: 13px; border: 0; border-radius: 10px; background: var(--orange); color: #fff; font: inherit; font-size: 18px; font-weight: 700; cursor: pointer; }
.login-form button:hover { background: #d9781d; }
.login-error { margin: 0 0 15px; padding: 10px 12px; border: 1px solid #f6c6c1; border-radius: 9px; background: #fff1f0; color: #a33c36; font-size: 13px; }
/* Larger, warmer typography for comfortable reading */
.school-name, .register-label, .recent-card-header h2 { font-size: 19px; }
.intro-copy, .register-foot, .document-meta, .empty-state { font-size: 16px; }
.academic-year span { font-size: 14px; }
.card-action { font-size: 14px; }
.register-card:hover { border-color: #f2b47e; }
.recent-card-header { border-bottom-color: #f5e5d5; }
.recent-row, .recent-card { border-color: #f3e4d5; }
.login-error { font-size: 15px; }
.register-card { display: flex; flex-direction: column; }
.register-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.register-foot { margin: 0; }
.register-button { min-height: 44px; padding: 9px 13px; border: 0; border-radius: 10px; background: #e87924; color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 9px rgba(201,92,22,.16); }
.register-button:hover { background: #c95c16; }
.modal-backdrop { position: fixed; z-index: 1000; inset: 0; display: none; align-items: center; justify-content: center; overflow-y: auto; padding: 20px; background: rgba(48,31,19,.55); backdrop-filter: blur(4px); }
.modal-backdrop.is-open { display: flex; }
.document-modal { width: min(100%, 680px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 27px; border: 1px solid #f0dcc7; border-radius: 22px; background: #fff; box-shadow: 0 24px 80px rgba(48,31,19,.24); }
.modal-header { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 22px; }
.modal-header p { margin: 0; color: #c95c16; font-size: 15px; font-weight: 700; }
.modal-header h2 { margin: 4px 0 0; color: #4b2d18; font-size: 27px; line-height: 1.35; }
.modal-close { width: 42px; height: 42px; flex: 0 0 auto; border: 0; border-radius: 12px; background: #fff0df; color: #a9440c; font-size: 30px; line-height: 1; cursor: pointer; }
#quick-document-form { display: grid; gap: 10px; }
#quick-document-form label { margin-top: 5px; color: #5d4028; font-size: 16px; font-weight: 700; }
#quick-document-form label span { color: #c2410c; }
#quick-document-form input:not([type=file]) { width: 100%; min-height: 49px; padding: 10px 13px; border: 1px solid #e2c8af; border-radius: 11px; outline: none; background: #fffdfb; color: var(--ink); font: inherit; font-size: 17px; }
#quick-document-form input:focus { border-color: #e87924; box-shadow: 0 0 0 4px rgba(232,121,36,.14); }
#quick-document-form input[type=file] { width: 100%; padding: 12px; border: 1px dashed #e9b98f; border-radius: 11px; background: #fffaf5; font: inherit; font-size: 15px; }
.modal-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.upload-note { margin: -4px 0 8px; color: #806b58; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; padding-top: 17px; border-top: 1px solid #f3e4d5; }
.modal-actions button { min-height: 47px; padding: 10px 18px; border-radius: 11px; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.modal-cancel { border: 1px solid #ead8c6; background: #fff; color: #6d5946; }
.modal-submit { border: 0; background: #e87924; color: #fff; }
.modal-submit:hover { background: #c95c16; }
body.modal-open { overflow: hidden; }

@media (max-width: 850px) {
  .register-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .home-header-inner, .home-main { width: min(100% - 28px, 540px); }
  .home-header-inner { min-height: 64px; gap: 8px; }
  .home-brand { gap: 8px; font-size: 17px; }
  .brand-mark { width: 34px; height: 34px; }
  .home-actions { gap: 3px; }
  .history-link { padding: 8px 7px; font-size: 14px; }
  .login-link { padding: 8px 9px; font-size: 14px; }
  .user-greeting { display: none; }
  .home-main { padding-top: 28px; }
  .home-intro { align-items: flex-start; gap: 13px; margin-bottom: 19px; }
  .home-intro h1 { font-size: 30px; }
  .intro-copy { max-width: 260px; font-size: 15px; }
  .academic-year { min-width: 96px; padding: 8px 10px; border-radius: 11px; }
  .academic-year span { font-size: 12px; }
  .academic-year strong { font-size: 21px; }
  .register-grid { gap: 10px; }
  .register-card { min-height: 157px; padding: 14px; border-radius: 14px; }
  .register-icon { width: 38px; height: 38px; border-radius: 11px; }
  .register-label { margin-top: 12px; font-size: 15px; }
  .register-count { font-size: 34px; }
  .card-action { font-size: 13px; }
  .register-card-bottom { align-items: flex-start; flex-direction: column; gap: 8px; }
  .register-button { width: 100%; padding: 8px 9px; font-size: 14px; }
  .recent-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
  .recent-card-header { padding: 14px 15px; }
  .recent-list { padding: 0 15px; }
  .login-main { min-height: calc(100vh - 64px); padding: 20px 14px; }
  .login-card { padding: 25px 21px; border-radius: 16px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .document-modal { max-height: 92vh; padding: 22px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .modal-field-row { grid-template-columns: 1fr; gap: 8px; }
  .modal-header h2 { font-size: 24px; }
  .modal-actions button { flex: 1; padding: 9px 12px; }
}
@media (max-width: 360px) {
  .home-header-inner, .home-main { width: calc(100% - 20px); }
  .history-link { font-size: 13px; }
  .register-card { padding: 12px; }
  .card-action { font-size: 12px; }
}
