/* =========================================================
 * iHRM ESS — Mobile App Styles
 * Theme: Navy Midnight + Antique Gold
 * ========================================================= */

:root {
  --ess-navy-950: #070f1c;
  --ess-navy-900: #0d1a2e;
  --ess-navy-800: #122441;
  --ess-navy-700: #162a4d;
  --ess-gold-300: #e8d49d;
  --ess-gold-400: #dabc6d;
  --ess-gold-500: #b29248;
  --ess-gold-600: #9a7d3a;
  --ess-gold-700: #7c6430;
  --ess-cream-50:  #fdfcf7;
  --ess-cream-100: #faf6ec;
  --ess-cream-200: #f3ead0;
  --ess-cream-300: #ece4cd;
}

/* ===== Reset / Base ===== */
* { -webkit-tap-highlight-color: rgba(178,146,72,.18); }

html, body {
  margin: 0; padding: 0;
  background: linear-gradient(180deg, #f4f1e8 0%, #fdfcf7 60%);
  color: var(--ess-navy-900);
  font-family: 'LINESeedSansTH','Sarabun','Inter','Helvetica Neue',Arial,sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ===== Phone Frame (max 480 width) ===== */
.ess-app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  box-shadow: 0 0 60px rgba(13,26,46,.08);
  position: relative;
  padding-bottom: 78px; /* room for bottom nav */
  overflow-x: hidden;
}

/* ===== Top Header (Navy + Gold) ===== */
.ess-topbar {
  background: linear-gradient(135deg, var(--ess-navy-900) 0%, var(--ess-navy-700) 100%);
  color: #fff;
  padding: 14px 16px 12px;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 2px solid var(--ess-gold-500);
  box-shadow: 0 2px 14px rgba(13,26,46,.18);
  display: flex; align-items: center; gap: 10px;
}
.ess-topbar .back {
  width: 36px; height: 36px; border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(178,146,72,.15);
  border: 1px solid rgba(178,146,72,.35);
  color: var(--ess-gold-400); font-size: 15px;
  flex-shrink: 0;
}
.ess-topbar .back:active { transform: scale(0.92); }
.ess-topbar .title {
  font-size: 16px; font-weight: 800; line-height: 1.15; flex: 1; min-width: 0;
}
.ess-topbar .title small {
  display: block; font-size: 11px; font-weight: 600; color: var(--ess-gold-300);
  letter-spacing: .06em; text-transform: uppercase;
}
.ess-topbar .topbar-actions { display: flex; gap: 6px; }
.ess-topbar .icon-btn {
  width: 36px; height: 36px; border-radius: 9999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(218,188,109,.35);
  color: var(--ess-gold-400);
  font-size: 14px; position: relative;
}
.ess-topbar .icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 9999px;
  background: #ef4444; border: 2px solid var(--ess-navy-900);
}

/* Hero greeting (home) */
.ess-hero {
  background:
    radial-gradient(400px 240px at 0% 0%, rgba(178,146,72,.22), transparent 60%),
    linear-gradient(135deg, var(--ess-navy-900) 0%, var(--ess-navy-700) 100%);
  color: #fff;
  padding: 20px 18px 28px;
  position: relative;
  overflow: hidden;
}
.ess-hero::before {
  content:''; position:absolute; inset:0;
  background-image: repeating-linear-gradient(135deg, rgba(178,146,72,.05) 0 2px, transparent 2px 12px);
}
.ess-hero::after {
  content:''; position:absolute; left:0; right:0; bottom:0; height:2px;
  background: linear-gradient(90deg, transparent, var(--ess-gold-500), transparent);
}
.ess-hero .row {
  position: relative; display: flex; align-items: center; gap: 12px;
}
.ess-hero .greet { font-size: 12px; color: var(--ess-gold-300); letter-spacing:.08em; text-transform: uppercase; font-weight: 600; }
.ess-hero .name { font-size: 18px; font-weight: 800; }
.ess-hero .meta {
  font-size: 11px; color: rgba(255,255,255,.7); margin-top: 2px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.ess-hero .meta span i { color: var(--ess-gold-400); margin-right: 3px; }

/* Avatar (used everywhere) */
.ess-avatar {
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--ess-gold-300), var(--ess-gold-500));
  color: var(--ess-navy-950);
  font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--ess-gold-500);
  background-size: cover; background-position: center;
  flex-shrink: 0;
}
.ess-avatar.ess-avatar--empty {
  font-weight: 400;
}

/* ===== Content padding ===== */
.ess-content { padding: 16px; }
.ess-content.no-pad { padding: 0; }

/* ===== Section title ===== */
.ess-sec {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; color: var(--ess-navy-900);
  font-size: 14px; margin: 14px 16px 8px;
}
.ess-sec i { color: var(--ess-gold-500); margin-right: 5px; }
.ess-sec a { font-size: 12px; font-weight: 700; color: var(--ess-gold-600); }

