:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --sidebar: #0f1420;
  --sidebar-soft: #171e2d;
  --text: #171b26;
  --muted: #737b8c;
  --border: #e2e6ee;
  --primary: #e31f3d;
  --primary-dark: #be1731;
  --primary-soft: #fff0f3;
  --success: #16875a;
  --success-soft: #eaf8f2;
  --warning: #a76800;
  --warning-soft: #fff5df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --info: #365ec9;
  --info-soft: #edf2ff;
  --shadow: 0 16px 40px rgba(22, 29, 45, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 258px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { border: 0; }
[hidden] { display: none !important; }

.app-shell { display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #f5f7fb;
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand, .auth-brand { display: flex; align-items: center; gap: 12px; }
.brand { padding: 0 10px 24px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  color: white; font-size: 13px; font-weight: 900; letter-spacing: -.3px;
  background: linear-gradient(140deg, #ff3857, #b80f2b);
  box-shadow: 0 10px 26px rgba(227,31,61,.3);
}
.brand-mark.large { width: 50px; height: 50px; border-radius: 15px; font-size: 16px; }
.brand strong, .auth-brand strong { display: block; font-size: 17px; letter-spacing: -.3px; }
.brand small, .auth-brand small { display: block; margin-top: 2px; color: #929aab; font-size: 12px; text-transform: uppercase; letter-spacing: 1.7px; }

.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 13px; border-radius: 11px;
  color: #aeb6c6; font-size: 14px; font-weight: 600;
  transition: .18s ease;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: white; background: var(--sidebar-soft); box-shadow: inset 3px 0 0 var(--primary); }
.nav-icon { width: 22px; text-align: center; color: #80899b; font-size: 18px; }
.nav-item.active .nav-icon { color: #ff526b; }
.sidebar-bottom { margin-top: auto; }
.sidebar-profile {
  margin-top: 16px; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #283247; color: white; font-weight: 800; text-transform: uppercase;
}
.profile-copy { min-width: 0; flex: 1; }
.profile-copy strong, .profile-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy strong { font-size: 12px; }
.profile-copy small { color: #7f899b; font-size: 11px; margin-top: 3px; }
.icon-button {
  width: 32px; height: 32px; border-radius: 9px; color: #aeb6c6; background: transparent; cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.08); color: white; }

.main-content { width: calc(100% - var(--sidebar-width)); min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  min-height: 96px; padding: 21px 34px; display: flex; align-items: center; gap: 16px; justify-content: space-between;
  background: rgba(244,246,250,.88); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 2px 0 0; font-size: 25px; line-height: 1.15; letter-spacing: -.55px; }
.eyebrow { margin: 0; color: var(--primary); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.mobile-menu { display: none; background: transparent; font-size: 24px; cursor: pointer; }
.content-area { padding: 28px 34px 44px; }

.button {
  min-height: 40px; padding: 0 16px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 750; cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,20,32,.04); transition: .16s ease;
}
.button:hover { transform: translateY(-1px); border-color: #cbd1dc; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.secondary { background: #171e2d; border-color: #171e2d; color: white; }
.button.ghost { background: transparent; box-shadow: none; }
.button.danger { color: var(--danger); background: var(--danger-soft); border-color: #ffd4cf; }
.button.small { min-height: 32px; padding: 0 11px; border-radius: 8px; font-size: 12px; }
.button.full { width: 100%; min-height: 46px; }
.text-link { color: var(--primary); font-weight: 700; font-size: 13px; }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.span-2-1 { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.metric-card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 18px rgba(22,29,45,.035);
}
.metric-card { padding: 20px; min-height: 136px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 82px; height: 82px; border-radius: 50%; background: var(--primary-soft); right: -28px; top: -28px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-value { margin-top: 14px; font-size: 29px; font-weight: 850; letter-spacing: -.8px; }
.metric-note { margin-top: 7px; color: var(--muted); font-size: 11px; }
.metric-icon { position: absolute; z-index: 2; top: 16px; right: 17px; color: var(--primary); font-size: 18px; font-weight: 900; }
.panel { padding: 21px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.panel-title { margin: 0; font-size: 16px; letter-spacing: -.25px; }
.panel-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel-toolbar { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; justify-content: space-between; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; font-weight: 800; white-space: nowrap; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.cell-main { font-weight: 750; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.employee-cell { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.employee-avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #edf0f6; color: #293247; font-weight: 850; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 6px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .25px; white-space: nowrap; }
.badge.success { color: var(--success); background: var(--success-soft); }
.badge.warning { color: var(--warning); background: var(--warning-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.info { color: var(--info); background: var(--info-soft); }
.badge.neutral { color: #626b7c; background: #eef0f4; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { color: #4d5565; font-size: 11px; font-weight: 750; }
.field input, .field select, .field textarea, .search-input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #d9dee8; border-radius: 10px; background: white; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-input:focus { border-color: #ee7185; box-shadow: 0 0 0 3px rgba(227,31,61,.1); }
.search-input { max-width: 320px; min-height: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full-width { grid-column: 1 / -1; }
.form-error { padding: 10px 12px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.help-text { color: var(--muted); font-size: 11px; line-height: 1.5; }
.muted { color: var(--muted); }
code { padding: 2px 6px; border-radius: 6px; background: #eef0f4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { padding: 4px; display: inline-flex; gap: 2px; background: #eceff4; border-radius: 10px; }
.segmented a { padding: 7px 11px; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.segmented a.active { color: var(--text); background: white; box-shadow: 0 2px 6px rgba(15,20,32,.08); }

.profile-header { padding: 24px; display: flex; align-items: flex-start; gap: 18px; }
.profile-avatar { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; background: #171e2d; color: white; font-size: 24px; font-weight: 900; }
.profile-summary { flex: 1; }
.profile-summary h2 { margin: 2px 0 5px; font-size: 24px; letter-spacing: -.5px; }
.profile-summary p { margin: 0; color: var(--muted); }
.profile-meta { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 26px; }
.detail-item dt { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; }
.detail-item dd { margin: 5px 0 0; font-size: 13px; font-weight: 650; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.section-heading h3 { margin: 0; font-size: 15px; }
.timeline { display: flex; flex-direction: column; }
.timeline-item { position: relative; padding: 0 0 18px 22px; border-left: 1px solid var(--border); }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; width: 9px; height: 9px; border-radius: 50%; left: -5px; top: 3px; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline-title { font-size: 12px; font-weight: 750; }
.timeline-meta { color: var(--muted); font-size: 11px; margin-top: 4px; }
.sensitive-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.revealed-value { color: var(--danger); font-weight: 800; word-break: break-all; }

.audit-list { display: flex; flex-direction: column; }
.audit-item { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 11px; align-items: start; padding: 13px 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: 0; }
.audit-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: #f0f2f6; color: #667085; font-size: 12px; font-weight: 850; }
.audit-copy strong { display: block; font-size: 12px; line-height: 1.4; }
.audit-copy small, .audit-time { color: var(--muted); font-size: 10px; }

.notice { padding: 14px 15px; border: 1px solid; border-radius: 11px; font-size: 12px; line-height: 1.55; }
.notice.info { color: #294c9f; background: var(--info-soft); border-color: #d7e1ff; }
.notice.warning { color: #815600; background: var(--warning-soft); border-color: #f4dda7; }
.notice.danger { color: var(--danger); background: var(--danger-soft); border-color: #ffd8d3; }

.kpi-list { display: flex; flex-direction: column; gap: 10px; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.kpi-row:last-child { border-bottom: 0; }
.kpi-row strong { font-size: 13px; }
.kpi-row span { color: var(--muted); font-size: 11px; }

.auth-page { background: #0e131e; color: white; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr); }
.auth-visual { padding: 42px 55px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; background: radial-gradient(circle at 82% 15%, rgba(227,31,61,.24), transparent 30%), linear-gradient(140deg,#111827,#0b0f17); }
.auth-visual::after { content: "MB"; position: absolute; right: -50px; bottom: -120px; font-size: 310px; font-weight: 950; letter-spacing: -34px; color: rgba(255,255,255,.024); }
.auth-message { max-width: 650px; position: relative; z-index: 2; }
.auth-message h1 { margin: 13px 0 18px; font-size: clamp(40px, 5vw, 72px); line-height: .98; letter-spacing: -3.2px; }
.auth-message > p:last-child { color: #9aa4b6; font-size: 16px; }
.security-note { color: #8e98aa; font-size: 12px; }
.security-note span { color: var(--primary); margin-right: 8px; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: #f6f7fa; color: var(--text); }
.auth-card { width: min(100%, 420px); padding: 34px; display: flex; flex-direction: column; gap: 20px; background: white; border: 1px solid #e3e7ef; border-radius: 20px; box-shadow: 0 25px 70px rgba(0,0,0,.14); }
.auth-card h2 { margin: 7px 0 7px; font-size: 28px; letter-spacing: -.8px; }
.auth-card p { margin: 0; }
.demo-credentials { display: grid; gap: 6px; padding: 13px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.demo-credentials strong { color: var(--text); }
.auth-single { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, rgba(227,31,61,.18), transparent 35%), #0e131e; color: var(--text); }
.auth-card.narrow { max-width: 390px; }
.auth-brand.centered { justify-content: center; color: white; }
.centered-text { text-align: center; }
.centered-link { text-align: center; }
.otp-input { text-align: center; font-size: 24px; font-weight: 800; letter-spacing: 9px; }

.toast-stack { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 380px; padding: 12px 15px; border-radius: 11px; background: #17202d; color: white; font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f1c15; white-space: pre-line; }

.compact-access-form { max-width: 920px; }
.compact-access-select { max-width: 620px; }
.compact-access-form .field select { min-height: 38px; padding: 7px 10px; font-size: 12px; }
.compact-permission-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-top: 13px; }
.permission-choice { min-height: 66px; padding: 11px 12px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); cursor: pointer; }
.permission-choice:hover { border-color: #cbd2df; background: #fff; }
.permission-choice input { width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.permission-choice span { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.permission-choice strong { font-size: 11px; line-height: 1.35; color: var(--text); }
.permission-choice small { font-size: 10px; line-height: 1.35; color: var(--muted); }
.permission-choice:has(input:checked) { border-color: rgba(227,31,61,.35); background: var(--primary-soft); }
.permission-choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.compact-access-actions { margin-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.compact-access-actions .button { min-width: 142px; }
.toast.warning { background: #8b5b07; }

dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 17px; background: white; box-shadow: 0 28px 90px rgba(0,0,0,.25); overflow: auto; }
dialog::backdrop { background: rgba(9,13,21,.64); backdrop-filter: blur(3px); }
.dialog-header { padding: 20px 22px 16px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 18px; }
.dialog-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.dialog-body { padding: 21px 22px 24px; }
.dialog-close { width: 32px; height: 32px; border-radius: 9px; background: #f1f3f6; cursor: pointer; color: #596273; }

.security-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(300px,.7fr); gap: 18px; }
.secret-box { margin-top: 14px; padding: 14px; background: #101622; color: #f6f7fa; border-radius: 11px; }
.secret-box code { display: block; margin: 8px 0; color: #ff7c90; background: transparent; padding: 0; word-break: break-all; }
.secret-box input { width: 100%; border: 1px solid #303b50; color: #b8c0cf; background: #171e2d; border-radius: 8px; padding: 8px; font-size: 10px; }

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid.span-2-1, .security-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 30px 0 60px rgba(0,0,0,.25); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .main-content { width: 100%; margin-left: 0; }
  .mobile-menu { display: block; }
  .topbar { padding: 17px 18px; min-height: 82px; justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  .content-area { padding: 20px 16px 36px; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 18px; }
  .form-grid, .detail-list { grid-template-columns: 1fr; }
  .compact-permission-grid { grid-template-columns: 1fr; }
  .compact-access-actions { align-items: stretch; flex-direction: column; }
  .compact-access-actions .button { width: 100%; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; }
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 20px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions .button span.optional { display: none; }
  .panel { padding: 16px; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .search-input { max-width: none; }
  .auth-card { padding: 24px 20px; }
  .metric-card { min-height: 115px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.block { display: block; }

/* v0.2 HR modules */
.role-badge { color: #7a3fb0; background: #f5ecff; }
.profile-side { min-width: 170px; padding: 14px 16px; border-radius: 13px; background: var(--surface-soft); text-align: right; }
.profile-side span, .profile-side small { display: block; color: var(--muted); font-size: 10px; }
.profile-side strong { display: block; margin: 5px 0 4px; font-size: 22px; }
.vacation-balance { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.vacation-balance > div { padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.vacation-balance span { display: block; color: var(--muted); font-size: 10px; }
.vacation-balance strong { display: block; margin-top: 7px; font-size: 22px; }
.mini-people { display: flex; flex-direction: column; gap: 8px; }
.mini-person { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 11px; }
.mini-person:hover { border-color: #c7ceda; background: var(--surface-soft); }
.mini-person strong, .mini-person small { display: block; }
.mini-person strong { font-size: 12px; }
.mini-person small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.empty-state.compact { padding: 18px 4px; }
.danger-button { color: var(--danger); border-color: #ffd4cf; background: var(--danger-soft); }

.absence-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 8px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.absence-pill.vacation, .calendar-event.vacation, .legend-dot.vacation { color: #3f55bd; background: #e9edff; }
.absence-pill.sick, .calendar-event.sick, .legend-dot.sick { color: #b42318; background: #ffe9e6; }
.absence-pill.remote, .calendar-event.remote, .legend-dot.remote { color: #087b68; background: #e2f8f3; }
.absence-pill.day-off, .calendar-event.day-off, .legend-dot.day-off { color: #8a5a00; background: #fff0cc; }
.absence-pill.trip, .calendar-event.trip, .legend-dot.trip { color: #7250a8; background: #f2eaff; }
.absence-pill.unpaid, .calendar-event.unpaid, .legend-dot.unpaid { color: #596273; background: #e9ecf1; }
.absence-pill.other, .calendar-event.other, .legend-dot.other { color: #566178; background: #edf0f5; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

.birthday-list { display: flex; flex-direction: column; }
.birthday-item { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.birthday-item:last-child { border-bottom: 0; }
.birthday-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #8b2850; background: #ffe9f2; font-size: 11px; font-weight: 850; }
.birthday-copy strong, .birthday-copy small, .birthday-date small { display: block; }
.birthday-copy strong { font-size: 12px; }
.birthday-copy small, .birthday-date small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.birthday-date { text-align: right; font-size: 11px; font-weight: 800; }

.org-company { overflow: hidden; }
.org-tree-scroll { padding: 10px 4px 8px; overflow-x: auto; }
.org-tree, .org-tree ul { list-style: none; padding: 0; margin: 0; }
.org-tree-roots { display: flex; flex-direction: column; gap: 18px; }
.org-tree-item { position: relative; }
.org-tree-children { position: relative; margin: 12px 0 0 30px !important; padding-left: 24px !important; display: flex; flex-direction: column; gap: 11px; border-left: 1px solid #d8dde7; }
.org-tree-children > .org-tree-item::before { content: ""; position: absolute; top: 25px; left: -24px; width: 24px; border-top: 1px solid #d8dde7; }
.org-card { min-width: 330px; max-width: 520px; padding: 13px 14px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-left: 4px solid #aab2c1; border-radius: 12px; background: white; box-shadow: 0 4px 14px rgba(22,29,45,.04); }
.org-card.role-owner { border-left-color: #e31f3d; }
.org-card.role-executive { border-left-color: #7a3fb0; }
.org-card.role-head { border-left-color: #365ec9; }
.org-card.role-team_lead { border-left-color: #16875a; }
.org-card-main { min-width: 0; flex: 1; display: flex; gap: 10px; align-items: center; }
.org-avatar { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; display: grid; place-items: center; background: #171e2d; color: white; font-size: 11px; font-weight: 900; }
.org-copy { min-width: 0; }
.org-copy strong, .org-copy small, .org-copy span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.org-copy strong { font-size: 12px; }
.org-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.org-copy span { margin-top: 4px; color: #8b93a2; font-size: 9px; }
.org-role { padding: 5px 8px; border-radius: 999px; color: #626b7c; background: #eef0f4; font-size: 9px; font-weight: 800; white-space: nowrap; }
.org-count { color: var(--muted); font-size: 9px; white-space: nowrap; }

.calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.calendar-nav { display: flex; align-items: center; gap: 14px; }
.calendar-nav h2 { margin: 0; font-size: 21px; }
.calendar-nav p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.calendar-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 14px; color: var(--muted); font-size: 10px; }
.calendar-legend span { display: inline-flex; align-items: center; }
.calendar-panel { overflow-x: auto !important; }
.calendar-grid { min-width: 900px; display: grid; grid-template-columns: repeat(7,minmax(120px,1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.calendar-weekdays div { padding: 11px 12px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.calendar-days { background: var(--border); gap: 1px; }
.calendar-day { min-height: 142px; padding: 9px; background: white; }
.calendar-day.outside { background: #f7f8fa; color: #aeb5c1; }
.calendar-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.calendar-date { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; font-size: 11px; font-weight: 800; }
.calendar-day.today .calendar-date { color: white; background: var(--primary); }
.calendar-events { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.calendar-event { padding: 5px 6px; border-radius: 7px; display: block; font-size: 9px; line-height: 1.25; overflow: hidden; }
.calendar-event strong, .calendar-event span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar-event span { margin-top: 2px; opacity: .8; }
.calendar-more { color: var(--muted); font-size: 9px; font-weight: 800; }

@media (max-width: 820px) {
  .profile-side { width: 100%; text-align: left; }
  .vacation-balance { grid-template-columns: 1fr; }
  .calendar-head { align-items: flex-start; flex-direction: column; }
  .calendar-legend { justify-content: flex-start; }
}

.row-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.computed-field { display: flex; align-items: center; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #f7f8fa; color: var(--text); font-weight: 700; }
.section-divider { height: 1px; margin: 18px 0; background: var(--border); }

/* Employee photos / avatars */
.avatar-frame { overflow: hidden; position: relative; padding: 0; }
.avatar-frame img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.avatar-frame .avatar-initials { width: 100%; height: 100%; display: grid; place-items: center; }
.avatar-upload-preview { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.avatar-upload-preview .profile-avatar { flex: 0 0 auto; }
.avatar-upload-preview strong { display: block; font-size: 13px; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }

/* P&L module */
.pnl-shell { min-width: 0; }
.pnl-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 7px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.pnl-tabs a { padding: 9px 13px; border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 750; text-decoration: none; }
.pnl-tabs a:hover { background: #f3f5f8; color: var(--text); }
.pnl-tabs a.active { background: var(--primary); color: #fff; }
.toolbar-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.pnl-summary-table { min-width: 1450px; }
.pnl-summary-table th:not(:first-child), .pnl-summary-table td:not(:first-child) { text-align: right; white-space: nowrap; }
.pnl-summary-table tr.pnl-total td { border-top: 2px solid #202b3d; background: #f6f8fb; font-weight: 800; }
.pnl-summary-table tr.pnl-total.teal td { border-top-color: #00a88b; background: #edf9f6; }
.text-danger { color: var(--danger) !important; }
.breakdown-list { display: grid; gap: 15px; }
.breakdown-row { display: grid; gap: 6px; }
.breakdown-head { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; }
.breakdown-track { height: 8px; border-radius: 99px; background: #edf0f5; overflow: hidden; }
.breakdown-track span { display: block; min-width: 2px; height: 100%; background: #ff6678; border-radius: inherit; }
.breakdown-track.income span { background: #00b894; }
.monthly-bars { display: grid; gap: 10px; }
.monthly-bar-row { display: grid; grid-template-columns: 42px minmax(160px, 1fr) 105px; gap: 12px; align-items: center; font-size: 11px; }
.monthly-bar-row strong { text-align: right; }
.monthly-bar-track { position: relative; height: 14px; background: #f0f2f6; border-radius: 99px; overflow: hidden; }
.monthly-bar-track i { position: absolute; left: 0; height: 7px; max-width: 100%; }
.monthly-bar-track i.income { top: 0; background: #00b894; }
.monthly-bar-track i.expense { bottom: 0; background: #ff6678; }
.pnl-access-form { display: flex; gap: 15px; flex-wrap: wrap; }
.pnl-access-form label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; white-space: nowrap; }
.inline-form select { min-width: 95px; }
@media (max-width: 800px) {
  .pnl-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .pnl-tabs a { white-space: nowrap; }
  .monthly-bar-row { grid-template-columns: 34px minmax(120px, 1fr) 85px; }
}

/* Companies module */
.companies-shell { min-width: 0; }
.company-card-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; padding: 20px; }
.company-summary-card { display: flex; align-items: center; gap: 13px; min-height: 112px; padding: 17px; border: 1px solid var(--border); border-radius: 14px; background: #fff; transition: .16s ease; }
.company-summary-card:hover { transform: translateY(-2px); border-color: #c9d0dc; box-shadow: var(--shadow); }
.company-logo-placeholder, .company-profile-logo { display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: linear-gradient(145deg,#202b3d,#0f1420); font-weight: 900; letter-spacing: -.5px; }
.company-logo-placeholder { width: 48px; height: 48px; border-radius: 13px; font-size: 13px; }
.company-summary-copy { min-width: 0; flex: 1; }
.company-summary-copy strong, .company-summary-copy small, .company-summary-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-summary-copy strong { font-size: 14px; }
.company-summary-copy small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.company-summary-copy span { margin-top: 8px; color: #8b93a2; font-size: 9px; font-weight: 700; }
.company-card-arrow { color: var(--primary); font-size: 18px; font-weight: 800; }
.companies-access-form { display: flex; gap: 15px; flex-wrap: wrap; }
.companies-access-form label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; white-space: nowrap; }
.company-profile { padding: 26px; }
.company-profile-head { display: flex; align-items: center; gap: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.company-profile-logo { width: 70px; height: 70px; border-radius: 18px; font-size: 18px; }
.company-profile-head h2 { margin: 4px 0 0; font-size: 24px; }
.company-profile-head p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.company-info-grid { margin-top: 22px; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.company-info-grid > div { min-height: 82px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.company-info-grid > div.span-2 { grid-column: span 2; }
.company-info-grid span, .company-info-grid strong { display: block; }
.company-info-grid span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .5px; }
.company-info-grid strong { margin-top: 9px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.company-documents-grid { display: grid; gap: 10px; padding: 18px 20px 22px; }
.company-document-card { display: grid; grid-template-columns: 52px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.company-document-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 10px; font-weight: 900; }
.company-document-copy { min-width: 0; }
.company-document-copy strong, .company-document-copy small, .company-document-copy span { display: block; }
.company-document-copy strong { font-size: 13px; }
.company-document-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.company-document-copy span { margin-top: 5px; color: #8c94a3; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-document-copy p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.company-document-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.preview-dialog { width: min(1120px,94vw); height: min(820px,90vh); padding: 0; }
.preview-dialog .dialog-header { margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.preview-dialog-body { height: calc(100% - 78px); background: #eef1f5; }
.preview-dialog-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 1050px) { .company-card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .company-info-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 700px) { .company-card-grid { grid-template-columns: 1fr; padding: 14px; } .company-info-grid { grid-template-columns: 1fr; } .company-info-grid > div.span-2 { grid-column: auto; } .company-document-card { grid-template-columns: 44px minmax(0,1fr); } .company-document-actions { grid-column: 1/-1; justify-content: flex-start; } }

/* Organization administration */
.organizations-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.organization-admin-card { padding: 20px; }
.organization-admin-card.is-archived { opacity: .72; background: #f7f8fa; }
.organization-admin-head { display: flex; gap: 14px; align-items: flex-start; }
.organization-mark { width: 52px; height: 52px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; color: #fff; background: linear-gradient(145deg,#202b3d,#0f1420); font-size: 13px; font-weight: 900; letter-spacing: .4px; }
.organization-title { min-width: 0; flex: 1; }
.organization-title h2 { margin: 11px 0 0; font-size: 19px; }
.organization-title p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.organization-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin-top: 18px; }
.organization-metrics > div { padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.organization-metrics span, .organization-metrics small { display: block; color: var(--muted); font-size: 9px; }
.organization-metrics strong { display: block; margin: 6px 0 3px; font-size: 18px; }
.organization-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--border); }
.check-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.check-card input { margin-top: 2px; }
.check-card strong, .check-card small { display: block; }
.check-card strong { font-size: 12px; }
.check-card small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
@media (max-width: 1050px) { .organizations-grid { grid-template-columns: 1fr; } }
@media (max-width: 650px) { .organization-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); } }

/* Shared release-candidate controls */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.pagination a { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 9px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: #fff; font-size: 11px; font-weight: 750; text-decoration: none; }
.pagination a:hover { border-color: #bec7d5; color: var(--text); background: #f6f8fb; }
.pagination a.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.filter-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.json-preview { max-width: 520px; max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: #f7f9fc; font-size: 10px; line-height: 1.45; }
.company-summary-card.is-archived { opacity: .68; background: #f7f8fa; }
.compact-access-panel { max-width: 880px; }
.access-permission-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.access-permission-grid .check-card { min-height: 76px; }
.table-wrap table { scroll-margin-top: 90px; }
@media (max-width: 900px) { .filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 620px) { .filter-grid, .access-permission-grid { grid-template-columns: 1fr; } .pagination { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; } }

/* Per-user light/dark theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #151b26;
  --surface-soft: #101620;
  --sidebar: #080b11;
  --sidebar-soft: #1d2635;
  --text: #f2f5fa;
  --muted: #9aa5b6;
  --border: #293243;
  --primary-soft: #38111a;
  --success-soft: #103326;
  --warning-soft: #392b0f;
  --danger-soft: #3a1718;
  --info-soft: #172548;
  --shadow: 0 16px 40px rgba(0,0,0,.28);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #0b0f17;
    --surface: #151b26;
    --surface-soft: #101620;
    --sidebar: #080b11;
    --sidebar-soft: #1d2635;
    --text: #f2f5fa;
    --muted: #9aa5b6;
    --border: #293243;
    --primary-soft: #38111a;
    --success-soft: #103326;
    --warning-soft: #392b0f;
    --danger-soft: #3a1718;
    --info-soft: #172548;
    --shadow: 0 16px 40px rgba(0,0,0,.28);
  }
}
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .company-summary-card,
html[data-theme="dark"] .company-document-card,
html[data-theme="dark"] .pagination a,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] dialog,
html[data-theme="dark"] tbody tr:hover { background: var(--surface); color: var(--text); }
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .topbar,
  html[data-theme="system"] .company-summary-card,
  html[data-theme="system"] .company-document-card,
  html[data-theme="system"] .pagination a,
  html[data-theme="system"] .field input,
  html[data-theme="system"] .field select,
  html[data-theme="system"] .field textarea,
  html[data-theme="system"] .search-input,
  html[data-theme="system"] dialog,
  html[data-theme="system"] tbody tr:hover { background: var(--surface); color: var(--text); }
}
.theme-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; }
.equipment-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.equipment-card { padding: 18px; }
.equipment-card-head { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; }
.equipment-card h3 { margin:7px 0 0; font-size:16px; }
.equipment-meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; margin-top:15px; }
.equipment-meta div { padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); }
.equipment-meta span, .equipment-meta strong { display:block; }
.equipment-meta span { color:var(--muted); font-size:9px; text-transform:uppercase; }
.equipment-meta strong { margin-top:5px; font-size:12px; overflow-wrap:anywhere; }
.payment-request-card { padding:18px; }
.payment-request-head { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.payment-request-head h3 { margin:5px 0 0; font-size:16px; }
.payment-request-details { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-top:15px; }
.payment-request-details div { padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); }
.payment-request-details span,.payment-request-details strong { display:block; }
.payment-request-details span { color:var(--muted); font-size:9px; text-transform:uppercase; }
.payment-request-details strong { margin-top:5px; font-size:12px; overflow-wrap:anywhere; }
@media (max-width:1050px){.equipment-grid{grid-template-columns:repeat(2,minmax(0,1fr));}.payment-request-details{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media (max-width:680px){.equipment-grid{grid-template-columns:1fr}.payment-request-details{grid-template-columns:1fr}}
.task-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px}.task-card{display:flex;flex-direction:column;gap:5px;padding:14px;border:1px solid var(--border);border-radius:14px;background:var(--surface-soft);color:var(--text);text-decoration:none}.task-card:hover{transform:translateY(-1px);border-color:var(--accent)}.task-card.high{border-left:4px solid var(--danger)}.task-kind{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}.task-card small{color:var(--muted)}

/* Scoped access control */
.access-control-page .metric-value.compact { font-size: 1.05rem; line-height: 1.35; word-break: break-word; }
.access-user-picker select { min-width: min(560px, 100%); }
.permission-chip-grid { display: grid; gap: 18px; padding: 18px; }
.permission-group { display: grid; gap: 10px; }
.permission-group h3 { margin: 0; font-size: .92rem; }
.permission-chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.permission-chip { display: inline-flex; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .78rem; background: var(--surface-soft); }
.permission-chip.active { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.access-profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; padding: 18px; }
.access-profile-card { display: grid; gap: 10px; border: 1px solid var(--border); border-radius: 16px; padding: 15px; background: var(--surface); }
.access-profile-card h3 { margin: 7px 0 2px; }
.access-profile-card p { margin: 0; color: var(--muted); }
.access-profile-card.is-archived { opacity: .58; }
.permission-checkbox-groups { display: grid; gap: 14px; max-height: 52vh; overflow: auto; padding: 4px; }
.permission-checkbox-groups fieldset { border: 1px solid var(--border); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.permission-checkbox-groups legend { font-weight: 700; padding: 0 6px; }
.permission-checkbox { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: start; padding: 7px; border-radius: 10px; }
.permission-checkbox:hover { background: var(--surface-soft); }
.permission-checkbox span { display: grid; gap: 2px; }
.permission-checkbox small { color: var(--muted); }
.access-explain-result { margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.access-explain-result.allowed { border-color: var(--success); }
.access-explain-result.denied { border-color: var(--danger); }
.access-explain-result p { margin: 5px 0; }
.access-explain-result ul { margin: 8px 0 0 18px; }
@media (max-width: 760px) { .access-profile-grid { grid-template-columns: 1fr; } .access-user-picker select { min-width: 0; width: 100%; } }
