:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef4f3;
  --ink: #1d2329;
  --muted: #66717c;
  --line: #dce2e7;
  --brand: #166a5f;
  --brand-strong: #0f4d45;
  --accent: #c9572f;
  --amber: #b47b13;
  --green-soft: #e5f3ef;
  --red-soft: #faebe7;
  --shadow: 0 16px 40px rgba(24, 37, 45, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.auth-locked .app-shell {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(24, 37, 45, 0.78);
}

body.auth-locked .auth-screen {
  display: grid;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.login-brand {
  color: var(--ink);
}

.login-brand span {
  color: var(--muted);
}

.login-error {
  min-height: 20px;
  color: #a9151e;
  font-weight: 700;
}

.checkbox-field {
  align-self: end;
  display: flex;
  flex-direction: row;
  gap: 10px;
  min-height: 44px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  background: #18252d;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 54px;
  min-width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #fff;
  padding: 5px;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.ghost-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  color: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.nav-tab:hover,
.nav-tab.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  line-height: 1;
}

.sidebar-footer {
  margin-top: auto;
}

.ghost-button {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.8);
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-toolbar,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin-top: 3px;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px 6px 4px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.icon-button,
.segment,
.quick-action,
.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}

.primary-button {
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button {
  padding: 0 14px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #bdc8d0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.metric-card,
.panel,
.form-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 32px;
  line-height: 1;
}

.metric-card.alert {
  background: var(--red-soft);
  border-color: #efd3cb;
}

.metric-card.danger {
  background: #d11f2a;
  border-color: #a9151e;
  color: #fff;
}

.metric-card.danger span,
.metric-card.danger small {
  color: rgba(255, 255, 255, 0.86);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 18px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
}

.calendar-panel {
  min-width: 0;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-weekdays span {
  padding: 0 4px;
}

.calendar-day {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--ink);
  text-align: left;
}

.calendar-day:hover,
.calendar-day.selected {
  border-color: var(--brand);
  outline: 3px solid rgba(22, 106, 95, 0.12);
}

.calendar-day.muted {
  background: #f0f3f5;
  color: var(--muted);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(22, 106, 95, 0.28);
}

.calendar-day.danger {
  border-color: #d11f2a;
  background: #fff0f1;
}

.calendar-day.off {
  background: #f7f8f9;
}

.calendar-day-number {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.coverage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 900;
}

.coverage-pill.danger {
  background: #d11f2a;
  color: #fff;
}

.calendar-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.calendar-absences {
  display: grid;
  gap: 4px;
}

.calendar-absence {
  overflow: hidden;
  border-radius: 6px;
  background: #fff2d4;
  color: #805600;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-details {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.day-person {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.day-person.absent {
  border-color: #efd3cb;
  background: var(--red-soft);
}

.day-person.changed {
  border-color: #f0dca8;
  background: #fff8e6;
}

.day-person strong,
.day-person span {
  display: block;
}

.day-person span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.weekly-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 240px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.bar-item {
  display: grid;
  align-items: end;
  gap: 8px;
  min-width: 0;
  height: 196px;
}

.bar {
  min-height: 8px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #2d8b7c, #166a5f);
}

.bar-label,
.bar-value {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.compact-item,
.leave-card,
.employee-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compact-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.pending {
  background: #fff2d4;
  color: #805600;
}

.status-pill.rejected {
  background: var(--red-soft);
  color: #9a3218;
}

.section-toolbar {
  margin: 4px 0 16px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(22, 106, 95, 0.14);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(116px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
}

.compact-form {
  display: grid;
  grid-template-columns: 120px 180px auto auto minmax(180px, 1fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-hint {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.notes-field {
  grid-column: span 2;
}

.form-submit {
  align-self: end;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.row-action {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.row-action:hover {
  border-color: #bdc8d0;
  color: var(--ink);
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--brand);
  color: #fff;
}

.leave-grid,
.employee-grid,
.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.leave-card,
.employee-card,
.document-card {
  padding: 16px;
  box-shadow: var(--shadow);
}

.document-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.payroll-preview {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.payroll-preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.balance-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.balance-chip {
  border-radius: 8px;
  background: var(--surface-2);
  padding: 8px;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
}

.card-title-row,
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title-row h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.meta-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

.progress {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e6ecef;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 22px;
}

dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

dialog::backdrop {
  background: rgba(18, 27, 34, 0.48);
}

.dialog-card {
  padding: 18px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.quick-action {
  display: grid;
  min-height: 96px;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.quick-action:hover {
  border-color: var(--brand);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #18252d;
  color: #fff;
  box-shadow: 0 18px 45px rgba(24, 37, 45, 0.22);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-tab {
    justify-content: center;
  }

  .sidebar-footer {
    display: none;
  }

  .metrics-grid,
  .content-grid,
  .calendar-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.wide {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-toolbar,
  .panel-header {
    display: grid;
  }

  .topbar-actions,
  .filter-row {
    width: 100%;
  }

  .topbar-actions > *,
  .filter-row > * {
    flex: 1 1 180px;
  }

  .nav-tabs,
  .metrics-grid,
  .content-grid,
  .calendar-layout,
  .form-grid,
  .compact-form,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 112px;
  }

  h1 {
    font-size: 26px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }

  .weekly-chart {
    grid-template-columns: repeat(7, minmax(32px, 1fr));
    gap: 7px;
  }

  .notes-field {
    grid-column: auto;
  }
}
