:root {
  --bg: #eef4f8;
  --panel: #ffffff;
  --panel-soft: #f6f9fb;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e1ea;
  --line-strong: #b8c7d6;
  --accent: #167a8b;
  --accent-strong: #0d5f70;
  --accent-soft: #dff5f7;
  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --warning: #a46011;
  --warning-soft: #fff3d6;
  --danger: #b42318;
  --danger-soft: #ffe5e0;
  --ok: #1f7a45;
  --ok-soft: #e2f6ea;
  --violet: #6b5bd2;
  --violet-soft: #eeeafd;
  --shadow: 0 14px 34px rgba(32, 50, 71, 0.09);
  --shadow-soft: 0 6px 18px rgba(32, 50, 71, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(229, 244, 249, 0.9), rgba(238, 244, 248, 0.7) 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
  letter-spacing: 0;
  scroll-behavior: smooth;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 120ms ease;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 122, 139, 0.16);
}

select,
input {
  min-height: 38px;
  padding: 0 12px;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(216, 225, 234, 0.82);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 15px;
}

.nav-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 249, 251, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.nav-tab {
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 104px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.nav-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(32, 50, 71, 0.11);
}

.nav-tab[hidden] {
  display: none;
}

.user-panel {
  display: grid;
  grid-template-columns: auto minmax(160px, 240px);
  justify-content: end;
  align-items: center;
  gap: 10px;
}

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

main {
  min-width: 0;
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.primary-button {
  border-color: var(--accent);
  background: linear-gradient(180deg, #1c8fa0, var(--accent));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(22, 122, 139, 0.22);
}

.primary-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 88px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdfe);
  box-shadow: var(--shadow-soft);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  word-break: break-word;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar button {
  width: 38px;
  padding: 0;
  font-size: 20px;
  font-weight: 800;
}

.calendar-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.calendar-table,
.request-board,
.balance-table,
.settings-layout,
.context-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(116px, 1fr));
}

.month-weekday {
  padding: 11px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #eaf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.month-day {
  min-height: 132px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  transition: background 160ms ease;
}

.month-day:hover {
  background: #f8fcfd;
}

.month-day.day-off {
  background: #fff8e8;
}

.month-day.short-day {
  background: #effaf5;
}

.month-day.outside {
  background: #f7f9fb;
}

.day-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.day-head strong {
  font-size: 15px;
}

.day-head span {
  color: var(--muted);
  font-size: 11px;
}

.day-vacations {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.vacation-chip {
  display: block;
  overflow: hidden;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.vacation-chip.approved {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: #b8e6e7;
}

.vacation-chip.pending {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #f3d39b;
}

.vacation-chip.type-day_off {
  background: var(--blue-soft);
  color: #2458bd;
  border-color: #c9d9ff;
}

.vacation-chip.type-sick {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #ffc7bf;
}

.vacation-chip.type-business_trip {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: #d8d1ff;
}

.context-panel {
  display: grid;
  gap: 0;
  position: sticky;
  top: 92px;
}

.context-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.context-section:last-child {
  border-bottom: 0;
}

.balance-card {
  background: linear-gradient(145deg, #123f51, #176f80);
  color: #fff;
}

.balance-card .context-label,
.balance-card .balance-strip {
  color: rgba(255, 255, 255, 0.72);
}

.balance-card strong {
  font-size: 42px;
}

.balance-strip {
  display: grid;
  gap: 3px;
  font-size: 12px;
}

.context-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.section-head span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  font-size: 13px;
}

.compact-item span {
  color: var(--muted);
  font-size: 12px;
}

.request-row,
.balance-row {
  display: grid;
  align-items: start;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.request-row {
  grid-template-columns: minmax(260px, 1.3fr) minmax(170px, 0.7fr) 150px 180px;
}

.balance-row {
  grid-template-columns: 1.4fr repeat(4, minmax(90px, 1fr)) 150px;
}

.request-row:last-child,
.balance-row:last-child {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status.approved {
  background: var(--ok-soft);
  color: var(--ok);
}

.status.pending_manager,
.status.pending_hr {
  background: var(--warning-soft);
  color: var(--warning);
}

.status.rejected,
.status.cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.request-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.task-card {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid #cfe3df;
  border-radius: 8px;
  background: #f7fcfc;
}

.checklist {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.balance-input {
  width: 100%;
}

.settings-layout {
  display: grid;
}

.planning-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.planning-panel,
.planning-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.planning-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  position: sticky;
  top: 92px;
  background: linear-gradient(180deg, #ffffff, #f8fcfd);
}

.planning-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.plan-person {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.plan-person:last-child {
  border-bottom: 0;
}

.plan-person-head,
.plan-period {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.plan-person-head span,
.plan-period span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.plan-periods {
  display: grid;
  gap: 8px;
}

.plan-period {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.plan-period button {
  min-height: 32px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
}

.settings-layout {
  display: grid;
}

.settings-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-card:last-child {
  border-bottom: 0;
}

.rules-table,
.notice-list,
.audit-list,
.access-list {
  display: grid;
  gap: 8px;
}

.rules-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(110px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.notice-row,
.audit-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.audit-row {
  grid-template-columns: 150px 1fr 1fr 1fr;
}

.access-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 120px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.access-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.access-state {
  display: inline-flex;
  justify-content: center;
  min-height: 26px;
  padding: 6px 8px;
  border-radius: 999px;
  font-weight: 800;
}

.access-state.on {
  background: var(--ok-soft);
  color: var(--ok);
}

.access-state.off {
  background: var(--danger-soft);
  color: var(--danger);
}

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(24, 33, 43, 0.48);
}

.dialog-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-hint {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

  .nav-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .user-panel {
    justify-content: start;
  }

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

  .planning-layout {
    grid-template-columns: 1fr;
  }

  .context-panel {
    position: static;
  }

  .planning-panel {
    position: static;
  }
}

@media (max-width: 860px) {
  main,
  .app-header {
    padding: 18px;
  }

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

  .month-grid {
    overflow-x: auto;
    grid-template-columns: repeat(7, minmax(112px, 1fr));
  }

  .request-row,
  .balance-row,
  .rules-row,
  .audit-row,
  .access-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 24px;
  }

  .topbar,
  .toolbar,
  .date-row,
  .user-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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