:root {
  color-scheme: light;
  --canvas: #f6f6f4;
  --surface: #ffffff;
  --surface-muted: #f1f1ee;
  --ink: #181817;
  --muted: #6b6b66;
  --line: #deded9;
  --line-strong: #c7c7c0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eeedff;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #18794e;
  --success-soft: #edf8f2;
  --warning: #8a5a00;
  --sidebar-width: 236px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  transform: translateY(-160%);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 650;
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
}

.brand-block {
  padding: 0 10px 26px;
}

.brand {
  color: var(--ink);
  display: block;
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-caption {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.main-nav {
  display: grid;
  gap: 3px;
}

.main-nav a {
  border-radius: 6px;
  color: #3d3d39;
  font-size: 14px;
  font-weight: 560;
  padding: 9px 10px;
}

.main-nav a:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

.main-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 680;
}

.runtime {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  margin-top: auto;
  padding: 18px 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-form {
  margin: 12px 10px 0;
}

.logout-button {
  width: 100%;
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.logout-button:hover {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink);
}

.runtime span,
.runtime-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.runtime-up span,
.runtime-dot.runtime-up {
  background: #2b9a66;
}

.runtime-down span,
.runtime-dot.runtime-down {
  background: #cf7b22;
}

.workspace-shell {
  min-width: 0;
}

.mobile-header {
  display: none;
}

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

.mobile-logout {
  display: none;
}

.container {
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.footer {
  color: var(--muted);
  font-size: 12px;
  padding: 0 32px 30px;
  text-align: center;
}

.page-heading,
.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.page-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
}

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(27px, 3vw, 34px);
  line-height: 1.15;
  margin: 0 0 7px;
}

h2 {
  font-size: 18px;
  margin: 0 0 6px;
}

h3 {
  font-size: 15px;
}

p {
  color: var(--muted);
  margin: 6px 0;
}

small {
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 22px;
}

.table-card {
  overflow-x: auto;
  padding: 0;
}

.stat-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 22px;
  overflow: hidden;
}

.stat {
  min-width: 0;
  padding: 19px 20px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.stat:last-child {
  border-right: 0;
}

.stat span,
.stat small {
  color: var(--muted);
}

.stat span {
  font-size: 12px;
  font-weight: 650;
}

.stat strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 7px 0 5px;
  overflow-wrap: anywhere;
}

.actions,
.action-column {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-column {
  align-items: stretch;
  flex-direction: column;
}

.dashboard-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.action-hint {
  max-width: 590px;
  text-align: right;
}

button,
.button-link {
  appearance: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
}

button:hover,
.button-link:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}

button.secondary,
.button-link.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: #373733;
}

button.secondary:hover,
.button-link.secondary:hover {
  background: var(--surface-muted);
  border-color: #adada5;
}

button.danger,
.button-link.danger {
  background: var(--surface);
  border-color: #e6aaa4;
  color: var(--danger);
}

button.danger:hover,
.button-link.danger:hover {
  background: var(--danger-soft);
}

button.small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

button:disabled {
  background: var(--surface-muted);
  border-color: var(--line);
  color: #92928b;
  cursor: not-allowed;
}

:is(a, button, input, textarea, select, summary):focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.24);
  outline-offset: 2px;
}

label {
  color: #44443f;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 640;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
  font-weight: 400;
}

input::placeholder,
textarea::placeholder {
  color: #8a8a83;
  opacity: 1;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(79, 70, 229, 0.1);
}

.checkbox {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
}

.checkbox input {
  width: auto;
}

.checkbox.large {
  align-self: end;
  padding-bottom: 9px;
}

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

