:root {
  --sih-primary: #ea5b13;
  --sih-primary-hover: #c8490d;
  --sih-primary-active: #a83d0b;
  --sih-text: #1d1d1b;
  --sih-muted: #575656;
  --sih-surface: #ffffff;
  --sih-page: #f5f5f6;
  --sih-border: #d7d7d4;
  --sih-focus: #9c3b0b;
  --sih-sidebar: #ffffff;
  --sih-sidebar-active: #ea5b13;
}

body {
  background: var(--sih-page);
  color: var(--sih-text);
  font-family: Montserrat, Arial, sans-serif;
}

a:not(.btn) {
  color: var(--sih-primary-active);
}

a:not(.btn):hover {
  color: var(--sih-primary-hover);
}

.btn-primary {
  --bs-btn-bg: var(--sih-primary);
  --bs-btn-border-color: var(--sih-primary);
  --bs-btn-hover-bg: var(--sih-primary-hover);
  --bs-btn-hover-border-color: var(--sih-primary-hover);
  --bs-btn-active-bg: var(--sih-primary-active);
  --bs-btn-active-border-color: var(--sih-primary-active);
  --bs-btn-disabled-bg: var(--sih-primary);
  --bs-btn-disabled-border-color: var(--sih-primary);
  --bs-btn-color: #fff;
}

.btn {
  align-items: center;
  border-radius: .4rem;
  display: inline-flex;
  gap: .45rem;
  justify-content: center;
  line-height: 1.25;
  min-height: 2.375rem;
  padding: .5rem .85rem;
}

.btn-sm {
  min-height: 1.95rem;
  padding: .3rem .6rem;
}

.btn > .bi {
  line-height: 1;
}

