:root {
  --ink: #172132;
  --muted: #687386;
  --line: #e7ebf1;
  --panel: #ffffff;
  --soft: #f6f8fb;
  --brand: #c52f82;
  --brand-dark: #982264;
  --navy: #111c2c;
  --teal: #0c9b91;
  --amber: #d98c16;
  --danger: #cf3f4a;
  --shadow: 0 18px 48px rgba(17, 28, 44, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Cairo", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #fbfcfe 0%, #eef4f7 100%);
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.ambient span {
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(197, 47, 130, 0.12);
  animation: float 14s ease-in-out infinite;
}
.ambient span:nth-child(1) { top: 8%; right: 8%; }
.ambient span:nth-child(2) { bottom: 8%; left: 12%; background: rgba(12, 155, 145, 0.14); animation-delay: -5s; }
.ambient span:nth-child(3) { top: 42%; left: 36%; background: rgba(17, 28, 44, 0.08); animation-delay: -9s; }
@keyframes float { 50% { transform: translate3d(28px, -24px, 0) scale(1.08); } }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
  width: min(430px, 100%);
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 32px;
  backdrop-filter: blur(18px);
}
.brand-block { text-align: center; margin-bottom: 28px; }
.brand-block img { width: min(250px, 80%); }
.brand-block p { margin: 8px 0 0; color: var(--muted); font-weight: 700; }
.login-form, .form-grid { display: grid; gap: 14px; }
label { color: var(--muted); font-size: 13px; font-weight: 700; display: grid; gap: 7px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
}
textarea { resize: vertical; min-height: 86px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(197,47,130,.1); }
.password-field { display: grid; grid-template-columns: 1fr 42px; gap: 8px; align-items: center; }
.form-error { margin: 0; min-height: 22px; color: var(--danger); font-weight: 700; }

.app { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  background: rgba(255,255,255,.92);
  border-left: 1px solid var(--line);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.side-brand { display: flex; align-items: center; justify-content: space-between; min-height: 58px; }
.side-brand img { width: 170px; }
nav { display: grid; gap: 7px; overflow: auto; padding-inline-end: 4px; }
.nav-btn, .ghost-btn, .primary-btn, .icon-btn {
  border: 0;
  border-radius: 8px;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}
.nav-btn.active, .nav-btn:hover { background: #f3edf3; color: var(--brand-dark); transform: translateX(-2px); }
.primary-btn, .ghost-btn {
  min-height: 42px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}
.primary-btn { background: var(--brand); color: #fff; box-shadow: 0 10px 22px rgba(197,47,130,.22); }
.primary-btn:hover, .icon-btn:hover, .ghost-btn:hover { transform: translateY(-1px); }
.ghost-btn { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.logout { margin-top: auto; }
svg { width: 19px; height: 19px; stroke-width: 2.3; }

.workspace { min-width: 0; }
.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(255,255,255,.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.eyebrow { margin: 0 0 2px; color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: 0; }
h1 { margin: 0; font-size: 25px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.content { padding: 24px; display: grid; gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat, .panel, .table-panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(17,28,44,.07);
}
.stat { padding: 16px; display: grid; gap: 8px; }
.stat-icon { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: #f3edf3; color: var(--brand); }
.stat p { margin: 0; color: var(--muted); font-weight: 800; }
.stat strong { font-size: 24px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.panel { padding: 18px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-title h2 { margin: 0; font-size: 18px; }
.hint { color: var(--muted); margin: 0; font-size: 13px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: right; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; background: #eef8f7; color: var(--teal); font-weight: 900; font-size: 12px; }
.badge.warn { background: #fff6e7; color: var(--amber); }
.badge.danger { background: #fff0f1; color: var(--danger); }
.row-actions { display: flex; gap: 7px; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 9px; font-weight: 800; }
.chart-box { height: 270px; }
canvas { width: 100%; height: 100%; }
.filter-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filter-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 900;
}
.filter-chip.active, .filter-chip:hover { background: #f3edf3; color: var(--brand-dark); border-color: rgba(197,47,130,.25); }
.filter-total { margin-inline-start: auto; color: var(--navy); }
.expense-breakdown { display: grid; gap: 10px; }
.breakdown-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 900;
}
.breakdown-row:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(17,28,44,.08); }
.breakdown-row strong { color: var(--brand-dark); }

.employee-layout { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr); gap: 18px; align-items: start; }
.employee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.employee-tile {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(17,28,44,.06);
}
.employee-tile h3 { margin: 0; font-size: 16px; }
.employee-tile p { margin: 2px 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.employee-tile span { color: var(--teal); font-size: 12px; font-weight: 900; }
.tile-photo {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3edf3;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
}
.card-studio { overflow: hidden; }
.employee-card {
  width: 720px;
  max-width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.id-front, .id-back {
  position: relative;
  width: 340px;
  min-height: 214px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.id-front { padding: 18px; display: grid; gap: 14px; }
.id-ribbon {
  position: absolute;
  inset: 0 0 auto auto;
  width: 122px;
  height: 100%;
  background: linear-gradient(180deg, var(--brand), var(--navy));
  clip-path: polygon(40% 0, 100% 0, 100% 100%, 0 100%);
}
.id-top, .id-person, .id-meta { position: relative; z-index: 1; }
.id-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.id-logo { width: 126px; background: #fff; border-radius: 6px; padding: 4px; }
.id-top span { color: var(--muted); font-size: 11px; font-weight: 900; }
.id-person { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; }
.id-photo {
  width: 92px;
  height: 108px;
  border-radius: 8px;
  object-fit: cover;
  background: #edf1f5;
  border: 4px solid #fff;
  box-shadow: 0 8px 18px rgba(17,28,44,.14);
}
.id-photo.placeholder {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
}
.id-person strong { display: block; font-size: 22px; line-height: 1.25; }
.id-person p { margin: 4px 0; color: var(--muted); font-weight: 800; }
.id-person small { color: var(--brand); font-weight: 900; }
.id-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  padding: 10px;
  background: var(--soft);
  border-radius: 8px;
}
.id-meta span { color: var(--muted); font-size: 11px; font-weight: 900; }
.id-meta b { font-size: 12px; }
.id-back {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
  background: linear-gradient(145deg, #ffffff 0%, #f6f8fb 100%);
}
.scan-label { margin: 0 0 8px; color: var(--navy); font-weight: 900; }
.qr-box {
  display: grid;
  place-items: center;
  width: 178px;
  height: 178px;
  margin: auto;
  padding: 9px;
  background: #fff;
  border: 2px solid var(--navy);
  border-radius: 8px;
}
.qr-box svg { width: 154px !important; height: 154px !important; }
.id-back small { max-width: 240px; color: var(--muted); font-weight: 800; }
.print-area { display: flex; gap: 18px; flex-wrap: wrap; align-items: start; margin-top: 12px; overflow: auto; padding-bottom: 4px; }

.activity { display: grid; gap: 10px; }
.activity-item { display: flex; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.activity-item i { color: var(--brand); margin-top: 2px; }
.activity-item p { margin: 0; font-weight: 800; }
.activity-item small { color: var(--muted); }

.mobile-only { display: none; }
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .stats, .grid-2, .grid-3, .employee-layout { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}
@media (max-width: 680px) {
  .content, .topbar { padding: 14px; }
  .top-actions { width: 100%; }
  .top-actions > * { flex: 1; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .login-panel { padding: 22px; }
  h1 { font-size: 21px; }
  .employee-card { width: 100%; grid-template-columns: 1fr; }
  .id-front, .id-back { width: 100%; }
  .employee-tile { grid-template-columns: 52px 1fr; }
  .employee-tile .mini-btn { grid-column: 1 / -1; }
  .filter-total { width: 100%; margin-inline-start: 0; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable {
    position: absolute;
    inset: 0 auto auto 0;
    width: 720px;
    max-width: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12mm;
    box-shadow: none;
  }
  .id-front, .id-back { box-shadow: none; break-inside: avoid; }
  .no-print { display: none !important; }
}