/* ===== Cards ===== */
.ess-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--ess-cream-300);
  box-shadow: 0 4px 12px rgba(13,26,46,.05);
  padding: 14px;
  margin: 0 16px 12px;
}
.ess-card.flat { box-shadow: none; }

/* ===== Quick Actions Grid ===== */
.qa-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: -16px 16px 18px;
  position: relative; z-index: 5;
  background: #fff; padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--ess-cream-300);
  box-shadow: 0 6px 18px rgba(13,26,46,.08);
}
.qa-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; padding: 4px;
}
.qa-item .ic {
  width: 46px; height: 46px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
}
.qa-item .lb {
  font-size: 11px; color: var(--ess-navy-900); font-weight: 700; line-height: 1.2;
}

/* Stat strip (home) */
.stat-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 0 16px 14px;
}
.stat-strip .it {
  background: #fff; border-radius: 12px;
  border: 1px solid var(--ess-cream-300);
  padding: 10px; text-align: center;
  box-shadow: 0 3px 10px rgba(13,26,46,.04);
}
.stat-strip .it .lb { font-size: 10px; color: #6b7280; font-weight: 600; text-transform: uppercase; letter-spacing:.04em; }
.stat-strip .it .vl { font-size: 18px; font-weight: 800; color: var(--ess-navy-900); line-height: 1.05; margin: 2px 0; }
.stat-strip .it .ic { color: var(--ess-gold-500); font-size: 13px; }

/* ===== List item rows ===== */
.ess-list { margin: 0 16px 16px; background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid var(--ess-cream-300); }
.ess-list a, .ess-list .item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid #f4ecd6;
  color: var(--ess-navy-900);
}
.ess-list a:last-child, .ess-list .item:last-child { border-bottom: none; }
.ess-list a:active { background: var(--ess-cream-100); }
.ess-list .ic {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; flex-shrink: 0;
}
.ess-list .text { flex: 1; min-width: 0; }
.ess-list .text .t { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.ess-list .text .s { font-size: 11px; color: #6b7280; margin-top: 2px; }
.ess-list .arrow { color: var(--ess-gold-500); font-size: 12px; flex-shrink: 0; }

/* ===== Pills ===== */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 9999px; padding: 2px 9px;
  font-size: 11px; font-weight: 700;
}
.pill.gold { background: var(--ess-cream-100); color: var(--ess-gold-700); border: 1px solid var(--ess-gold-400); }
.pill.navy { background: var(--ess-navy-900); color: var(--ess-gold-400); border: 1px solid var(--ess-gold-500); }
.pill.green { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.pill.red { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.pill.amber { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.pill.blue { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.pill.gray { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.pill.purple { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }

/* ===== Button (Mobile) ===== */
.btn-app {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; width: 100%;
  background: linear-gradient(135deg, var(--ess-gold-500), var(--ess-gold-400));
  color: var(--ess-navy-950);
  font-weight: 800; font-size: 14.5px;
  padding: 13px; border-radius: 12px;
  border: 1px solid var(--ess-gold-700);
  box-shadow: 0 6px 18px rgba(178,146,72,.35);
  cursor: pointer;
}
.btn-app:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(178,146,72,.3); }
.btn-app.navy {
  background: linear-gradient(135deg, var(--ess-navy-900), var(--ess-navy-700));
  color: var(--ess-gold-400);
  border-color: var(--ess-gold-500);
}
.btn-app.outline {
  background: transparent; color: var(--ess-navy-900);
  border: 1.5px solid var(--ess-cream-300); box-shadow: none;
}
.btn-app.danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff; border-color: #b91c1c;
  box-shadow: 0 6px 18px rgba(220,38,38,.3);
}
.btn-app.sm { padding: 9px 12px; font-size: 13px; border-radius: 10px; }

/* ===== Inputs (mobile) ===== */
.fld { margin-bottom: 12px; }
.fld label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--ess-navy-800); margin-bottom: 5px;
}
.fld label i { color: var(--ess-gold-600); margin-right: 4px; }
.fld .input {
  width: 100%; box-sizing: border-box;
  background: #fff; border: 1.5px solid var(--ess-cream-300);
  border-radius: 12px; padding: 12px 14px;
  font-size: 14px; color: var(--ess-navy-900);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld .input:focus {
  border-color: var(--ess-gold-500);
  box-shadow: 0 0 0 3px rgba(178,146,72,.15);
}
.fld textarea.input { min-height: 80px; resize: vertical; }
.fld .with-ic { position: relative; }
.fld .with-ic > i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ess-gold-500); font-size: 14px; pointer-events: none;
}
.fld .with-ic .input { padding-left: 40px; }

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: #fff;
  border-top: 1px solid var(--ess-cream-300);
  display: flex; align-items: stretch; justify-content: space-around;
  z-index: 100;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(13,26,46,.08);
}
.bottom-nav .b {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  padding: 6px 4px; color: #94a3b8;
  font-size: 10.5px; font-weight: 700; text-align: center;
  position: relative;
}
.bottom-nav .b i {
  font-size: 18px; transition: transform .15s;
}
.bottom-nav .b:active i { transform: scale(0.85); }
.bottom-nav .b.active {
  color: var(--ess-navy-900);
}
.bottom-nav .b.active i { color: var(--ess-gold-500); }
.bottom-nav .b.active::before {
  content: ''; position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 30px; height: 3px; border-radius: 0 0 4px 4px;
  background: var(--ess-gold-500);
}