.btn-outline-primary {
  --bs-btn-color: var(--sih-primary-active);
  --bs-btn-border-color: var(--sih-primary);
  --bs-btn-hover-bg: var(--sih-primary);
  --bs-btn-hover-border-color: var(--sih-primary);
  --bs-btn-active-bg: var(--sih-primary-active);
  --bs-btn-active-border-color: var(--sih-primary-active);
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
a:focus-visible,
.sidebar-toggle:focus-visible {
  box-shadow: 0 0 0 .25rem rgba(234, 91, 19, .32);
  outline: 0;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-card {
  background: var(--sih-surface);
  border-radius: .5rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  max-width: 420px;
  padding: 1.5rem;
  width: min(420px, calc(100vw - 2rem));
}

.login-brand {
  display: flex;
  justify-content: center;
  margin: .25rem 0 1.5rem;
}

.login-logo {
  display: block;
  height: auto;
  max-width: 100%;
  width: min(236px, 72vw);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}

.layout.sidebar-collapsed {
  grid-template-columns: 74px 1fr;
}

.sidebar {
  background: var(--sih-sidebar);
  border-right: 1px solid var(--sih-border);
  color: var(--sih-text);
  padding: 1rem;
  min-width: 0;
}

.brand {
  background: var(--sih-surface);
  border-bottom: 1px solid var(--sih-border);
  border-radius: .35rem;
  margin-bottom: .55rem;
  padding: .55rem .7rem;
}

.brand-row {
  align-items: flex-start;
  display: flex;
  gap: .5rem;
  justify-content: space-between;
}

.brand-identity {
  min-width: 0;
}

.sidebar-logo {
  display: block;
  height: auto;
  max-width: 204px;
  width: 100%;
}

.brand-text {
  color: var(--sih-muted);
  font-size: .72rem;
  line-height: 1.25;
  margin-top: .3rem;
}

.sidebar-toggle {
  align-items: center;
  background: var(--sih-surface);
  border: 1px solid var(--sih-border);
  border-radius: .4rem;
  color: var(--sih-text);
  display: inline-flex;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}

.sidebar-toggle:hover {
  background: #ececea;
}

.sidebar a {
  color: var(--sih-text);
  display: flex;
  gap: .65rem;
  align-items: center;
  padding: .7rem .8rem;
  text-decoration: none;
  border-radius: .4rem;
  margin-bottom: .2rem;
}

.sidebar a i {
  flex: 0 0 1.1rem;
  text-align: center;
}

.sidebar a:hover,
.sidebar a:focus-visible {
  background: #fbe8dd;
  color: var(--sih-primary-active);
}

.sidebar a.active {
  background: #fbe8dd;
  color: var(--sih-primary-active);
}

.sidebar-user {
  color: var(--sih-muted);
  overflow-wrap: anywhere;
}

.content {
  padding: 1.5rem;
  min-width: 0;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .sidebar a span {
  display: none;
}

.sidebar-collapsed .brand {
  display: flex;
  justify-content: center;
}

.sidebar-collapsed .brand-row {
  justify-content: center;
}

.sidebar-collapsed .sidebar {
  padding: 1rem .65rem;
}

.sidebar-collapsed .sidebar a {
  justify-content: center;
  padding: .7rem;
}

.metric-card {
  background: var(--sih-surface);
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}

.metric-label,
.dashboard-panel-title {
  color: var(--sih-text);
  font-weight: 700;
}

.metric-label {
  font-size: .82rem;
  margin-bottom: .2rem;
}

.dashboard-panel-title {
  margin-bottom: .9rem;
}

.metric-icon {
  color: var(--sih-muted);
  font-size: 1.65rem;
  opacity: .7;
}

.card {
  background: var(--sih-surface);
  border-color: var(--sih-border);
  box-shadow: 0 4px 14px rgba(29, 29, 27, .05);
}

.table-wrap {
  background: var(--sih-surface);
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
  max-width: 100%;
  max-height: calc(100vh - 220px);
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  scrollbar-gutter: stable both-edges;
}

.table-wrap table {
  min-width: 1050px;
}

.table-wrap thead th {
  background: #f8f8f8;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sortable-header {
  cursor: pointer;
  padding-right: 1.35rem !important;
  position: relative;
  user-select: none;
}

.sortable-header::after {
  color: #94a3b8;
  content: "↕";
  font-size: .75rem;
  position: absolute;
  right: .4rem;
}

.sortable-header.sort-asc::after { color: var(--sih-primary); content: "▲"; }
.sortable-header.sort-desc::after { color: var(--sih-primary); content: "▼"; }

.apurations-table-wrap table { min-width: 1900px; }
.apurations-table-wrap th[data-column="date"], .apurations-table-wrap td[data-column="date"] { left: 0; min-width: 112px; position: sticky; z-index: 3; }
.apurations-table-wrap th[data-column="registration"], .apurations-table-wrap td[data-column="registration"] { left: 112px; min-width: 92px; position: sticky; z-index: 3; }
.apurations-table-wrap th[data-column="employee"], .apurations-table-wrap td[data-column="employee"] { left: 204px; min-width: 190px; position: sticky; z-index: 3; }
.apurations-table-wrap td[data-column="date"], .apurations-table-wrap td[data-column="registration"], .apurations-table-wrap td[data-column="employee"] { background: #fff; }
.apurations-table-wrap th[data-column="date"], .apurations-table-wrap th[data-column="registration"], .apurations-table-wrap th[data-column="employee"] { z-index: 5; }
.employee-name-cell { white-space: nowrap; }
.situation-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-density-compact > :not(caption) > * > * { padding-bottom: .35rem; padding-top: .35rem; }
.table-density-comfortable > :not(caption) > * > * { padding-bottom: .75rem; padding-top: .75rem; }
.column-picker { max-height: 70vh; min-width: 280px; overflow-y: auto; }

.table-wrap .date-col {
  min-width: 112px;
  white-space: nowrap;
}

.clocking-times {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 4.5rem;
}

.clocking-times > div:not(.text-muted) {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
  background: #f8fafc;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.form-panel {
  background: var(--sih-surface);
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
  padding: 1rem;
}

.filter-panel > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: .75rem;
  list-style: none;
}

.filter-panel > summary::-webkit-details-marker {
  display: none;
}

.filter-panel > summary span {
  display: inline-block;
  font-weight: 700;
}

.filter-panel > summary small {
  color: #64748b;
  display: inline-block;
  font-weight: 400;
  margin-left: .65rem;
}

.filter-panel > summary::after {
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: .35rem;
  color: var(--sih-primary-active);
  content: "+";
  display: inline-flex;
  flex: 0 0 1.8rem;
  font-weight: 700;
  height: 1.8rem;
  justify-content: center;
  margin-left: auto;
  width: 1.8rem;
}

.filter-panel[open] > summary::after {
  content: "-";
}

.filter-command-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.filter-groups {
  display: grid;
  gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.check-filter {
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  padding: .75rem;
}

.check-filter summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  margin: -.1rem 0 .65rem;
}

.check-filter summary::-webkit-details-marker {
  display: none;
}

.check-filter summary span {
  font-weight: 600;
}

.check-filter summary small {
  color: #64748b;
}

.check-filter-options {
  display: grid;
  gap: .35rem;
  max-height: 210px;
  overflow: auto;
  padding-right: .25rem;
}

.check-option {
  align-items: flex-start;
  border-radius: .35rem;
  display: grid;
  gap: .5rem;
  grid-template-columns: auto 1fr;
  line-height: 1.25;
  padding: .35rem .25rem;
}

.check-option:hover {
  background: #f8f8f8;
}

.check-option span {
  overflow-wrap: anywhere;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .55rem 0;
  min-height: 1.7rem;
}

.admin-inline-form {
  background: #f8f8f8;
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  display: grid;
  gap: .5rem;
  min-width: 320px;
  padding: .75rem;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.toolbar-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
  align-items: center;
}

.count-pill {
  background: var(--sih-surface);
  border: 1px solid var(--sih-border);
  border-radius: .5rem;
  padding: .5rem .75rem;
}

.picker {
  display: grid;
  gap: .5rem;
}

.picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  min-height: 2rem;
}

.chip {
  align-items: center;
  background: #fbe8dd;
  border: 1px solid #f0b28f;
  border-radius: 999px;
  color: var(--sih-primary-active);
  display: inline-flex;
  gap: .35rem;
  max-width: 100%;
  padding: .25rem .55rem;
}

.chip span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip button {
  background: transparent;
  border: 0;
  color: inherit;
  line-height: 1;
  padding: 0;
}

pre.json-box {
  background: #111827;
  color: #e5e7eb;
  border-radius: .5rem;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
}

.page-link {
  color: var(--sih-primary-active);
}

.page-link:hover {
  color: var(--sih-primary-active);
  background: #fbe8dd;
}

.page-item.active .page-link {
  background: var(--sih-primary);
  border-color: var(--sih-primary);
}

@media (max-width: 900px) {
  .layout,
  .layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .sidebar-logo {
    max-width: 190px;
  }

  .sidebar-collapsed .brand-text,
  .sidebar-collapsed .sidebar a span {
    display: block;
  }

  .sidebar-collapsed .sidebar a {
    justify-content: flex-start;
  }

  .table-wrap {
    max-height: calc(100vh - 180px);
  }
}
