/* ============================================================
   BCM HR — Portal (employee · manager · HR · owner)
   Depends on style.css for design tokens, fonts and buttons.
   ============================================================ */

body.portal {
  background:
    radial-gradient(900px 500px at 100% -10%, var(--g-50), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, #e8f6ee, transparent 60%),
    var(--paper);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Auth (login) ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-side {
  position: relative; overflow: hidden; color: #eafff3;
  background: var(--grad-brand); padding: clamp(28px, 5vw, 64px);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side::after { content:""; position:absolute; inset:0; background: radial-gradient(600px 260px at 80% 0%, rgba(163,230,53,.4), transparent), radial-gradient(500px 300px at 0% 100%, rgba(45,212,191,.35), transparent); }
.auth-side > * { position: relative; z-index: 1; }
.auth-side .brand { color: #fff; }
.auth-side .brand b { color: var(--lime); }
.auth-hero h1 { color: #fff; font-size: clamp(1.7rem, 3vw, 2.6rem); }
.auth-hero p { color: #d6f5e2; max-width: 42ch; }
.auth-points { display: grid; gap: .8rem; margin-top: 1.4rem; }
.auth-points li { display: flex; gap: .7rem; align-items: center; }
.auth-points .ck { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.auth-points .ck svg { width: 15px; height: 15px; }
.auth-foot { color: #bfe9cf; font-size: .85rem; }

.auth-main { display: grid; place-items: center; padding: clamp(24px, 4vw, 56px); }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { font-size: 1.7rem; margin-bottom: .3rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1.6rem; }
.auth-tabs { display: flex; gap: .4rem; background: var(--g-50); padding: 4px; border-radius: 999px; margin-bottom: 1.4rem; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: .6rem; border-radius: 999px; font-family: var(--font-body); font-weight: 700; color: var(--g-700); cursor: pointer; transition: .2s; }
.auth-tabs button.active { background: #fff; box-shadow: var(--shadow-sm); color: var(--g-600); }
.demo-creds { margin-top: 1.2rem; padding: .9rem 1rem; border: 1px dashed var(--g-300); border-radius: 12px; background: var(--g-50); font-size: .85rem; }
.demo-creds b { color: var(--g-700); }
.demo-creds button { border:0; background:var(--white); border:1px solid var(--line); border-radius:8px; padding:.25rem .55rem; cursor:pointer; font-size:.8rem; font-weight:600; color:var(--g-700); margin-inline-start:.3rem; }
.demo-creds .row { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding:.25rem 0; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.input, .field input, .field select, .field textarea {
  width: 100%; font-family: var(--font-body); font-size: .98rem; color: var(--ink);
  background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--g-400); box-shadow: var(--ring); }
.field.invalid input, .field.invalid select { border-color: #dc2626; }
.field .err { color: #dc2626; font-size: .8rem; margin-top: .3rem; display: none; }
.field.invalid .err { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.input-group { position: relative; }
.input-group .toggle-pw { position: absolute; inset-inline-end: 10px; inset-block-start: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; color: var(--muted); }

/* ---------- App shell ---------- */
.app-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--g-950); color: #cfeede; padding: 1.1rem; display: flex; flex-direction: column; gap: .3rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: #fff; margin-bottom: 1.2rem; padding: .3rem; }
.sidebar .brand b { color: var(--lime); }
.side-label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #6f9683; margin: 1rem .6rem .3rem; }
html[dir="rtl"] .side-label { letter-spacing: 0; }
.side-link {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 12px;
  color: #b8dac8; font-weight: 600; font-size: .95rem; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: start;
  transition: background .2s, color .2s;
}
.side-link svg { width: 20px; height: 20px; flex: none; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: var(--grad-brand); color: #fff; box-shadow: 0 10px 22px -12px rgba(21,128,61,.8); }
.side-link .count { margin-inline-start: auto; background: var(--lime); color: var(--g-900); font-size: .72rem; font-weight: 800; padding: .05rem .45rem; border-radius: 999px; }
.side-user { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: .6rem; }
.side-user .av { width: 38px; height: 38px; border-radius: 50%; background: var(--grad-lime); color: var(--g-900); display: grid; place-items: center; font-weight: 800; flex: none; }
.side-user .meta { min-width: 0; flex: 1; }
.side-user .meta b { display: block; font-size: .88rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .meta small { color: #8fb9a3; }
.side-user .logout { background: rgba(255,255,255,.06); border: 0; color: #cfeede; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.side-user .logout:hover { background: #dc2626; color: #fff; }

/* ---------- Main area ---------- */
.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(246,250,247,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); padding: .9rem clamp(16px, 3vw, 32px);
  display: flex; align-items: center; gap: 1rem;
}
.app-topbar h1 { font-size: 1.3rem; margin: 0; }
.app-topbar .sub { color: var(--muted); font-size: .85rem; margin: 0; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .6rem; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--white); cursor: pointer; display: grid; place-items: center; color: var(--ink-soft); position: relative; }
.icon-btn:hover { border-color: var(--g-300); color: var(--g-700); }
.icon-btn .dot { position: absolute; top: 9px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; border: 2px solid var(--white); }
.menu-btn { display: none; }

.app-content { padding: clamp(16px, 3vw, 32px); display: grid; gap: clamp(16px, 2.4vw, 24px); }
.app-view { display: grid; gap: clamp(16px, 2.4vw, 24px); animation: viewin .4s cubic-bezier(.2,.7,.3,1); }
@keyframes viewin { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform:none; } }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 2vw, 20px); }
.kpi {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem;
  position: relative; overflow: hidden;
}
.kpi .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--g-100); color: var(--g-700); margin-bottom: .8rem; }
.kpi .ic svg { width: 22px; height: 22px; }
.kpi .val { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; line-height: 1; }
.kpi .lbl { color: var(--muted); font-size: .88rem; margin-top: .3rem; }
.kpi .trend { font-size: .8rem; font-weight: 700; margin-top: .5rem; display: inline-flex; align-items: center; gap: .25rem; }
.kpi .trend.up { color: var(--g-600); } .kpi .trend.down { color: #dc2626; }

/* ---------- Panels ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 1.1rem; }
.panel-head .sub { color: var(--muted); font-size: .82rem; margin: 0; }
.panel-head .actions { margin-inline-start: auto; display: flex; gap: .5rem; }
.panel-body { padding: 1.1rem 1.3rem; }
.panel-body.flush { padding: 0; }
.cols-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: clamp(16px, 2.4vw, 24px); align-items: start; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .85rem 1.1rem; text-align: start; white-space: nowrap; }
table.data thead th { background: var(--g-50); color: var(--muted); font-weight: 700; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
html[dir="rtl"] table.data thead th { letter-spacing: 0; }
table.data tbody tr { border-bottom: 1px solid var(--line); transition: background .15s; }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: var(--g-50); }
.cell-user { display: flex; align-items: center; gap: .6rem; }
.cell-user .av { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.cell-user b { display: block; }
.cell-user small { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; }
.badge .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--g-100); color: var(--g-700); }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.danger { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #e0f2fe; color: #0369a1; }
.badge.muted { background: var(--paper-2); color: var(--muted); }

/* ---------- Clock-in widget ---------- */
.clock-card { text-align: center; }
.clock-time { font-family: var(--font-display); font-weight: 800; font-size: 3rem; line-height: 1; letter-spacing: -.02em; }
.clock-date { color: var(--muted); margin-bottom: 1rem; }
.clock-status { display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .9rem; border-radius: 999px; font-weight: 700; font-size: .85rem; margin-bottom: 1.2rem; }
.geo-box { display: flex; align-items: center; gap: .6rem; justify-content: center; font-size: .82rem; color: var(--muted); margin-top: .8rem; }
.geo-box .pin { width: 10px; height: 10px; border-radius: 50%; background: var(--g-400); box-shadow: 0 0 0 4px var(--g-100); }
.geo-box.out .pin { background: #ef4444; box-shadow: 0 0 0 4px #fee2e2; }
.clock-btns { display: flex; gap: .6rem; justify-content: center; }

/* mini geofence map */
.mini-map { position: relative; height: 150px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-top: 1rem;
  background: linear-gradient(180deg,#e9f6ee,#f6faf7); }
.mini-map .g { position:absolute; inset:0; background-image: linear-gradient(var(--g-100) 1px,transparent 1px),linear-gradient(90deg,var(--g-100) 1px,transparent 1px); background-size:24px 24px; opacity:.7; }
.mini-map .zone { position:absolute; inset-block-start:30%; inset-inline-start:32%; width:90px; height:70px; border:2px dashed var(--g-500); border-radius:14px; background:rgba(34,197,94,.12); }
.mini-map .me { position:absolute; inset-block-start:42%; inset-inline-start:46%; width:16px; height:16px; border-radius:50%; background:var(--g-600); border:3px solid #fff; box-shadow:var(--shadow); }
.mini-map .me.out { background:#ef4444; inset-inline-start:74%; inset-block-start:18%; }

/* ---------- Timeline / records ---------- */
.timeline { position: relative; padding-inline-start: 1.4rem; }
.timeline::before { content:""; position:absolute; inset-block:6px; inset-inline-start:5px; width:2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 1.2rem; }
.tl-item::before { content:""; position:absolute; inset-inline-start:-1.4rem; inset-block-start:4px; width:12px; height:12px; border-radius:50%; background: var(--g-500); border:2px solid var(--white); box-shadow: 0 0 0 3px var(--g-100); }
.tl-item .when { font-size:.78rem; color: var(--muted); }
.tl-item .what { font-weight:600; }
.tl-item .note { color: var(--ink-soft); font-size:.92rem; }
.tl-tag { font-size:.72rem; font-weight:700; padding:.1rem .5rem; border-radius:999px; background:var(--g-100); color:var(--g-700); }

/* progress bar */
.bar { height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--grad-lime); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.open { display: grid; place-items: center; }
.modal .backdrop { position: absolute; inset: 0; background: rgba(5,32,21,.5); backdrop-filter: blur(4px); animation: viewin .2s; }
.modal .dialog {
  position: relative; width: min(560px, 92vw); max-height: 88vh; overflow-y: auto;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 1.5rem;
  animation: pop .3s cubic-bezier(.2,.7,.3,1);
}
@keyframes pop { from { opacity:0; transform: translateY(16px) scale(.98); } to { opacity:1; transform:none; } }
.modal .dialog h3 { margin: 0 0 .2rem; }
.modal .dialog .sub { color: var(--muted); margin: 0 0 1.2rem; font-size: .9rem; }
.modal .x { position: absolute; inset-block-start: 1rem; inset-inline-end: 1rem; border: 0; background: var(--paper-2); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.4rem; }

/* ---------- Empty / toast ---------- */
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty .ic { width: 60px; height: 60px; border-radius: 18px; background: var(--g-50); color: var(--g-400); display: grid; place-items: center; margin: 0 auto 1rem; }

#toast-wrap { position: fixed; inset-block-end: 1.2rem; inset-inline-start: 1.2rem; z-index: 200; display: grid; gap: .6rem; }
.toast {
  background: var(--g-900); color: #fff; padding: .8rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .92rem; animation: pop .3s;
  max-width: 340px;
}
.toast .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.toast.ok .ic { background: var(--g-500); } .toast.err .ic { background: #dc2626; } .toast.info .ic { background: #0ea5e9; }

/* segmented control */
.seg { display: inline-flex; background: var(--paper-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: .45rem .9rem; border-radius: 8px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--white); color: var(--g-700); box-shadow: var(--shadow-sm); }

.app-lang { display: inline-flex; background: var(--g-100); border-radius: 999px; padding: 3px; }
.app-lang button { border: 0; background: transparent; cursor: pointer; font-weight: 700; font-size: .82rem; color: var(--g-700); padding: .3rem .65rem; border-radius: 999px; }
.app-lang button.active { background: var(--white); color: var(--g-600); box-shadow: var(--shadow-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; z-index: 90;
    transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.7,.3,1);
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); } /* inline-start = right in RTL */
  html[dir="rtl"] .sidebar.open { transform: none; }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(5,32,21,.5); z-index: 80; display: none; }
  .sidebar-scrim.show { display: block; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Smart Assistant (chatbot)
   ============================================================ */
.chat-fab {
  position: fixed; inset-block-end: 1.4rem; inset-inline-end: 1.4rem; z-index: 150;
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--grad-brand); color: #fff; display: grid; place-items: center;
  box-shadow: 0 16px 34px -12px rgba(21,128,61,.8); transition: transform .25s, box-shadow .25s;
}
.chat-fab:hover { transform: translateY(-3px) scale(1.04); }
.chat-fab svg { width: 28px; height: 28px; }
.chat-fab .ping { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--g-300); animation: chatping 2.4s ease-out infinite; }
@keyframes chatping { 0% { transform: scale(1); opacity:.7; } 100% { transform: scale(1.5); opacity:0; } }
.chat-fab .badge-n { position: absolute; inset-block-start: -2px; inset-inline-end: -2px; background: var(--lime); color: var(--g-900); font-size: .7rem; font-weight: 800; min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; border: 2px solid var(--paper); }

.chat-panel {
  position: fixed; inset-block-end: 1.4rem; inset-inline-end: 1.4rem; z-index: 160;
  width: min(380px, calc(100vw - 2rem)); height: min(620px, calc(100vh - 3rem));
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); display: none; flex-direction: column; overflow: hidden;
  transform-origin: bottom; }
.chat-panel.open { display: flex; animation: pop .3s cubic-bezier(.2,.7,.3,1); }

.chat-head { background: var(--grad-brand); color: #fff; padding: 1rem 1.1rem; display: flex; align-items: center; gap: .7rem; position: relative; overflow: hidden; }
.chat-head::after { content:""; position:absolute; inset:0; background: radial-gradient(300px 120px at 90% 0%, rgba(163,230,53,.4), transparent); }
.chat-head > * { position: relative; z-index: 1; }
.chat-head .bot-ava { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.chat-head .bot-ava svg { width: 24px; height: 24px; }
.chat-head .meta { flex: 1; min-width: 0; }
.chat-head .meta b { display: block; font-family: var(--font-display); }
.chat-head .meta small { color: #d6f5e2; display: inline-flex; align-items: center; gap: .35rem; }
.chat-head .meta small .live { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(163,230,53,.3); }
.chat-head .close { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.chat-head .close:hover { background: rgba(255,255,255,.28); }

.chat-body { flex: 1; overflow-y: auto; padding: 1rem; background: linear-gradient(180deg, var(--g-50), var(--white) 120px); display: flex; flex-direction: column; gap: .8rem; }
.msg { display: flex; gap: .55rem; align-items: flex-end; max-width: 88%; }
.msg .av { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--grad-brand); color: #fff; }
.msg .av svg { width: 17px; height: 17px; }
.msg .bubble { padding: .7rem .9rem; border-radius: 16px; font-size: .92rem; line-height: 1.55; }
.msg.bot .bubble { background: var(--white); border: 1px solid var(--line); border-start-start-radius: 4px; box-shadow: var(--shadow-sm); }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .bubble { background: var(--grad-brand); color: #fff; border-end-end-radius: 4px; }
.msg.user .av { background: var(--g-100); color: var(--g-700); }
.msg .bubble b { font-weight: 700; }
.msg .bubble .data { display: inline-block; background: var(--g-100); color: var(--g-700); font-weight: 700; padding: 0 .35rem; border-radius: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .2rem; }
.chip { background: var(--white); border: 1px solid var(--g-300); color: var(--g-700); font-family: var(--font-body); font-weight: 600; font-size: .82rem; padding: .4rem .8rem; border-radius: 999px; cursor: pointer; transition: background .2s, transform .15s; }
.chip:hover { background: var(--g-100); transform: translateY(-1px); }

.chat-typing { display: flex; gap: 4px; padding: .8rem .9rem; background: var(--white); border: 1px solid var(--line); border-radius: 16px; border-start-start-radius: 4px; width: fit-content; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--g-300); animation: typing 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .2s; } .chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat-input-row { padding: .7rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; background: var(--white); }
.chat-input { flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: .7rem 1rem; font-family: var(--font-body); font-size: .92rem; color: var(--ink); }
.chat-input:focus { outline: none; border-color: var(--g-400); box-shadow: var(--ring); }
.chat-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--grad-brand); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .2s; }
.chat-send:hover { transform: scale(1.06); }
.chat-send svg { width: 19px; height: 19px; }
html[dir="rtl"] .chat-send svg { transform: scaleX(-1); }

@media (max-width: 520px) {
  .chat-panel { inset: .6rem; width: auto; height: auto; }
}

/* ============================================================
   Face + location verification
   ============================================================ */
.cam-frame {
  position: relative; width: 200px; height: 200px; border-radius: 50%;
  margin: 0 auto 1.1rem; overflow: hidden; background: var(--g-950);
  display: grid; place-items: center; box-shadow: 0 0 0 6px var(--g-100);
}
.cam-frame video { width: 100%; height: 100%; object-fit: cover; display: none; }
.cam-frame.live video { display: block; }
.cam-frame .sil { width: 108px; height: 108px; color: #2f5d46; display: none; }
.cam-frame.sim .sil { display: block; }
.scan-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--lime);
  animation: vspin 1.1s linear infinite; pointer-events: none;
}
.cam-frame.done .scan-ring { animation: none; border-color: var(--g-400); }
.scan-line {
  position: absolute; inset-inline: 20px; height: 2px; top: 18%;
  background: linear-gradient(90deg, transparent, var(--lime), transparent);
  animation: vscan 1.6s ease-in-out infinite; pointer-events: none;
}
.cam-frame.done .scan-line { display: none; }
@keyframes vspin { to { transform: rotate(360deg); } }
@keyframes vscan { 0%, 100% { top: 14%; } 50% { top: 84%; } }

.v-steps { display: grid; gap: .6rem; margin: .4rem 0 .2rem; }
.v-step {
  display: flex; gap: .7rem; align-items: center;
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  transition: border-color .3s, background .3s;
}
.v-step .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--g-100); color: var(--g-700); flex: none; }
.v-step .ic svg { width: 18px; height: 18px; }
.v-step b { display: block; font-size: .92rem; }
.v-step small { color: var(--muted); }
.v-step.ok { border-color: var(--g-300); background: var(--g-50); }
.v-step.fail { border-color: #fecaca; background: #fef2f2; }

.proof-img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); }
.proof-thumb { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; border: 2px solid var(--g-200); cursor: pointer; vertical-align: middle; transition: transform .15s; }
.proof-thumb:hover { transform: scale(1.15); }

/* ============================================================
   Charts + announcements
   ============================================================ */
.chart-canvas { width: 100%; height: 220px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .8rem; font-size: .82rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.ann-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.1rem; background: var(--white); margin-bottom: .8rem; transition: box-shadow .2s, border-color .2s; }
.ann-card:hover { border-color: var(--g-300); box-shadow: var(--shadow-sm); }
.ann-card:last-child { margin-bottom: 0; }
.ann-card h4 { margin: 0 0 .15rem; font-size: 1.02rem; }
.ann-card .meta { color: var(--muted); font-size: .78rem; margin-bottom: .45rem; }
.ann-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

/* ============================================================
   Recruitment pipeline (ATS)
   ============================================================ */
.pipe-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: 230px;
  gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: thin;
}
.pipe-col { background: var(--paper-2); border-radius: 14px; padding: 10px; min-height: 180px; }
.pipe-col h5 {
  margin: 0 0 .7rem; font-size: .85rem; display: flex; align-items: center; justify-content: space-between;
  color: var(--ink-soft); padding: 0 .2rem;
}
.pipe-col h5 .cnt { background: var(--white); border: 1px solid var(--line); border-radius: 999px; font-size: .72rem; padding: .05rem .5rem; color: var(--muted); }
.pipe-col.win { background: var(--g-100); }
.pipe-col.win h5 { color: var(--g-700); }
.pipe-col.lose { background: #fef2f2; }
.pipe-col.lose h5 { color: #b91c1c; }
.cand-card {
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; margin-bottom: .6rem; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.cand-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cand-card b { display: block; font-size: .9rem; }
.cand-card small { color: var(--muted); font-size: .76rem; display: block; }
.cand-card .stars { color: #f59e0b; font-size: .78rem; letter-spacing: 2px; margin: .25rem 0 .45rem; }
html[dir="rtl"] .cand-card .stars { letter-spacing: 0; }
.cand-card .cc-actions { display: flex; gap: .35rem; }
.cc-btn { padding: .3rem .6rem !important; font-size: .74rem !important; border-radius: 8px !important; }

/* ============================================================
   Notifications panel
   ============================================================ */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -6px; inset-inline-end: -6px;
  background: #ef4444; color: #fff; font-size: .68rem; font-weight: 800;
  min-width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center;
  border: 2px solid var(--paper); padding: 0 4px;
}
.notif-panel {
  position: absolute; top: calc(100% + 10px); inset-inline-end: 0; z-index: 60;
  width: min(330px, 86vw); max-height: 400px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); animation: pop .25s cubic-bezier(.2,.7,.3,1);
}
.np-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); font-family: var(--font-display); }
.notif-item { display: flex; gap: .7rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); align-items: flex-start; }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: var(--g-50); }
.notif-item .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--g-100); color: var(--g-700); display: grid; place-items: center; flex: none; }
.notif-item .ic svg { width: 17px; height: 17px; }
.notif-item .tx { min-width: 0; }
.notif-item .tx b { display: block; font-size: .87rem; }
.notif-item .tx small { display: block; color: var(--muted); font-size: .78rem; }
.notif-item .tx small.when { font-size: .72rem; margin-top: .15rem; }

/* ============================================================
   Performance goals
   ============================================================ */
.goal-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .95rem 1.1rem; background: var(--white); margin-bottom: .8rem; transition: border-color .2s, box-shadow .2s; }
.goal-card:hover { border-color: var(--g-300); box-shadow: var(--shadow-sm); }
.goal-card:last-child { margin-bottom: 0; }
.goal-card.done { background: var(--g-50); border-color: var(--g-200); }
.goal-card .g-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .15rem; }
.goal-card .g-head b { font-size: .97rem; }
.goal-card small { color: var(--muted); font-size: .78rem; }
.goal-ctrl { display: flex; gap: .4rem; }

/* ============================================================
   Dark mode — re-maps the design tokens, everything inherits
   ============================================================ */
:root[data-theme="dark"] {
  --ink: #e8f5ee;
  --ink-soft: #c3ddd0;
  --muted: #8fae9e;
  --line: #1d3a2b;
  --paper: #071710;
  --paper-2: #0b2118;
  --white: #0e2a1e;
  --g-50: #102c20;
  --g-100: #16382a;
  --bg: #071710;
  --surface: #0e2a1e;
  --text: #e8f5ee;
  --text-muted: #8fae9e;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 60px -24px rgba(0,0,0,.7);
}
:root[data-theme="dark"] body.portal {
  background:
    radial-gradient(900px 500px at 100% -10%, #0d2b1f, transparent 60%),
    radial-gradient(700px 500px at -10% 110%, #0a2419, transparent 60%),
    var(--paper);
}
:root[data-theme="dark"] .app-topbar { background: rgba(7,23,16,.85); }
:root[data-theme="dark"] .kpi,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .goal-card,
:root[data-theme="dark"] .ann-card,
:root[data-theme="dark"] .cand-card,
:root[data-theme="dark"] .shift-card,
:root[data-theme="dark"] .v-step,
:root[data-theme="dark"] .notif-panel,
:root[data-theme="dark"] .modal .dialog,
:root[data-theme="dark"] .chat-panel { background: var(--surface); }
:root[data-theme="dark"] table.data thead th { background: var(--paper-2); }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .input,
:root[data-theme="dark"] .chat-input { background: var(--paper-2); color: var(--ink); }
:root[data-theme="dark"] .pipe-col { background: var(--paper-2); }
:root[data-theme="dark"] .pipe-col.lose { background: #2a1414; }
:root[data-theme="dark"] .chat-body { background: linear-gradient(180deg, var(--paper-2), var(--surface) 120px); }
:root[data-theme="dark"] .msg.bot .bubble { background: var(--paper-2); }
:root[data-theme="dark"] .chart-canvas { filter: brightness(1.1); }
:root[data-theme="dark"] .badge.warn { background: #3a2c0d; color: #fbbf24; }
:root[data-theme="dark"] .badge.danger { background: #3a1616; color: #fca5a5; }
:root[data-theme="dark"] .badge.info { background: #0c2c3d; color: #7dd3fc; }
:root[data-theme="dark"] .map-card,
:root[data-theme="dark"] .mini-map { background: linear-gradient(180deg,#0c2419,#071710); }
:root[data-theme="dark"] .payslip { background: var(--surface); }

/* ============================================================
   Command palette (Ctrl/⌘ + K)
   ============================================================ */
.pal-trigger {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: .55rem .8rem; color: var(--muted); font-family: var(--font-body); font-size: .86rem;
  transition: border-color .2s, color .2s; max-width: 260px;
}
.pal-trigger:hover { border-color: var(--g-300); color: var(--g-700); }
.pal-trigger svg { width: 16px; height: 16px; flex: none; }
.pal-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-trigger kbd {
  font-family: var(--font-body); font-size: .68rem; font-weight: 700; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 6px; padding: .1rem .35rem; color: var(--muted); flex: none;
}
@media (max-width: 980px) { .pal-trigger span, .pal-trigger kbd { display: none; } .pal-trigger { padding: .55rem; } }

.pal-wrap { position: fixed; inset: 0; z-index: 180; display: grid; place-items: start center; padding-top: 12vh; }
.pal-backdrop { position: absolute; inset: 0; background: rgba(5,32,21,.5); backdrop-filter: blur(4px); }
.pal {
  position: relative; width: min(560px, 92vw); background: var(--white);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop .25s cubic-bezier(.2,.7,.3,1);
}
.pal-input-row { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.pal-input-row svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.pal-input { flex: 1; border: 0; background: none; outline: none; font-family: var(--font-body); font-size: 1.02rem; color: var(--ink); }
.pal-kbd { font-family: var(--font-body); font-size: .68rem; font-weight: 700; background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px; padding: .15rem .4rem; color: var(--muted); }
.pal-list { max-height: 52vh; overflow-y: auto; padding: .5rem; }
.pal-group { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: .6rem .8rem .3rem; }
html[dir="rtl"] .pal-group { letter-spacing: 0; }
.pal-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-radius: 11px; cursor: pointer; }
.pal-item .ic { width: 32px; height: 32px; border-radius: 9px; background: var(--g-100); color: var(--g-700); display: grid; place-items: center; flex: none; }
.pal-item .ic svg { width: 17px; height: 17px; }
.pal-item .tx { min-width: 0; }
.pal-item .tx b { display: block; font-size: .93rem; font-weight: 600; }
.pal-item .tx small { color: var(--muted); font-size: .78rem; }
.pal-item.sel, .pal-item:hover { background: var(--g-50); }
.pal-item.sel .ic { background: var(--grad-brand); color: #fff; }
.pal-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* ============================================================
   Shifts
   ============================================================ */
.shift-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.shift-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.1rem; background: var(--white); }
.shift-card .sh-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.shift-card .sh-time { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; color: var(--g-600); }
.shift-card .sh-time span { color: var(--muted); font-weight: 400; }
.shift-card small { color: var(--muted); font-size: .78rem; }

/* ============================================================
   Company identity (white-label branding)
   ============================================================ */
.co-brand { align-items: center; gap: .7rem; }
.co-brand span b { display: block; font-family: var(--font-display); font-size: 1.02rem; line-height: 1.2; }
.co-brand span small { display: block; font-family: var(--font-body); font-weight: 600; font-size: .6rem; letter-spacing: .14em; color: var(--muted); margin-top: 1px; }
html[dir="rtl"] .co-brand span small { letter-spacing: 0; }
.sidebar .co-brand span b { color: #fff; }
.sidebar .co-brand span small { color: var(--g-300); }
.auth-side .co-brand span b { color: #fff; }
.auth-side .co-brand span small { color: #bfe9cf; }
.brand .mark.logo { background: #fff; padding: 4px; box-shadow: var(--shadow-sm); overflow: hidden; }
.brand .mark.logo img { width: 100%; height: 100%; object-fit: contain; }

.logo-row { display: flex; gap: 1.1rem; align-items: flex-start; }
.logo-box {
  width: 104px; height: 104px; border-radius: 18px; flex: none;
  border: 2px dashed var(--line); background: var(--paper-2);
  display: grid; place-items: center; overflow: hidden;
}
.logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 8px; background: #fff; }
.logo-box .ph { color: var(--g-300); }
.logo-box .ph svg { width: 34px; height: 34px; }

.color-row { display: flex; align-items: center; gap: .7rem; }
.color-row input[type="color"] { width: 52px; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); cursor: pointer; }
.swatches { display: flex; gap: .35rem; }
.swatches i { width: 24px; height: 24px; border-radius: 7px; cursor: pointer; border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--line); transition: transform .15s; }
.swatches i:hover { transform: scale(1.15); }

/* Subscription */
.sub-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; background: linear-gradient(160deg, var(--g-50), var(--white)); }
.sub-card .sc-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.plan-chip { background: var(--grad-brand); color: #fff; font-weight: 800; font-size: .8rem; padding: .3rem .8rem; border-radius: 999px; }
.sub-card .sc-days { font-family: var(--font-display); color: var(--muted); font-size: .9rem; }
.sub-card .sc-days b { font-size: 2.2rem; color: var(--g-600); line-height: 1; }
.sub-card .sc-dates { display: flex; flex-direction: column; gap: .2rem; margin-top: .7rem; font-size: .84rem; color: var(--muted); }

.sub-banner {
  display: flex; align-items: center; gap: .8rem; padding: .9rem 1.2rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .92rem; margin-bottom: .2rem;
}
.sub-banner svg { width: 20px; height: 20px; flex: none; }
.sub-banner span { flex: 1; }
.sub-banner.soon { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.sub-banner.expired { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
:root[data-theme="dark"] .sub-banner.soon { background: #3a2c0d; color: #fbbf24; border-color: #57410f; }
:root[data-theme="dark"] .sub-banner.expired { background: #3a1616; color: #fca5a5; border-color: #5a1f1f; }

/* Payslip company header */
.ps-co { display: flex; align-items: center; gap: .8rem; padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 2px solid var(--g-100); }
.ps-co img { width: 46px; height: 46px; object-fit: contain; border-radius: 10px; background: #fff; }
.ps-co b { display: block; font-family: var(--font-display); font-size: 1rem; }
.ps-co small { color: var(--muted); font-size: .76rem; }

:root[data-theme="dark"] .sub-card { background: linear-gradient(160deg, var(--paper-2), var(--surface)); }
:root[data-theme="dark"] .logo-box { background: var(--paper-2); }

/* ============================================================
   Security UI — captcha, password strength, activation code
   ============================================================ */
.captcha-field .captcha-row { display: flex; align-items: center; gap: .6rem; }
.captcha-q {
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  background: var(--g-100); color: var(--g-700); padding: .6rem 1rem; border-radius: 12px;
  letter-spacing: .08em; user-select: none; flex: none;
}
.captcha-field .captcha-row input { flex: 1; }

.pw-meter { height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; margin-top: .45rem; }
.pw-meter > span { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .25s, background .25s; }
.pw-meter > span.s0, .pw-meter > span.s1 { background: #dc2626; }
.pw-meter > span.s2 { background: #f59e0b; }
.pw-meter > span.s3 { background: #3b82f6; }
.pw-meter > span.s4 { background: var(--g-500); }

.act-code {
  font-family: var(--font-display); font-weight: 800; font-size: 2rem;
  letter-spacing: .32em; color: var(--g-700); background: var(--white);
  border: 2px dashed var(--g-400); border-radius: 14px;
  padding: .7rem 1rem; text-align: center; margin: .6rem 0 .3rem;
}
html[dir="rtl"] .act-code { letter-spacing: .32em; direction: ltr; }
.act-input {
  text-align: center; font-family: var(--font-display); font-weight: 800;
  font-size: 1.6rem; letter-spacing: .3em; direction: ltr;
}
:root[data-theme="dark"] .act-code { background: var(--paper-2); }

/* ============================================================
   BCM HR v2 additions
   ============================================================ */
body.portal { color: var(--ink); }
.btn-sm { padding: .45rem .85rem; font-size: .85rem; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-link { background: none; border: 0; color: var(--g-600); font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.right { margin-inline-start: auto; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: .8rem; }
.hidden { display: none !important; }

/* ---------- Top loading bar (API activity) ---------- */
#net-bar { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 300; background: var(--grad-lime); transform: scaleX(0); transform-origin: 0 50%; transition: transform .3s ease, opacity .4s; opacity: 0; pointer-events: none; }
html[dir="rtl"] #net-bar { transform-origin: 100% 50%; }
#net-bar.on { opacity: 1; transform: scaleX(.7); transition: transform 3s cubic-bezier(.1,.6,.2,1), opacity .2s; }
#net-bar.done { opacity: 0; transform: scaleX(1); }

/* ---------- Auth: 3D scene on the brand side ---------- */
.auth-3d { position: relative; height: 230px; perspective: 900px; margin: 1.6rem 0; }
.cube { position: absolute; width: 90px; height: 90px; transform-style: preserve-3d; animation: cubeSpin 14s linear infinite; }
.cube.c1 { top: 20px; inset-inline-start: 10%; }
.cube.c2 { top: 110px; inset-inline-start: 46%; width: 60px; height: 60px; animation-duration: 10s; animation-direction: reverse; }
.cube.c3 { top: 10px; inset-inline-start: 70%; width: 46px; height: 46px; animation-duration: 8s; }
.cube i { position: absolute; inset: 0; border: 1px solid rgba(217,249,157,.55); background: linear-gradient(135deg, rgba(163,230,53,.22), rgba(45,212,191,.12)); backdrop-filter: blur(2px); }
.cube i:nth-child(1) { transform: translateZ(calc(var(--s, 45px))); }
.cube i:nth-child(2) { transform: rotateY(180deg) translateZ(var(--s, 45px)); }
.cube i:nth-child(3) { transform: rotateY(90deg) translateZ(var(--s, 45px)); }
.cube i:nth-child(4) { transform: rotateY(-90deg) translateZ(var(--s, 45px)); }
.cube i:nth-child(5) { transform: rotateX(90deg) translateZ(var(--s, 45px)); }
.cube i:nth-child(6) { transform: rotateX(-90deg) translateZ(var(--s, 45px)); }
.cube.c2 { --s: 30px; } .cube.c3 { --s: 23px; }
@keyframes cubeSpin { from { transform: rotateX(-20deg) rotateY(0); } to { transform: rotateX(-20deg) rotateY(360deg); } }
.auth-orbit { position: absolute; inset: 30px 18% auto auto; width: 180px; height: 180px; border-radius: 50%; border: 1px dashed rgba(255,255,255,.25); animation: vspin 30s linear infinite; }
.auth-orbit::after { content: ""; position: absolute; top: -6px; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 18px var(--lime); }
.auth-card .links { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; font-size: .9rem; }
.auth-alert { padding: .75rem 1rem; border-radius: 12px; font-size: .9rem; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.auth-alert.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.auth-alert.info { background: var(--g-50); color: var(--g-700); border: 1px solid var(--g-200); }
.auth-alert svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.demo-creds .row { justify-content: space-between; }
.demo-creds code { font-size: .78rem; direction: ltr; unicode-bidi: isolate; }
.secure-note { display: flex; align-items: center; gap: .45rem; justify-content: center; color: var(--muted); font-size: .78rem; margin-top: 1.2rem; }
.secure-note svg { width: 14px; height: 14px; color: var(--g-500); }

/* ---------- Tabs / toolbar ---------- */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; background: var(--paper-2); padding: 4px; border-radius: 14px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: .55rem 1rem; border-radius: 10px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted); white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; }
.tabs button.active { background: var(--white); color: var(--g-700); box-shadow: var(--shadow-sm); }
.tabs .cnt { background: var(--g-100); color: var(--g-700); border-radius: 999px; font-size: .72rem; padding: 0 .45rem; }
.toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.toolbar .input, .toolbar select { width: auto; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--ink); }

/* ---------- KPI cards with depth ---------- */
.kpi { transition: transform .35s cubic-bezier(.2,.7,.3,1), box-shadow .35s, border-color .35s; transform-style: preserve-3d; }
.kpi::after { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(74,222,128,.22), transparent 70%); transition: transform .5s; }
.kpi:hover { box-shadow: var(--shadow); border-color: var(--g-200); }
.kpi:hover::after { transform: scale(1.4); }
.kpi .val small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.kpi.accent { background: var(--grad-brand); color: #fff; border-color: transparent; }
.kpi.accent .lbl { color: #d6f5e2; } .kpi.accent .ic { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Skeleton loading ---------- */
.skel { position: relative; overflow: hidden; background: var(--paper-2); border-radius: 12px; min-height: 16px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: skel 1.2s infinite; }
@keyframes skel { to { transform: translateX(100%); } }
.skel-grid { display: grid; gap: 1rem; }
.skel-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.skel-kpis .skel { height: 120px; border-radius: var(--radius); }
.skel-panel { height: 260px; border-radius: var(--radius); }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; font-size: .92rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .tr { width: 44px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .25s; flex: none; }
.switch .tr::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start .25s; }
.switch input:checked + .tr { background: var(--g-500); }
.switch input:checked + .tr::after { inset-inline-start: 23px; }
.switch input:focus-visible + .tr { box-shadow: var(--ring); }

/* ---------- Range (goal progress) ---------- */
input[type="range"].range { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; background: var(--paper-2); outline: none; }
input[type="range"].range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--g-600); border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer; }
input[type="range"].range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--g-600); border: 3px solid #fff; cursor: pointer; }

/* ---------- Side drawer (details) ---------- */
.drawer { position: fixed; inset: 0; z-index: 110; }
.drawer .backdrop { position: absolute; inset: 0; background: rgba(5,32,21,.45); backdrop-filter: blur(3px); animation: viewin .2s; }
.drawer .sheet { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(480px, 100vw); background: var(--white); box-shadow: var(--shadow-lg); overflow-y: auto; padding: 1.4rem; animation: sheetIn .3s cubic-bezier(.2,.7,.3,1); }
@keyframes sheetIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
html[dir="rtl"] .drawer .sheet { animation-name: sheetInRtl; }
@keyframes sheetInRtl { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .55rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Profile hero ---------- */
.profile-hero { display: flex; align-items: center; gap: 1rem; padding: 1.3rem; border-radius: var(--radius); background: var(--grad-brand); color: #fff; position: relative; overflow: hidden; }
.profile-hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(400px 160px at 90% 0%, rgba(163,230,53,.35), transparent); }
.profile-hero > * { position: relative; z-index: 1; }
.profile-hero .big-av { width: 64px; height: 64px; border-radius: 20px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; }
.profile-hero h3 { color: #fff; margin: 0; }
.profile-hero p { margin: 0; color: #d6f5e2; }

/* ---------- 2FA + sessions ---------- */
.qr-box { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 170px; height: 170px; border-radius: 14px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--paper-2); border: 1px dashed var(--g-300); border-radius: 10px; padding: .5rem .8rem; letter-spacing: .12em; word-break: break-all; direction: ltr; }
.session-row { display: flex; gap: .8rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.session-row:last-child { border-bottom: 0; }
.session-row .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--g-100); color: var(--g-700); display: grid; place-items: center; flex: none; }
.session-row .ic svg { width: 19px; height: 19px; }
.session-row small { color: var(--muted); display: block; font-size: .78rem; }

/* ---------- Leave calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { font-size: .74rem; font-weight: 700; color: var(--muted); text-align: center; padding-bottom: .2rem; }
.cal .day { min-height: 64px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px; font-size: .78rem; background: var(--white); position: relative; }
.cal .day.off { background: var(--paper-2); color: var(--muted); }
.cal .day.today { border-color: var(--g-500); box-shadow: 0 0 0 2px var(--g-100); }
.cal .day .n { font-weight: 700; }
.cal .day .who { display: block; margin-top: 2px; background: var(--g-100); color: var(--g-700); border-radius: 6px; padding: 0 4px; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- CMS editor ---------- */
.cms-group { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 1rem; background: var(--white); }
.cms-group > summary { list-style: none; cursor: pointer; padding: .9rem 1.1rem; font-weight: 700; display: flex; align-items: center; gap: .6rem; background: var(--g-50); }
.cms-group > summary::-webkit-details-marker { display: none; }
.cms-group > summary .cnt { margin-inline-start: auto; font-size: .76rem; color: var(--muted); font-weight: 600; }
.cms-group[open] > summary { border-bottom: 1px solid var(--line); }
.cms-row { display: grid; grid-template-columns: 170px 1fr 1fr auto; gap: .7rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); align-items: start; }
.cms-row:last-child { border-bottom: 0; }
.cms-row .k { font-family: ui-monospace, Consolas, monospace; font-size: .76rem; color: var(--muted); word-break: break-all; padding-top: .55rem; direction: ltr; }
.cms-row textarea { width: 100%; min-height: 44px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; font-size: .9rem; background: var(--white); color: var(--ink); field-sizing: content; max-height: 220px; }
.cms-row textarea:focus { outline: none; border-color: var(--g-400); box-shadow: var(--ring); }
.cms-row textarea[lang="en"] { direction: ltr; }
.cms-row.dirty { background: #fffbeb; }
.cms-row.dirty .k::after { content: " •"; color: #d97706; font-weight: 800; }
.cms-savebar { position: sticky; bottom: 1rem; z-index: 15; display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-radius: 14px; background: var(--g-900); color: #fff; box-shadow: var(--shadow-lg); animation: pop .3s; }
.cms-savebar .grow { flex: 1; }
.faq-admin { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; background: var(--white); margin-bottom: .8rem; }
.faq-admin .head { display: flex; gap: .6rem; align-items: center; }
.faq-admin .head b { flex: 1; }
.faq-admin .body { color: var(--muted); font-size: .88rem; margin-top: .4rem; }
.faq-admin.unpub { opacity: .6; }
.order-btns { display: inline-flex; flex-direction: column; gap: 2px; }
.order-btns button { border: 1px solid var(--line); background: var(--white); border-radius: 6px; width: 26px; height: 20px; cursor: pointer; font-size: .7rem; line-height: 1; color: var(--muted); }
.order-btns button:hover { color: var(--g-700); border-color: var(--g-300); }
.rich-hint { font-size: .78rem; color: var(--muted); }
.rich-hint code { background: var(--paper-2); padding: 0 .3rem; border-radius: 4px; direction: ltr; unicode-bidi: isolate; }

/* ---------- Coming-soon (mobile app) card in the portal ---------- */
.app-soon { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: linear-gradient(120deg, #052015, #14532d); color: #eafff3; position: relative; overflow: hidden; }
.app-soon::after { content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(163,230,53,.35), transparent 70%); }
.app-soon .ph { width: 42px; height: 64px; border-radius: 10px; border: 2px solid rgba(255,255,255,.5); flex: none; display: grid; place-items: center; transform: rotate(-10deg); animation: phoneBob 5s ease-in-out infinite; }
.app-soon .ph svg { width: 20px; height: 20px; color: var(--lime); }
.app-soon b { display: block; color: #fff; }
.app-soon small { color: #9fc4b1; }
.app-soon .tag { margin-inline-start: auto; background: #f97316; color: #fff; font-size: .74rem; font-weight: 800; padding: .25rem .7rem; border-radius: 999px; position: relative; z-index: 1; white-space: nowrap; }
@keyframes phoneBob { 50% { transform: rotate(-10deg) translateY(-6px); } }

/* ---------- Clock widget extras ---------- */
.clock-ring { width: 150px; height: 150px; margin: .6rem auto 1rem; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--g-500) calc(var(--p, 0) * 1%), var(--paper-2) 0); position: relative; transition: --p 1s; }
.clock-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--white); }
.clock-ring > div { position: relative; text-align: center; }
.clock-ring b { display: block; font-family: "Sora", var(--font-display); font-size: 1.7rem; direction: ltr; }
.clock-ring small { color: var(--muted); font-size: .76rem; }
.geo-dist { font-size: .8rem; color: var(--muted); }
.mini-map .zone { inset: auto; left: 50%; top: 50%; width: 120px; height: 84px; border-radius: 50%; transform: translate(-50%, -50%); }
.mini-map .me { inset: auto; left: calc(50% + 12px); top: calc(50% - 8px); transform: translate(-50%, -50%); animation: mePulse 2.4s ease-in-out infinite; }
.mini-map .me.out { left: 84%; top: 24%; }
@keyframes mePulse { 50% { box-shadow: 0 0 0 8px rgba(34,197,94,.18); } }

/* ---------- Charts ---------- */
.chart-canvas.tall { height: 260px; }
.bar-list { display: grid; gap: .7rem; }
.bar-list .item { display: grid; grid-template-columns: 1fr auto; gap: .3rem .6rem; font-size: .88rem; }
.bar-list .item .bar { grid-column: 1 / -1; }

/* ---------- Dark mode for new parts ---------- */
:root[data-theme="dark"] .tabs { background: var(--paper-2); }
:root[data-theme="dark"] .tabs button.active { background: var(--surface); }
:root[data-theme="dark"] .drawer .sheet, :root[data-theme="dark"] .cms-group, :root[data-theme="dark"] .faq-admin, :root[data-theme="dark"] .cal .day { background: var(--surface); }
:root[data-theme="dark"] .cms-group > summary { background: var(--paper-2); }
:root[data-theme="dark"] .cms-row textarea, :root[data-theme="dark"] .toolbar .input, :root[data-theme="dark"] .toolbar select { background: var(--paper-2); color: var(--ink); }
:root[data-theme="dark"] .cms-row.dirty { background: #2a2208; }
:root[data-theme="dark"] .clock-ring::before { background: var(--surface); }
:root[data-theme="dark"] .skel { background: var(--paper-2); }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
:root[data-theme="dark"] .auth-alert.err { background: #3a1616; color: #fca5a5; border-color: #5a1f1f; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) { .skel-kpis { grid-template-columns: 1fr 1fr; } .cms-row { grid-template-columns: 1fr; } .cms-row .k { padding-top: 0; } }
@media (max-width: 760px) { .kv { grid-template-columns: 1fr; } .auth-3d { display: none; } }

/* ---------- Print (payslips) ---------- */
@media print {
  .sidebar, .app-topbar, .chat-fab, .chat-panel, #toast-wrap, .modal .x, .modal-foot, .sidebar-scrim { display: none !important; }
  .modal .backdrop { background: #fff; backdrop-filter: none; }
  .modal .dialog { box-shadow: none; max-height: none; width: 100%; }
  body.portal { background: #fff; }
}

/* Icon sizes (svg() emits a 1em fallback) */
.icon-btn svg { width: 20px; height: 20px; }
.side-user .logout svg { width: 18px; height: 18px; }
.empty .ic svg { width: 28px; height: 28px; }
.tabs button svg { width: 16px; height: 16px; }
.cms-group > summary svg { width: 18px; height: 18px; color: var(--g-600); }
.input-group .toggle-pw svg { width: 18px; height: 18px; }
.chat-fab svg { width: 28px; height: 28px; }
.secure-note svg { width: 14px; height: 14px; }
.cam-frame .sil { width: 108px; height: 108px; }
.btn-link svg { width: 1em; height: 1em; }