.form-grid.compact {
  grid-template-columns: 1fr 1fr 2fr auto;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form .grow {
  flex: 1 1 340px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 160px;
}

.align-end {
  display: flex;
  align-items: end;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

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

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

th {
  background: #fafaf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

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

.badge {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.neutral {
  background: var(--surface-muted);
  color: #55554f;
}

.alert {
  border: 1px solid;
  border-radius: 6px;
  margin-bottom: 18px;
  padding: 11px 13px;
}

.alert.success {
  background: var(--success-soft);
  border-color: #b7ddc9;
  color: #0f6841;
}

.alert.error {
  background: var(--danger-soft);
  border-color: #efbbb6;
  color: #8f1d14;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0, var(--accent-soft), transparent 38rem),
    var(--canvas);
}

.login-shell {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(24, 24, 23, 0.08);
  padding: 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
}

.login-brand img {
  border-radius: 9px;
}

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

.login-brand strong {
  font-size: 15px;
}

.login-brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.login-heading {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.login-heading h1 {
  font-size: 27px;
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 22px;
}

.login-form button {
  width: 100%;
  margin-top: 3px;
}

.login-note {
  border-top: 1px solid var(--line);
  font-size: 12px;
  margin: 22px 0 0;
  padding-top: 17px;
}

.progress-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 16px 0;
  overflow: hidden;
}

.progress-row div {
  border-right: 1px solid var(--line);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
}

.progress-row div:last-child {
  border-right: 0;
}

.progress-row strong {
  font-size: 20px;
}

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

.checklist {
  padding: 0;
  list-style: none;
}

.checklist li {
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.checklist li:last-child {
  border-bottom: 0;
}

.checklist li::before {
  display: inline-block;
  width: 22px;
}

.checklist .ok::before {
  color: var(--success);
  content: "✓";
}

.checklist .bad::before {
  color: var(--danger);
  content: "!";
}

.warning-text {
  color: var(--warning);
}

.top-gap {
  margin-top: 12px;
}

.invite-cell {
  min-width: 300px;
}

.copy-value {
  font-size: 12px;
}

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

.calendar-header {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
  text-align: center;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 4px 0 12px;
}

.calendar-legend span {
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #4d4d48;
  font-size: 11px;
  padding: 4px 7px;
}

.calendar-legend .workday,
.calendar-day.workday {
  background: #f0f8f3;
}

.calendar-legend .dayoff,
.calendar-day.dayoff {
  background: #fbf2f1;
}

.calendar-legend .today,
.calendar-day.today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-day {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-day.outside {
  opacity: 0.3;
}

.calendar-day span,
.calendar-day small {
  color: var(--muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.report-cell {
  min-width: 320px;
  max-width: 520px;
}

.report-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 8px;
}

.revision-history {
  margin-top: 10px;
}

.revision-history summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.revision-history article {
  border-left: 2px solid var(--line-strong);
  margin-top: 9px;
  padding: 7px 0 1px 11px;
}

.audit-details {
  min-width: 270px;
  max-width: 520px;
}

.audit-details pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
}

code {
  border-radius: 3px;
  background: var(--surface-muted);
  padding: 2px 5px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 206px;
  }

  .container {
    width: min(100% - 40px, 1180px);
    padding-top: 36px;
  }

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

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .form-grid,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

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

  .progress-row div:nth-child(2) {
    border-right: 0;
  }

  .progress-row div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0;
  }

  .brand-block,
  .runtime {
    display: none;
  }

  .sidebar .logout-form {
    display: none;
  }

  .mobile-logout {
    display: block;
  }

  .logout-button {
    width: auto;
    min-height: 30px;
    padding: 5px 9px;
  }

  .mobile-header {
    height: 54px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .main-nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 8px 12px;
    scrollbar-width: none;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .main-nav a {
    flex: 0 0 auto;
    padding: 7px 9px;
  }

  .container {
    width: min(100% - 28px, 720px);
    padding: 28px 0 52px;
  }

  .page-heading,
  .card-heading {
    flex-direction: column;
    gap: 14px;
  }

  .dashboard-controls {
    width: 100%;
    align-items: stretch;
  }

  .action-hint {
    text-align: left;
  }

  .table-card {
    overflow: visible;
    background: transparent;
    border: 0;
  }

  .responsive-table {
    display: block;
    min-width: 0;
  }

  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .responsive-table tbody {
    display: grid;
    gap: 10px;
  }

  .responsive-table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    padding: 12px 14px;
  }

  .responsive-table td {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: none;
    border: 0;
    padding: 7px 0;
    overflow-wrap: anywhere;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    margin-bottom: 4px;
  }

  .responsive-table td:empty,
  .responsive-table .empty-mobile {
    display: none;
  }

  .responsive-table .empty-cell {
    display: block;
  }

  .responsive-table .empty-cell::before {
    display: none;
  }

  .responsive-table .stack-form,
  .responsive-table .invite-cell,
  .responsive-table .report-cell,
  .responsive-table .audit-details {
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .login-shell {
    padding: 14px;
  }

  .login-card {
    padding: 22px;
  }

  .stat-grid,
  .progress-row {
    grid-template-columns: 1fr;
  }

  .stat,
  .progress-row div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat:last-child,
  .progress-row div:last-child {
    border-bottom: 0;
  }

  .actions,
  .dashboard-controls .actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .actions form,
  .actions button,
  .actions .button-link,
  .form-actions button {
    width: 100%;
  }

  .card {
    padding: 17px;
  }

  .calendar-grid {
    gap: 3px;
  }

  .calendar-day {
    min-height: 43px;
    padding: 5px;
  }

  .calendar-day span,
  .calendar-day small {
    display: none;
  }
}
