:root {
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --accent: #dc2626;
  --accent-soft: #fee2e2;
  --danger: #e11d48;
  --warn: #d97706;
  --ok: #059669;
  --surface: #f8fafc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  background: var(--surface);
  color: #0f172a;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.brand p {
  margin: 2px 0 0;
  font-size: 11px;
  color: #94a3b8;
}

.nav {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.nav-btn:hover { background: var(--sidebar-hover); color: white; }
.nav-btn.active { background: #7f1d1d; color: #fecaca; }
.nav-short { display: none; }

.sync-chip {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 2px 8px;
}

.sidebar-foot {
  padding: 16px 20px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  color: #64748b;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.topbar .sub {
  color: #64748b;
  font-size: 13px;
  margin-top: 2px;
}

.content {
  padding: 24px 28px 40px;
  flex: 1;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 18px 16px;
}

.card .label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.03em;
}

.card .hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.panel {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: hidden;
}

.panel-h {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-h h3 { margin: 0; font-size: 15px; font-weight: 700; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: #dc2626; color: white; }
.btn-primary:hover { background: #b91c1c; }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: #fff1f2; color: #e11d48; }
.btn-danger:hover { background: #ffe4e6; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tr:hover td { background: #f8fafc; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
}

.b-present { background: #d1fae5; color: #065f46; }
.b-late { background: #ffedd5; color: #9a3412; }
.b-absent { background: #fee2e2; color: #991b1b; }
.b-remote { background: #e0e7ff; color: #3730a3; }
.b-vacation { background: #cffafe; color: #155e75; }
.b-sick { background: #fce7f3; color: #9d174d; }
.b-holiday { background: #f3e8ff; color: #6b21a8; }
.b-pending { background: #fef3c7; color: #92400e; }
.b-approved { background: #d1fae5; color: #065f46; }
.b-rejected { background: #fee2e2; color: #991b1b; }
.b-unpaid { background: #e2e8f0; color: #334155; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
  flex-shrink: 0;
}

.emp {
  display: flex;
  align-items: center;
  gap: 10px;
}

.emp .name { font-weight: 650; }
.emp .meta { font-size: 12px; color: #64748b; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-bg.show { display: flex; }

.modal {
  background: white;
  width: min(560px, 100%);
  border-radius: 18px;
  max-height: 90vh;
  overflow: auto;
}

.modal h3 { margin: 0; font-size: 18px; }
.modal .mh { padding: 18px 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.modal .mb { padding: 18px 20px; }
.modal .mf { padding: 14px 20px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; }

label { display: block; font-size: 12px; font-weight: 650; color: #475569; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #fecaca;
  border-color: #ef4444;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-bottom: 12px; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filters input, .filters select {
  width: auto;
  min-width: 160px;
}

.cal-wrap { padding: 12px; }
#teamCal { min-height: 620px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 18px 14px;
  font-size: 12px;
  color: #475569;
}

.dot { width: 10px; height: 10px; border-radius: 99px; display: inline-block; margin-right: 6px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  display: none;
  z-index: 80;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.who-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; }
.who-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: #94a3b8;
}

.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted { color: #64748b; font-size: 12px; }

.bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.bar > span {
  display: block;
  height: 100%;
  background: #dc2626;
}
.bar.warn > span { background: #d97706; }
.bar.over > span { background: #e11d48; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.stat-box {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
}
.stat-box .k { font-size: 11px; color: #64748b; font-weight: 600; }
.stat-box .v { font-size: 16px; font-weight: 800; margin-top: 2px; }

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.pill.on { background: #b91c1c; color: white; border-color: #b91c1c; }

.rate-input {
  width: 120px;
  text-align: right;
}

@media print {
  .sidebar, .topbar, .nav, .btn, .filters, .toast, .modal-bg { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .panel { border: 0; }
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
  }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    z-index: 40;
    border-top: 1px solid #1e293b;
  }
  .brand, .sidebar-foot { display: none; }
  .nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
    overflow: visible;
  }
  .nav-full { display: none; }
  .nav-short { display: block; }
  .nav-btn {
    width: auto;
    min-width: 0;
    max-width: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    white-space: normal;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 600;
    padding: 8px 2px;
    letter-spacing: -0.01em;
  }
  .topbar { position: sticky; top: 0; z-index: 30; padding: 12px 16px; }
  .content { padding: 16px 14px 24px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card .value { font-size: 22px; }
  table { font-size: 12px; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; }
  .modal-bg { align-items: flex-end; padding: 0; }
}
.rate-input.sm { width: 88px; }
.warn-text { color: #c2410c; font-weight: 700; }
.danger-text { color: #e11d48; font-weight: 700; }
.ok-text { color: #059669; font-weight: 700; }
.alert-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; }
.alert {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #ffedd5;
  font-size: 13px;
}
.alert.bad { background: #fff1f2; border-color: #ffe4e6; }
.veh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .veh-grid { grid-template-columns: 1fr; } }

.tri-cal {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr 0.72fr;
  gap: 12px;
  padding: 8px 16px 20px;
  align-items: start;
}
.mini-cal {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px;
}
.mini-cal.feat {
  background: white;
  border-color: #fecaca;
  box-shadow: 0 0 0 3px #fee2e2;
  padding: 14px;
}
.mini-h {
  font-weight: 800;
  text-transform: capitalize;
  margin-bottom: 8px;
  font-size: 14px;
}
.mini-cal.feat .mini-h { font-size: 18px; }
.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.wd {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  font-weight: 700;
  padding-bottom: 4px;
}
.mday {
  border: 0;
  background: white;
  border-radius: 8px;
  min-height: 42px;
  padding: 4px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mini-cal.feat .mday { min-height: 64px; }
.mday:hover { background: #fef2f2; }
.mday.today { outline: 2px solid #dc2626; }
.mday.wknd { background: #f1f5f9; color: #64748b; }
.mday.hol { background: #f3e8ff; }
.mday.wx-half { background: #e0f2fe; }
.mday.wx-off { background: #ffedd5; }
.mday.empty-day { background: transparent; cursor: default; }
.dn { font-weight: 800; font-size: 12px; }
.mini-cal.feat .dn { font-size: 14px; }
.dm { font-size: 10px; color: #334155; }
.do { font-size: 9px; color: #64748b; line-height: 1.2; }
@media (max-width: 1100px) {
  .tri-cal { grid-template-columns: 1fr; }
}

.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-row input { width: auto; }
.mday.has-proj { background: #fef2f2; }
.cal-boards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .cal-boards { grid-template-columns: 1fr; } }
