/* Employee Portal — mobile-first app UI */
:root {
  --primary: #b61c1b;
  --primary-dark: #8f1414;
  --primary-light: #fdecec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2126;
  --muted: #7a828c;
  --line: #e7e9ee;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 24, 31, .07);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh;
}
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); position: relative; }
@media (min-width: 520px) { .app { box-shadow: 0 0 40px rgba(0,0,0,.12); } }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  box-shadow: 0 2px 8px rgba(182, 28, 27, .35);
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-btn {
  color: #fff; text-decoration: none; font-size: 1.3rem; line-height: 1;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,.15); flex: none;
}
.topbar-logo { height: 34px; width: auto; max-width: 130px; border-radius: 8px; object-fit: contain; background: #fff; padding: 2px 4px; flex: none; }
.topbar-logo-mark {
  width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex: none;
}

/* Content */
.content { flex: 1; padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px)); }
.content.nonav { padding-bottom: 24px; }

/* Bottom navigation */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(env(safe-area-inset-bottom, 0px) + 6px);
}
.bottomnav a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: .68rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
}
.bottomnav a .ico { font-size: 1.35rem; line-height: 1.2; }
.bottomnav a.on { color: var(--primary); font-weight: 600; }
.bottomnav .addico {
  background: var(--primary); color: #fff; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-top: -18px;
  box-shadow: 0 4px 12px rgba(182,28,27,.45);
}

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: .95rem; margin-bottom: 12px; color: var(--primary); font-weight: 700; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title-row h2 { margin: 0; }

/* Detail list */
.dl { display: grid; grid-template-columns: 1fr; gap: 0; }
.dl .row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dl .row:last-child { border-bottom: 0; }
.dl .k { color: var(--muted); font-size: .8rem; flex: none; max-width: 45%; }
.dl .v { font-size: .86rem; font-weight: 500; text-align: right; word-break: break-word; }

