/* XGL Mobile - light theme, violet accent, mobile-first */
:root {
  --violet: #6d28d9;
  --violet-dark: #5b21b6;
  --violet-soft: #ede9fe;
  --ink: #1e1b2e;
  --muted: #6b7280;
  --bg: #f5f4fa;
  --card: #ffffff;
  --line: #e5e3f0;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(30, 27, 46, .07);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 14px; margin: 10px 0 0; text-align: center; }
.note {
  background: var(--warn-soft); color: var(--warn);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 12px 0 0;
}

.screen { min-height: 100dvh; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }

/* Splash / Login */
.splash-logo {
  font-size: 44px; font-weight: 700; letter-spacing: 1px; color: var(--ink);
  margin-bottom: 12px; text-align: center;
}
.splash-logo span { color: var(--violet); }
.spinner {
  width: 28px; height: 28px; margin: 8px auto;
  border: 3px solid var(--violet-soft); border-top-color: var(--violet);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-card {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 24px; width: 100%; max-width: 360px; text-align: center;
}
.login-title { font-size: 22px; margin: 4px 0 2px; }
.login-sub { margin: 0 0 20px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-form input {
  font: inherit; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; outline: none; background: #fafafa;
}
.login-form input:focus { border-color: var(--violet); background: #fff; }
.bind-avatar { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 10px; display: block; }

.btn {
  font: inherit; font-weight: 600; border: none; border-radius: 12px;
  padding: 13px 16px; width: 100%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s;
}
.btn:active { filter: brightness(.92); }
.btn-line { background: #06c755; color: #fff; margin-bottom: 10px; }
.btn-primary { background: var(--violet); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); padding: 10px; }
.btn-danger-soft { background: var(--bad-soft); color: var(--bad); }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.topbar-logo { font-size: 20px; font-weight: 700; }
.topbar-logo span { color: var(--violet); }
.topbar-title { flex: 1; font-weight: 600; font-size: 16px; }
.icon-btn {
  background: none; border: none; color: var(--muted); padding: 8px;
  border-radius: 10px; cursor: pointer; display: flex;
}
.icon-btn:active { background: var(--violet-soft); color: var(--violet); }

/* Pane + tabbar */
.pane { padding: 16px 16px calc(86px + var(--safe-bottom)); max-width: 560px; margin: 0 auto; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 500;
  padding: 6px 0; position: relative; border-radius: 12px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--violet); }
.tab .dot {
  position: absolute; top: 4px; right: calc(50% - 16px);
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
}

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.greeting { font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.greeting-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.quota-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quota-item {
  background: var(--violet-soft); border-radius: 12px; padding: 10px 8px; text-align: center;
}
.quota-num { font-size: 20px; font-weight: 700; color: var(--violet-dark); }
.quota-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

.list-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.li-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--violet-soft);
}

.chip {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.approved { background: var(--ok-soft); color: var(--ok); }
.chip.rejected { background: var(--bad-soft); color: var(--bad); }

.unread-dot { width: 9px; height: 9px; background: #ef4444; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }

.empty-state { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 14px; }
.empty-state .big { font-size: 36px; margin-bottom: 8px; }

/* Month section in calendar */
.month-head {
  font-size: 13px; font-weight: 700; color: var(--violet-dark);
  margin: 18px 4px 8px; display: flex; align-items: center; gap: 8px;
}
.month-head:first-child { margin-top: 0; }
.holiday-date {
  width: 44px; flex-shrink: 0; text-align: center; background: var(--violet-soft);
  border-radius: 10px; padding: 6px 0;
}
.holiday-date .d { font-size: 17px; font-weight: 700; color: var(--violet-dark); line-height: 1.1; }
.holiday-date .m { font-size: 10.5px; color: var(--muted); }
.holiday-past { opacity: .45; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(86px + var(--safe-bottom)); z-index: 21;
  width: 56px; height: 56px; border-radius: 18px; border: none; cursor: pointer;
  background: var(--violet); color: #fff; font-size: 26px;
  box-shadow: 0 6px 18px rgba(109, 40, 217, .4);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { filter: brightness(.9); }

/* Modal (bottom sheet) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 35, .45); z-index: 30;
}
.modal {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; background: var(--line); border-radius: 99px; margin: 0 auto 14px; }
.sheet-title { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form-group select, .form-group input, .form-group textarea {
  font: inherit; width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fafafa; outline: none;
}
.form-group select:focus, .form-group input:focus, .form-group textarea:focus {
  border-color: var(--violet); background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg2 button {
  font: inherit; font-weight: 600; padding: 10px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fafafa; cursor: pointer; color: var(--muted);
}
.seg2 button.active { border-color: var(--violet); background: var(--violet-soft); color: var(--violet-dark); }

/* Detail rows (profile / leave detail) */
.kv { display: flex; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { width: 110px; flex-shrink: 0; color: var(--muted); }
.kv .v { flex: 1; word-break: break-word; }

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  background: var(--violet-soft); color: var(--violet-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.announce-content { font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.attach-img { width: 100%; border-radius: 12px; margin-top: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + var(--safe-bottom)); z-index: 40;
  background: var(--ink); color: #fff; font-size: 13.5px;
  padding: 10px 18px; border-radius: 99px; box-shadow: var(--shadow);
  max-width: 86vw; text-align: center;
}

.skeleton { background: linear-gradient(90deg, #ececf4 25%, #f6f5fb 50%, #ececf4 75%); background-size: 200% 100%; animation: shimmer 1.1s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
