:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #eef7f5;
  --text: #18222f;
  --muted: #697586;
  --line: #dfe5ec;
  --primary: #0f766e;
  --primary-dark: #0b5d56;
  --accent: #f97316;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(249, 115, 22, 0.09), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0;
}

.brand,
.account,
.nav-links {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 210px;
}

.brand-mark,
.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.logo-mark {
  width: 58px;
  height: 46px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
}

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

.brand small,
.person-cell small,
.user-card small,
.away-item small,
.muted {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-links {
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.nav-links a {
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
}

.nav-links a.active,
.nav-links a:hover {
  background: var(--text);
  color: #fff;
}

.account {
  justify-content: flex-end;
  gap: 10px;
  min-width: 310px;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.language-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 30px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.language-switch a.active,
.language-switch a:hover {
  background: var(--primary);
  color: #fff;
}

.role-pill,
.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.role-pill {
  background: #fff3e8;
  color: #9a4b05;
}

main {
  padding-bottom: 48px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.flash {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.06);
  font-weight: 700;
}

.flash.success {
  border-color: #99f6e4;
  color: #0f766e;
}

.flash.error {
  border-color: #fecaca;
  color: #b91c1c;
}

.flash.info {
  border-color: #fed7aa;
  color: #9a3412;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 140px);
}

.auth-copy h1,
.page-head h1,
.narrow-page h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.auth-copy p:not(.eyebrow) {
  max-width: 570px;
  color: var(--muted);
  font-size: 1.12rem;
}

.panel {
  border: 1px solid rgba(223, 229, 236, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-card {
  display: grid;
  gap: 18px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 20px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-heading {
  margin-bottom: 20px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 20px;
}

.two-column {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  align-items: stretch;
}

.admin-grid {
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input[type="file"] {
  padding: 9px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

form {
  margin: 0;
}

.form-grid,
.filters,
.button-row,
.stats-row,
.toggle-row,
.search-form,
.year-filter {
  display: flex;
  gap: 12px;
}

.form-grid > * {
  flex: 1 1 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.2);
}

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

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.button.ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
}

.button.danger {
  background: #fff1f2;
  color: var(--danger);
}

.button.wide {
  width: 100%;
}

.button.tiny {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.stats-row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-tile {
  min-width: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
  box-shadow: 0 12px 24px rgba(31, 41, 55, 0.08);
}

.stat-tile strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.stat-tile span {
  color: var(--muted);
  font-weight: 700;
}

.stat-tile.accent strong {
  color: var(--accent);
}

.search-form,
.year-filter {
  align-items: end;
}

.search-form label {
  min-width: min(320px, 100%);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  align-items: stretch;
}

.chart-panel {
  min-height: 360px;
}

.month-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(46px, 1fr));
  gap: 10px;
  min-height: 250px;
  align-items: end;
}

.month-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.bar-track {
  position: relative;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--primary));
}

.month-bar strong {
  font-size: 0.95rem;
}

.month-bar span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.leader-list {
  display: grid;
  gap: 14px;
}

.leader-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(160px, 1.4fr) 48px;
  gap: 12px;
  align-items: center;
}

.leader-label {
  min-width: 0;
}

.leader-label strong,
.leader-label small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-meter {
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  overflow: hidden;
}

.leader-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.leader-value {
  text-align: right;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.calendar-panel {
  margin-bottom: 20px;
}

.calendar-head,
.calendar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.calendar-actions {
  justify-content: flex-end;
}

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

.calendar-weekdays {
  margin-top: 2px;
  border-bottom: 1px solid var(--line);
}

.calendar-weekdays span {
  padding: 0 8px 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-grid-month {
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
}

.calendar-cell {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 7px;
  min-height: 118px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.calendar-cell:nth-child(7n) {
  border-right: 0;
}

.calendar-cell:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.calendar-cell:hover,
.calendar-cell.selected {
  background: #f0fdfa;
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.25);
}

.calendar-cell.outside-month {
  background: #f8fafc;
  color: #9aa5b1;
}

.calendar-cell.today .calendar-date-number {
  background: var(--primary);
  color: #fff;
}

.calendar-cell.public-holiday {
  background: #fff7ed;
}

.calendar-cell.public-holiday.selected,
.calendar-cell.public-holiday:hover {
  background: #ffedd5;
}

.calendar-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.calendar-date-number {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  font-weight: 900;
}

.holiday-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.calendar-event-stack {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.calendar-event-pill {
  overflow: hidden;
  min-height: 24px;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  background: #e6fffb;
  color: #115e59;
  padding: 3px 6px;
  font-size: 0.74rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-pill.event-color-1 {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.calendar-event-pill.event-color-2 {
  border-color: #f97316;
  background: #fff7ed;
  color: #c2410c;
}

.calendar-event-pill.event-color-3 {
  border-color: #7c3aed;
  background: #f5f3ff;
  color: #6d28d9;
}

.calendar-event-pill.event-color-4 {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #15803d;
}

.calendar-more {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.calendar-detail {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.calendar-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-detail h3 {
  margin: 0;
}

.holiday-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  border-radius: 999px;
  background: #ffedd5;
  color: #c2410c;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.calendar-detail-list,
.period-list {
  display: grid;
  gap: 8px;
}

.calendar-detail-item,
.period-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.calendar-detail-item {
  display: grid;
  gap: 2px;
}

.calendar-detail-item strong,
.calendar-detail-item small,
.period-pill span {
  min-width: 0;
}

.period-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.period-pill strong {
  flex: 0 0 auto;
  color: var(--primary);
}

.employee-vacation-panel table {
  min-width: 960px;
}

.away-panel {
  background: linear-gradient(135deg, #ffffff, var(--surface-soft));
}

.away-list,
.user-list {
  display: grid;
  gap: 12px;
}

.away-item,
.person-cell,
.user-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar.small {
  width: 34px;
  height: 34px;
  font-size: 0.9rem;
}

.empty-text,
.empty-table,
.helper-text {
  color: var(--muted);
  font-weight: 700;
}

.helper-text {
  margin: -4px 0 0;
  font-size: 0.9rem;
}

.table-panel {
  margin-top: 20px;
  padding: 0;
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.filters {
  align-items: end;
  flex-wrap: wrap;
}

.filters label {
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fbfcfd;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:hover {
  background: #fbfcfd;
}

.status.now {
  background: #ccfbf1;
  color: #0f766e;
}

.status.upcoming {
  background: #ffedd5;
  color: #c2410c;
}

.status.past {
  background: #e5e7eb;
  color: #4b5563;
}

.actions-cell {
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  margin-left: 6px;
}

.narrow-page {
  width: min(620px, 100%);
  margin: 38px auto;
}

.narrow-page .panel,
.admin-grid > .panel:first-child,
.panel:not(.table-panel) {
  display: grid;
  gap: 16px;
}

.readout {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.readout span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.users-panel {
  box-shadow: var(--shadow);
}

.file-schema {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.file-schema span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 900;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 0.9fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.user-profile-form,
.reset-form {
  display: grid;
  gap: 12px;
}

@media (max-width: 900px) {
  .topbar,
  .page-head,
  .table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .account,
  .nav-links {
    min-width: 0;
  }

  .nav-links,
  .account {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .auth-layout,
  .two-column,
  .admin-grid,
  .dashboard-grid,
  .user-card {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    min-height: auto;
    padding: 30px 0;
  }

  .form-grid,
  .filters,
  .button-row,
  .stats-row,
  .toggle-row,
  .search-form,
  .year-filter {
    flex-direction: column;
  }

  .stats-row {
    justify-content: stretch;
  }

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

  .month-chart {
    overflow-x: auto;
    grid-template-columns: repeat(12, 52px);
    padding-bottom: 8px;
  }

  .leader-row {
    grid-template-columns: 1fr;
  }

  .leader-value {
    text-align: left;
  }

  .calendar-head,
  .calendar-detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-actions {
    justify-content: flex-start;
  }

  .calendar-grid-month,
  .calendar-weekdays {
    min-width: 760px;
  }

  .calendar-panel {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .panel {
    padding: 18px;
  }

  .auth-copy h1,
  .page-head h1,
  .narrow-page h1 {
    font-size: 2.2rem;
  }

  .table-head {
    padding: 18px;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .calendar-cell {
    min-height: 104px;
  }

  .period-pill {
    align-items: flex-start;
    flex-direction: column;
  }
}
