:root {
  --ink: #14120f;
  --paper: #faf8f3;
  --card: #ffffff;
  --gold: #c99a2e;
  --gold-deep: #a67f22;
  --line: #e7e2d6;
  --muted: #6b6558;
  --green: #2f7a4f;
  --red: #b3432b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 28px;
  background: var(--ink);
  color: #fff;
}
.brand { text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.brand-mark { font-weight: 700; letter-spacing: 0.3px; color: #fff; font-size: 18px; }
.brand-logo { height: 40px; display: block; }
.brand-logo-lg { height: 56px; }
.brand-sub { color: var(--gold); font-size: 14px; font-weight: 600; }
.topbar { flex-wrap: wrap; }
.topnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; row-gap: 4px; }
.topnav a {
  color: #cfcabf;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.topnav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.topnav a.active { color: var(--ink); background: var(--gold); font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #cfcabf; }
.logout { color: var(--gold); text-decoration: none; }
.logout:hover { text-decoration: underline; }

/* ---- layout ---- */
.page { max-width: 1080px; margin: 0 auto; padding: 28px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } .topnav { display: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; }

/* ---- balance card ---- */
.balance-number { font-size: 40px; font-weight: 700; color: var(--ink); }
.balance-number span { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.balance-sub { color: var(--muted); font-size: 13px; margin: 6px 0 18px; }

.stat-list { margin: 0 0 16px; }
.stat-list div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; font-weight: 600; }

/* ---- buttons ---- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 7px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--gold); color: var(--ink); }
.btn-primary:hover { background: var(--gold-deep); }
.btn-primary:disabled { background: #e3d9bf; color: #a89f8a; cursor: not-allowed; }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-secondary:hover { background: #2a2620; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-approve { background: var(--green); color: #fff; }
.btn-reject { background: var(--red); color: #fff; }

/* ---- forms ---- */
.form-card { max-width: 560px; }
.form-intro { color: var(--muted); margin-top: -6px; }
.field-row { display: flex; gap: 16px; }
.field { flex: 1; margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
input[type=date], input[type=text], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
.input-narrow { width: 72px; }

.days-preview {
  background: #f6f1e4;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--ink);
}
.days-preview strong { color: var(--gold-deep); }

/* ---- tables ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table td { font-size: 13px; }

.decision-form { display: flex; gap: 6px; align-items: center; }
.decision-form input[type=text] { width: 140px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-pending_manager { background: #fdf1d6; color: #93691b; }
.badge-pending_hr { background: #e4e9f7; color: #34508f; }
.badge-approved { background: #e4f3e9; color: var(--green); }
.badge-rejected { background: #fbe6e1; color: var(--red); }
.badge-cancelled { background: #efece3; color: var(--muted); }
.badge-pending_ceo { background: #f0e6fb; color: #6b3fa0; }

.empty { color: var(--muted); font-size: 14px; }
.link-more { display: inline-block; margin-top: 10px; color: var(--gold-deep); text-decoration: none; font-size: 13px; font-weight: 600; }

/* ---- tabs ---- */
.pipeline-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.pipeline-tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--line);
}
.pipeline-tabs a:hover { border-color: var(--gold); }
.pipeline-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- form helpers ---- */
.section-heading { font-size: 14px; font-weight: 700; margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.field-hint { color: var(--muted); font-size: 12px; margin: -10px 0 14px; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); font-size: 14px; }
.checkbox-inline input { width: auto; }

/* ---- warning callout (conflicts) ---- */
.warning-note {
  background: #fdf1d6;
  border: 1px solid #e8cd8e;
  border-radius: 7px;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: #7a5a12;
}

/* ---- team calendar ---- */
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding-bottom: 4px; }
.cal-day {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 90px;
  padding: 6px;
  font-size: 12px;
  background: #fff;
}
.cal-day.out-of-month { background: #faf8f3; color: var(--muted); }
.cal-day.is-weekend { background: #f6f4ee; }
.cal-day.is-today { border-color: var(--gold); border-width: 2px; }
.cal-day-num { font-weight: 700; margin-bottom: 4px; }
.cal-holiday { display: block; font-size: 10px; background: #fbe6e1; color: var(--red); border-radius: 4px; padding: 1px 5px; margin-bottom: 3px; }
.cal-entry { display: block; font-size: 10px; border-radius: 4px; padding: 1px 5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-entry.status-approved { background: #e4f3e9; color: var(--green); }
.cal-entry.status-pending_manager, .cal-entry.status-pending_hr { background: #fdf1d6; color: #93691b; }
@media (max-width: 760px) {
  .cal-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .cal-day { min-height: 60px; padding: 3px; font-size: 10px; }
}

/* ---- flash ---- */
.flash-stack { margin-bottom: 18px; }
.flash { padding: 10px 14px; border-radius: 7px; font-size: 14px; margin-bottom: 8px; }
.flash-success { background: #e4f3e9; color: var(--green); }
.flash-error { background: #fbe6e1; color: var(--red); }

/* ---- login ---- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--ink); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 36px; width: 340px; text-align: center; }
.login-brand { justify-content: center; margin-bottom: 14px; }
.login-brand .brand-mark { color: var(--ink); }
.login-copy { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-alt { margin-top: 16px; font-size: 13px; }
.login-alt a { color: var(--gold-deep); text-decoration: none; }
.login-alt a:hover { text-decoration: underline; }
.admin-tabs { display:flex; gap:8px; margin-bottom:16px; border-bottom:1px solid #e0dcd4; }
.admin-tabs .tab { padding:8px 16px; text-decoration:none; color:#6b6459; border-bottom:2px solid transparent; }
.admin-tabs .tab.active { color:#1a1a1a; border-bottom-color:#c9a227; font-weight:600; }
.select-manager { min-width:180px; max-width:220px; }
.btn-danger { background:#b3261e; color:#fff; border-color:#b3261e; }
.btn-danger:hover { background:#8f1d17; }
.region-group { margin-bottom:14px; border:1px solid #e0dcd4; border-radius:6px; }
.region-group summary { cursor:pointer; padding:10px 14px; font-weight:600; background:#faf8f4; list-style:none; }
.region-group summary::-webkit-details-marker { display:none; }
.region-group summary::before { content:"▸ "; }
.region-group[open] summary::before { content:"▾ "; }
.region-group table { margin:0; }

.col-actions { width: 1%; white-space: nowrap; }

/* =========================================================================
   Employee bio-data
   ========================================================================= */
.bio-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.bio-kicker { color: var(--muted); font-size: 13px; margin: -10px 0 10px; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 13px; }
.bio-subsection { font-size: 14px; font-weight: 700; margin: 22px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink); }
.req { color: var(--red); font-weight: 700; }
.opt { color: var(--muted); font-weight: 400; }
.bio-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.bio-grid .field { margin-bottom: 14px; }
.span-2 { grid-column: span 2; }
input[type=email], input[type=tel] { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; min-height: 40px; }
.inline-other { width: 200px !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* passport photo frame (35x45 ratio) */
.photo-frame { flex: 0 0 auto; width: 140px; height: 180px; border: 2px dashed #cfc6ae; border-radius: 6px; display: flex; align-items: center; justify-content: center; text-align: center; background: #fbf9f4; cursor: pointer; overflow: hidden; position: relative; margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.photo-frame:hover { border-color: var(--gold); }
.photo-frame.has-photo { border-style: solid; border-color: var(--line); }
.photo-frame.static { cursor: default; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-frame small { font-weight: 400; }
.photo-frame.is-invalid { border-color: var(--red); background: #fdf1ee; }
.photo-error { position: absolute; bottom: 6px; left: 0; right: 0; color: var(--red); font-size: 11px; }

/* attachments */
.attach-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; }
.attach-row { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.attach-thumb { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 6px; overflow: hidden; background: #f6f4ee; display: flex; align-items: center; justify-content: center; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-body { flex: 1; min-width: 0; }
.attach-body label { margin-bottom: 4px; }
.attach-body input[type=file] { font-size: 12px; max-width: 100%; }
.attach-current { font-size: 12px; color: var(--muted); margin-top: 4px; }
.attach-current a { color: var(--gold-deep); }
.file-chip { display: inline-block; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 4px; }
.file-chip-empty { background: #e7e2d6; color: var(--muted); }
.attach-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gallery-thumb { display: flex; align-items: center; justify-content: center; height: 110px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #f6f4ee; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb.missing { border-style: dashed; }
.gallery-label { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.3; }

/* repeating tables */
.rows-wrap { overflow-x: auto; }
.bio-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.bio-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.bio-table td { padding: 5px 4px; vertical-align: middle; }
.bio-table td.sn { width: 28px; color: var(--muted); font-size: 13px; text-align: right; padding-right: 8px; }
.bio-table input, .bio-table select { padding: 7px 8px; font-size: 13px; min-width: 90px; }
.bio-table input[type=number] { min-width: 80px; }
.row-remove { border: none; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.row-remove:hover { color: var(--red); background: #fbe6e1; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.none-toggle { margin-bottom: 10px; }

/* declaration + signature */
.declaration { margin-bottom: 14px; }
.sign-block { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: start; }
.sig-wrap { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; min-height: 60px; display: flex; align-items: center; justify-content: center; }
#sig-pad { width: 100%; height: auto; aspect-ratio: 600 / 180; display: block; touch-action: none; cursor: crosshair; background: repeating-linear-gradient(transparent 0 139px, #e7e2d6 139px 140px); }
#sig-pad.is-invalid { outline: 2px solid var(--red); }
.sig-existing { max-height: 120px; max-width: 100%; }
.sig-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.sig-error { color: var(--red); font-size: 13px; }
.sign-meta { margin-top: 26px; }

.bio-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.upload-note { color: var(--muted); font-size: 13px; }
.bio-callout { background: #f6f1e4; border: 1px solid #e8dcb8; border-radius: 8px; padding: 12px 14px; margin: 8px 0 16px; font-size: 14px; }
.bio-callout-red { background: #fbe6e1; border-color: #eec2b6; color: #7c2c1b; }
.bio-callout .btn { margin-left: 8px; }
.bio-callout-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* read-only view */
.bio-dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 24px; margin: 0; }
.bio-dl div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.bio-dl dt { color: var(--muted); font-size: 13px; }
.bio-dl dd { margin: 0; font-weight: 600; text-align: right; }
.view-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
.review-card { border-color: var(--gold); }
.review-form textarea { margin-bottom: 10px; }
.review-buttons { display: flex; gap: 10px; }

/* HR list */
.hr-bio-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.search-row { display: flex; gap: 8px; margin-bottom: 12px; max-width: 420px; }
.avatar-cell { width: 44px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar-empty { background: #efece3; color: var(--muted); font-weight: 700; font-size: 14px; }

.badge-bio-not_started { background: #efece3; color: var(--muted); }
.badge-bio-draft { background: #fdf1d6; color: #93691b; }
.badge-bio-submitted { background: #e4e9f7; color: #34508f; }
.badge-bio-returned { background: #fbe6e1; color: var(--red); }
.badge-bio-verified { background: #e4f3e9; color: var(--green); }

@media (max-width: 760px) {
  .page { padding: 16px; }
  .bio-title-row { flex-direction: column-reverse; align-items: center; }
  .bio-grid, .bio-dl, .attach-list { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .attach-gallery { grid-template-columns: repeat(2, 1fr); }
  .sign-block { grid-template-columns: 1fr; }
  .sign-meta { margin-top: 0; }
  /* stack table rows as cards on phones */
  .bio-table thead { display: none; }
  .bio-table, .bio-table tbody, .bio-table tr, .bio-table td { display: block; width: 100%; }
  .bio-table tr { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; position: relative; }
  .bio-table td { padding: 4px 0; }
  .bio-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
  .bio-table td.sn { text-align: left; font-weight: 700; }
  .bio-table td:last-child { position: absolute; top: 4px; right: 4px; width: auto; }
  .review-buttons { flex-direction: column; }
}

/* Phones: show the top menu as a swipeable row instead of hiding it,
   so field staff can reach every tab (incl. My bio-data). */
@media (max-width: 760px) {
  .topbar { gap: 10px 16px; padding: 12px 16px; }
  .topnav { display: flex; order: 3; width: 100%; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  .topnav::-webkit-scrollbar { display: none; }
  .topbar-user { margin-left: auto; }
}
.leave-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 14px; }
.leave-tile { background: #f6f1e4; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.lt-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.lt-label { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) { .leave-tiles { grid-template-columns: 1fr; } }
/* "I don't have a Pension ID / TIN" */
.dont-have { margin-top: 6px; font-size: 13px; color: var(--muted); }
.field input:disabled { background: #f3f1ec; color: var(--muted); }
.dont-have-note { display: none; font-size: 12px; color: var(--muted); margin-top: 4px; }
.attach-row.is-not-needed { background: #faf8f3; border-style: dashed; }
.attach-row.is-not-needed label, .attach-row.is-not-needed .attach-thumb { opacity: .5; }
.attach-row.is-not-needed input[type=file] { display: none; }
.attach-row.is-not-needed .dont-have-note { display: block; }
.muted-val { color: var(--muted); font-weight: 500; }