/* Forms */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: .95rem; color: var(--text);
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; outline: none;
  appearance: none; -webkit-appearance: none;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none; cursor: pointer;
  background: var(--primary); color: #fff; border: 0; border-radius: 12px;
  padding: 14px; font-size: 1rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(182,28,27,.35);
}
.btn:active { background: var(--primary-dark); transform: scale(.99); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.btn-sm { display: inline-block; width: auto; padding: 8px 14px; font-size: .8rem; border-radius: 9px; box-shadow: none; }
.btn-ghost { background: var(--primary-light); color: var(--primary); box-shadow: none; }
.btn-danger { background: #fff; color: #c0392b; border: 1.5px solid #f0c3be; box-shadow: none; }

/* Flash */
.flash { padding: 12px 14px; border-radius: 10px; font-size: .85rem; margin-bottom: 14px; }
.flash-success { background: #e8f7ee; color: #1c7c40; border: 1px solid #bfe8cf; }
.flash-error { background: #fdecec; color: #b61c1b; border: 1px solid #f4c3c2; }
.flash-info { background: #eaf2fd; color: #1d5fb8; border: 1px solid #c3d9f4; }

/* Auth screens */
body:has(.auth), .app:has(.auth) { background: #fff; }
.auth { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding: 28px 22px calc(28px + env(safe-area-inset-bottom, 0px)); }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo img {
  /* show the uploaded logo in full — never crop it */
  width: auto; height: auto; max-width: 240px; max-height: 110px;
  object-fit: contain; border-radius: 14px; background: #fff;
  padding: 6px;
}
.auth-logo .mark {
  width: 76px; height: 76px; border-radius: 20px; margin: 0 auto; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 800;
  box-shadow: 0 8px 20px rgba(182,28,27,.4);
}
.auth-logo h1 { font-size: 1.35rem; margin-top: 14px; }
.auth-logo p { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.auth .links { text-align: center; margin-top: 16px; font-size: .85rem; }
.auth .links a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* OTP boxes */
.otp-input { letter-spacing: 14px; text-align: center; font-size: 1.5rem !important; font-weight: 700; }

/* App store badges */
.store-row { margin-top: 26px; display: flex; justify-content: center; gap: 10px; }
.store-btn {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  background: #1d2126; color: #fff; border: 1px solid #3a4048;
  border-radius: 9px; padding: 6px 12px; min-width: 128px;
}
.store-btn:active { background: #000; }
.store-btn .store-ico { font-size: 21px; width: 24px; text-align: center; flex: none; color: #fff; }
.store-btn small { display: block; font-size: .52rem; letter-spacing: .08em; color: #bbb; line-height: 1.2; }
.store-btn b { font-size: .82rem; line-height: 1.2; }

/* Bottom-sheet modal (iOS install steps) */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 18, 22, .55); backdrop-filter: blur(2px);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 22px 22px 0 0; padding: 10px 22px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 16px; }
.modal-sheet h3 { font-size: 1.05rem; margin-bottom: 6px; }
.ios-steps { list-style: none; margin: 0 0 18px; padding: 0; }
.ios-steps li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .88rem;
}
.ios-steps li:last-child { border-bottom: 0; }
.step-ico {
  width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.share-glyph { width: 18px; height: 18px; }

/* Employee list */
.emp-item {
  display: flex; align-items: center; gap: 13px; text-decoration: none; color: var(--text);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; margin-bottom: 10px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
/* Uploaded photos: never crop — show the whole image, letterboxed on white */
img.avatar {
  object-fit: contain; background: #fff;
  border-radius: 12px; border: 1px solid var(--line);
}
.emp-item .meta { flex: 1; min-width: 0; }
.emp-item .meta b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-item .meta span { color: var(--muted); font-size: .76rem; }
.emp-item .chev { color: var(--muted); }

/* Profile hero */
.hero { text-align: center; padding: 20px 0 8px; }
.hero .avatar { width: 84px; height: 84px; margin: 0 auto 10px; font-size: 1.5rem; border: 3px solid var(--primary-light); }
.hero img.avatar { width: auto; max-width: 220px; max-height: 160px; height: auto; border-radius: 14px; display: block; }
.hero h2 { font-size: 1.15rem; }
.hero p { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.badge { display: inline-block; background: var(--primary-light); color: var(--primary); font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 20px; margin-top: 8px; }

/* Tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; text-decoration: none; font-size: .8rem; font-weight: 600;
  color: var(--muted); background: var(--card); border: 1px solid var(--line);
  padding: 8px 15px; border-radius: 20px;
}
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 16px; text-decoration: none; color: var(--text);
  display: flex; align-items: center; gap: 12px;
}
.tile .num { display: block; font-size: 1.45rem; font-weight: 800; color: var(--text); line-height: 1.15; }
.tile .lbl { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.tico {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.tico.t1 { background: var(--primary-light); color: var(--primary); }
.tico.t2 { background: #eaf2fd; color: #1d5fb8; }
.tico.t3 { background: #e8f7ee; color: #1c7c40; }
.tico.t4 { background: #fdf3e4; color: #c07a13; }

/* Salary slip */
.slip-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.slip-item:last-child { border-bottom: 0; }
.slip-item b { font-size: .9rem; }
.slip-item small { color: var(--muted); display: block; }
.slip-net { color: var(--primary); font-weight: 700; }
.slip-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.slip-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.slip-table td:last-child { text-align: right; font-weight: 600; }
.slip-table tr.total td { border-top: 2px solid var(--text); font-weight: 800; color: var(--primary); font-size: .95rem; }

.nav-brand { display: none; }
.nav-user { display: none; }
.list-grid { display: block; }

.muted { color: var(--muted); font-size: .82rem; }
.mt { margin-top: 14px; }
/* Toggle switch */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 30px;
  background: #cfd4db; transition: background .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* Attendance */
.att-times { display: flex; gap: 12px; }
.att-times > div {
  flex: 1; background: var(--bg); border-radius: 12px; padding: 12px 14px; text-align: center;
}
.att-times small { display: block; color: var(--muted); font-size: .7rem; margin-bottom: 4px; }
.att-times b { font-size: 1.05rem; }

/* Calendar */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav b { font-size: .95rem; }
.cal-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--bg); color: var(--text); text-decoration: none; font-size: .8rem;
}
.cal-btn-off { opacity: .3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: .68rem; font-weight: 700; color: var(--muted); }
.cal-head .sun { color: var(--primary); }
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: .82rem; background: var(--bg); color: var(--text);
}
.cal-day.blank { background: transparent; }
.cal-day.sun { color: var(--primary); }
.cal-day.future { opacity: .38; }
.cal-day.present { background: #1c7c40; color: #fff; font-weight: 700; }
.cal-day.partial { background: #e8a13a; color: #fff; font-weight: 700; }
.cal-day.today { outline: 2px solid var(--primary); outline-offset: -2px; font-weight: 700; }
.cal-legend { display: flex; gap: 16px; margin-top: 12px; font-size: .74rem; color: var(--muted); }
.cal-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.cal-legend .dot.present { background: #1c7c40; }
.cal-legend .dot.today { background: transparent; outline: 2px solid var(--primary); outline-offset: -2px; }

.copyright {
  text-align: center; color: var(--muted); font-size: .74rem;
  padding: 20px 12px 6px; margin-top: auto;
}
.empty { text-align: center; color: var(--muted); padding: 34px 12px; font-size: .87rem; }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.logo-preview { height: 60px; border-radius: 10px; margin-bottom: 10px; display: block; }

/* ============================================================
   Desktop layout (≥ 900px): sidebar navigation + wide content
   ============================================================ */
@media (min-width: 900px) {
  .app { max-width: none; box-shadow: none; }

  /* Bottom nav becomes a fixed left sidebar */
  .bottomnav {
    left: 0; top: 0; bottom: 0; transform: none;
    width: 250px; max-width: none;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 18px 14px;
    border-top: 0; border-right: 1px solid var(--line);
    z-index: 30;
  }
  .nav-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px 22px; margin-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }
  .nav-brand img { width: auto; max-width: 140px; height: 38px; border-radius: 10px; object-fit: contain; background: #fff; padding: 2px 4px; }
  .nav-brand .mark {
    width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex: none;
  }
  .nav-brand b { font-size: .95rem; color: var(--text); line-height: 1.25; }
  .bottomnav a {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 13px;
    font-size: .92rem; padding: 12px 14px; border-radius: 10px;
  }
  .bottomnav a:hover { background: var(--bg); }
  .bottomnav a.on { background: var(--primary-light); position: relative; }
  .bottomnav a.on::before {
    content: ""; position: absolute; left: -14px; top: 20%; bottom: 20%;
    width: 4px; border-radius: 0 4px 4px 0; background: var(--primary);
  }
  .bottomnav a .ico { font-size: 1.15rem; width: 22px; text-align: center; }
  .bottomnav .addico {
    width: auto; height: auto; margin-top: 0; border-radius: 0;
    background: transparent; color: inherit; box-shadow: none; font-size: 1.3rem;
  }
  .navadd.on .addico, .navadd .addico { color: inherit; }

  /* Profile block pinned to the sidebar bottom */
  .nav-user {
    display: flex; align-items: center; gap: 10px;
    margin-top: auto; padding: 14px 10px 6px;
    border-top: 1px solid var(--line);
  }
  .nav-avatar {
    font-size: 2rem; color: var(--primary); line-height: 1; flex: none;
    display: flex; align-items: center;
  }
  .nav-user-meta { flex: 1; min-width: 0; display: block; }
  .nav-user-meta b { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-user-meta small { display: block; font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-logout {
    width: 34px; height: 34px; flex: none; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); background: var(--primary-light); text-decoration: none; font-size: .85rem;
  }
  .nav-logout:hover { background: var(--primary); color: #fff; }

  /* Top bar & content shift right of the sidebar */
  .topbar {
    margin-left: 250px; padding: 18px 36px;
    background: linear-gradient(120deg, #d3423e 0%, var(--primary) 45%, #8f1414 100%);
  }
  .topbar h1 { font-size: 1.2rem; letter-spacing: .01em; }
  .topbar-logo, .topbar-logo-mark { display: none; } /* brand lives in sidebar */
  .content {
    /* center the 960px column in the area right of the 250px sidebar */
    margin-left: calc(250px + max(0px, (100vw - 250px - 960px) / 2));
    padding: 30px 36px 48px;
    max-width: 960px; width: calc(100vw - 250px);
  }

  /* Wider grids */
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .tile { padding: 20px 18px; }
  .tile .num { font-size: 1.7rem; }
  .tico { width: 50px; height: 50px; font-size: 1.2rem; }
  .card { padding: 22px 24px; }
  .card h2 { font-size: 1rem; }
  .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .list-grid .emp-item { margin-bottom: 0; }
  .emp-item:hover, .tile:hover { box-shadow: 0 4px 18px rgba(20,24,31,.13); }

  /* Detail lists in two columns */
  .dl { grid-template-columns: 1fr 1fr; column-gap: 48px; }

  /* Big employee form: cards side by side */
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  .form-grid > .btn { grid-column: 1 / -1; justify-self: center; width: 340px; }

  /* Buttons don't need to be full-width bars on desktop */
  .btn { max-width: 420px; margin-left: auto; margin-right: auto; }
  .btn:hover { background: var(--primary-dark); }
  .btn-outline:hover, .btn-ghost:hover { background: var(--primary); color: #fff; }
  .btn-danger:hover { background: #c0392b; color: #fff; border-color: #c0392b; }
  .btn-sm { width: auto; }

  /* Auth screens: centered card on white */
  .app:has(.auth) {
    align-items: center; justify-content: center;
    background: #fff;
  }
  .auth {
    min-height: auto; width: 100%; max-width: 440px; margin: 48px auto;
    background: var(--card); border-radius: 24px;
    border: 1px solid var(--line);
    box-shadow: 0 10px 34px rgba(20, 24, 31, .08);
    padding: 44px 40px;
  }

  .hero .avatar { width: 96px; height: 96px; }

  /* Modal becomes a centered dialog on desktop */
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 22px; max-width: 420px; padding: 10px 28px 26px; }
}

@media print {
  .topbar, .bottomnav, .btn, .tabs { display: none !important; }
  body, .app { background: #fff; box-shadow: none; }
  .content { padding: 0; margin: 0; }
}