/* center FAB (Plus) */
.bottom-nav .fab {
  position: relative; top: -22px;
  width: 56px; height: 56px; border-radius: 9999px;
  background: linear-gradient(135deg, var(--ess-gold-400), var(--ess-gold-500));
  color: var(--ess-navy-950);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
  box-shadow: 0 8px 22px rgba(178,146,72,.45), 0 0 0 4px #fff, 0 0 0 5px var(--ess-gold-400);
  border: none;
  flex-shrink: 0;
}
.bottom-nav .b-fab {
  flex: none; width: 60px; align-items: center;
  display: flex; flex-direction: column;
}

/* ===== Empty state ===== */
.empty {
  text-align: center; padding: 60px 20px;
  color: #94a3b8; font-size: 13px;
}
.empty .ic {
  width: 76px; height: 76px; margin: 0 auto 14px;
  border-radius: 9999px; background: var(--ess-cream-100);
  border: 2px dashed var(--ess-gold-400); color: var(--ess-gold-500);
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
}
.empty h3 { font-size: 15px; font-weight: 800; color: var(--ess-navy-900); margin: 0 0 4px; }

/* ===== Toast (flash) ===== */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 200; width: 90%; max-width: 440px;
}
.toast {
  background: #fff; border-radius: 12px; padding: 12px 14px;
  border: 1px solid var(--ess-cream-300);
  box-shadow: 0 12px 28px rgba(13,26,46,.18);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
  animation: toast-in .25s ease;
}
.toast .ic { width: 32px; height: 32px; border-radius: 9999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.toast.success .ic { background: #10b981; }
.toast.error   .ic { background: #ef4444; }
.toast.info    .ic { background: var(--ess-gold-500); }
.toast .msg { flex: 1; font-size: 13px; font-weight: 700; color: var(--ess-navy-900); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Login screen (special) ===== */
.ess-login {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(500px 300px at 50% 0%, rgba(178,146,72,.25), transparent 60%),
    linear-gradient(180deg, var(--ess-navy-950) 0%, var(--ess-navy-900) 50%, var(--ess-navy-700) 100%);
  color: #fff;
  padding: 30px 22px 22px;
}
.ess-login .logo {
  text-align: center; margin: 30px 0 24px;
}
.ess-login .logo .brand-logo {
  width: auto; height: 72px; max-width: 240px;
  object-fit: contain;
  margin: 0 auto 10px;
  display: block;
  border-radius: 18px;
  padding: 10px 16px;
  background: #fff;
  border: 3px solid var(--ess-gold-500);
  box-shadow: 0 14px 40px rgba(178,146,72,.35), 0 8px 24px rgba(0,0,0,.35);
}
.ess-login .logo .brand-name {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin-bottom: 10px;
}
.ess-login .logo .brand-name .ln1 {
  font-size: 18px; font-weight: 800; letter-spacing: .04em;
  color: #fff; line-height: 1.1;
}
.ess-login .logo .brand-name .ln2 {
  font-size: 18px; font-weight: 800; letter-spacing: .06em;
  color: var(--ess-gold-400); line-height: 1.1;
}
.ess-login h1 { font-size: 24px; font-weight: 800; margin: 0; }
.ess-login h1 .gold { color: var(--ess-gold-400); }
.ess-login p { font-size: 13px; color: var(--ess-gold-300); margin-top: 4px; }

.ess-login .form {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(218,188,109,.35);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(12px);
}
.ess-login .fld label { color: var(--ess-gold-300); }
.ess-login .fld .input {
  background: rgba(255,255,255,.95);
  color: var(--ess-navy-900);
  border-color: rgba(218,188,109,.35);
}
.ess-login .help {
  margin-top: 14px; font-size: 11.5px; color: rgba(255,255,255,.55);
  text-align: center; line-height: 1.55;
}

.ess-login .footer {
  margin-top: auto; text-align: center; font-size: 11px;
  color: rgba(218,188,109,.6); padding: 14px 0 4px;
}

/* ===== Slip Card ===== */
.slip-summary {
  background: linear-gradient(135deg, var(--ess-navy-900), var(--ess-navy-700));
  color: #fff;
  border-radius: 18px;
  padding: 18px;
  margin: 16px;
  border: 1px solid rgba(218,188,109,.4);
  position: relative; overflow: hidden;
}
.slip-summary::before {
  content:''; position:absolute; inset:0;
  background-image: repeating-linear-gradient(135deg, rgba(178,146,72,.05) 0 2px, transparent 2px 14px);
}
.slip-summary .lb { font-size: 11px; color: var(--ess-gold-300); letter-spacing:.06em; text-transform: uppercase; }
.slip-summary .vl { font-size: 30px; font-weight: 800; color: var(--ess-gold-400); margin-top: 4px; }
.slip-summary .vl small { font-size: 14px; color: var(--ess-gold-300); }
.slip-summary .row {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed rgba(218,188,109,.3);
  position: relative;
}
.slip-summary .row .it { text-align: center; flex: 1; }
.slip-summary .row .it .ll { font-size: 10px; color: var(--ess-gold-300); text-transform: uppercase; }
.slip-summary .row .it .vv { font-size: 14px; font-weight: 800; color: #fff; margin-top: 2px; }

/* ===== Leave quota (ESS leaves.php) — รายการแนว list + อัตรา 5/30 + progress bar ===== */
.ess-lv-quota-hero {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1px solid #86efac;
  border-radius: 14px;
  margin: 0 16px 10px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.ess-lv-quota-hero::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(5, 150, 105, .06) 0 1px, transparent 1px 10px);
  pointer-events: none;
  z-index: 0;
}
.ess-lv-quota-hero h3 { margin: 0; font-size: 13px; font-weight: 800; color: var(--ess-navy-900); position: relative; z-index: 1; }
.ess-lv-quota-hero p { margin: 4px 0 0; font-size: 11.5px; color: #166534; position: relative; z-index: 1; }
.ess-lv-quota-hero p + p { margin-top: 6px; }

.ess-lq-list {
  margin: 0 16px 12px;
  background: #fff;
  border: 1px solid var(--ess-cream-300);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(13, 26, 46, .06);
}
.ess-lq-row {
  padding: 12px 14px 10px;
  border-bottom: 1px solid #f1f5f9;
  --ess-lq-c: #3b82f6;
  position: relative;
}
.ess-lq-row:last-child { border-bottom: none; }
.ess-lq-row-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px;
  min-width: 0;
}
.ess-lq-row-name {
  font-weight: 800; font-size: 14px; color: var(--ess-navy-900);
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
}
.ess-lq-row-name i.fa-circle { font-size: 8px; color: var(--ess-lq-c, #3b82f6); flex-shrink: 0; }
.ess-lq-row-ratio {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-weight: 800; font-size: 16px; letter-spacing: -0.02em;
  color: var(--ess-navy-900);
  flex-shrink: 0;
}
.ess-lq-row--warn .ess-lq-row-ratio { color: #b45309; }
.ess-lq-row--full  .ess-lq-row-ratio { color: #b91c1c; }
.ess-lq-row-meta {
  display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; color: #64748b; margin-bottom: 8px;
}
.ess-lq-row-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ess-lq-pend { color: #b45309; font-weight: 700; }

.ess-lq-bar-track {
  height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; position: relative;
}
.ess-lq-row--warn .ess-lq-bar-track { background: #fef3c7; box-shadow: inset 0 0 0 1px #fcd34d; }
.ess-lq-row--full  .ess-lq-bar-track {
  height: 10px; background: #fee2e2;
  box-shadow: inset 0 0 0 1px #fca5a5;
  animation: ess-lq-pulse 1.8s ease-in-out infinite;
}
.ess-lq-bar-fill { height: 100%; border-radius: 99px; max-width: 100%; transition: width .35s ease; }
@keyframes ess-lq-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px #fca5a5; }
  50%     { box-shadow: inset 0 0 0 1px #f87171, 0 0 0 2px rgba(248, 113, 113, .25); }
}

.ess-lq-nearchip {
  margin-top: 6px; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 8px; width: fit-content;
}
.ess-lq-row--warn .ess-lq-nearchip { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.ess-lq-row--full  .ess-lq-nearchip  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.ess-lq-unlimited {
  margin-top: 4px; font-size: 11px; color: #64748b; display: flex; align-items: center; gap: 5px; font-weight: 600;
}
.ess-lq-footnote {
  margin: 0 16px 8px; font-size: 10px; color: #94a3b8; line-height: 1.35;
}
.ess-sec.ess-sec--flush { margin-top: 0; }
