:root {
  color-scheme: light;
  font-family: "Kanit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #16302d;
  --muted: #607773;
  --line: #d8e7e4;
  --surface: #ffffff;
  --canvas: #f3f8f7;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --primary-soft: #dff4f1;
  --gold: #e8a317;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 18px 55px rgba(16, 64, 58, 0.12);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.splash, .login-shell {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 28px;
  background:
    radial-gradient(circle at 10% 10%, rgba(232,163,23,.22), transparent 32%),
    radial-gradient(circle at 90% 90%, rgba(15,118,110,.2), transparent 36%),
    var(--canvas);
}

.brand-mark {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: #fff;
  font-size: 25px;
  font-weight: 700;
  background: linear-gradient(145deg, #0f766e, #0b5e58);
  box-shadow: 0 12px 30px rgba(15,118,110,.26);
}

.spinner {
  width: 30px;
  height: 30px;
  margin: 18px auto;
  border: 3px solid #cae8e4;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-card {
  width: min(460px, 100%);
  padding: 40px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 30px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 8px 0 6px; font-size: clamp(28px, 6vw, 40px); }
.login-card p { color: var(--muted); margin: 0 0 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 500;
  transition: .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-wide { width: 100%; }
.btn-google { background: #fff; border-color: #d9e1e0; color: #243b38; box-shadow: 0 6px 18px rgba(16,64,58,.08); }
.btn-google .g { font-weight: 700; color: #4285f4; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 52px);
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .brand-mark { width: 46px; height: 46px; margin: 0; border-radius: 14px; font-size: 16px; }
.brand strong { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); }
.user-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { text-align: right; }
.user-chip strong, .user-chip small { display: block; }
.user-chip small { color: var(--muted); }

.page { width: min(1240px, calc(100% - 32px)); margin: 28px auto 60px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: clamp(25px, 4vw, 38px); }
.page-head p { margin: 5px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 28px rgba(20,70,64,.06); }
.card-pad { padding: clamp(20px, 4vw, 32px); }
.narrow { max-width: 720px; margin-inline: auto; }
.section-title { margin: 0 0 18px; font-size: 21px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field label { font-size: 14px; color: #3d5551; }
.field input, .field select, .field textarea, .search-box {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cddfdb;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .search-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.field input[readonly] { background: #f3f6f5; color: var(--muted); }
.input-prefix { display: flex; align-items: stretch; border: 1px solid #cddfdb; border-radius: 12px; overflow: hidden; background: #fff; }
.input-prefix:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.input-prefix span { display: grid; place-items: center; padding: 0 13px; color: var(--primary-dark); background: var(--primary-soft); font-weight: 600; }
.field .input-prefix input { min-width: 0; border: 0; border-radius: 0; box-shadow: none; }
.field .input-prefix input:focus { border: 0; box-shadow: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.hint { margin: 7px 0 0; font-size: 13px; color: var(--muted); }

.notice { padding: 14px 16px; border-radius: 14px; margin-bottom: 18px; background: var(--primary-soft); color: #175b55; }
.notice-danger { background: var(--danger-soft); color: var(--danger); }

.choice-card { min-height: 160px; display: grid; align-content: center; gap: 9px; padding: 24px; text-align: left; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.choice-card:hover { border-color: var(--primary); box-shadow: 0 8px 24px rgba(15,118,110,.1); }
.choice-card strong { font-size: 23px; color: var(--primary-dark); }
.choice-card span { color: var(--muted); line-height: 1.55; }

.profile-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; }
.photo-panel { text-align: center; }
.avatar { width: 160px; height: 160px; margin: 0 auto 14px; border-radius: 28px; object-fit: cover; background: #e5efed; border: 4px solid #fff; box-shadow: 0 8px 25px rgba(16,64,58,.15); }
.avatar-placeholder { display: grid; place-items: center; font-size: 50px; color: #5a7772; }
.photo-input { display: none; }
.photo-status { font-size: 12px; color: var(--muted); margin-top: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.stat b { display: block; font-size: 25px; color: var(--primary); }
.stat span { color: var(--muted); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 5px 0 14px; }
.tab { white-space: nowrap; padding: 10px 15px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); }
.tab.active { color: #fff; background: var(--primary); border-color: var(--primary); }
.toolbar { display: flex; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.toolbar .search-box { max-width: 430px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #e6efed; vertical-align: middle; }
th { position: sticky; top: 0; background: #f7fbfa; color: #49615d; font-size: 13px; }
td { font-size: 14px; }
.row-actions { display: flex; gap: 8px; }
tr:hover td { background: #fbfdfd; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; color: var(--muted); }
.badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; }
.badge-off { background: #edf1f0; color: #697b78; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(6,31,28,.56); }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 24px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 24px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }

.toast-region { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: grid; gap: 10px; }
.toast { width: min(360px, calc(100vw - 36px)); padding: 13px 16px; border-radius: 14px; color: #fff; background: #193f3b; box-shadow: 0 10px 35px rgba(0,0,0,.2); animation: toast-in .2s ease; }
.toast.error { background: #8f2018; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 760px) {
  .login-card { padding: 28px 22px; }
  .user-chip { display: none; }
  .page { width: min(100% - 20px, 1240px); margin-top: 18px; }
  .page-head { align-items: start; flex-direction: column; }
  .grid-2, .grid-3, .stats { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar .search-box { max-width: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
