:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8dee8;
  --line-strong: #b8c2d1;
  --text: #18202f;
  --muted: #667085;
  --accent: #1f6feb;
  --accent-dark: #1557c0;
  --accent-soft: #eaf2ff;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --warning: #9a5b00;
  --warning-soft: #fff5df;
  --success: #14783f;
  --success-soft: #e8f6ee;
  --focus: rgba(31, 111, 235, 0.25);
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.08), 0 10px 30px rgba(20, 28, 45, 0.05);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 6px;
  margin-inline: -4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 2px 4px 4px;
  scrollbar-width: none;
}

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

.nav a,
.nav button {
  display: inline-flex;
  min-height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.nav a:hover,
.nav button:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  text-decoration: none;
}

.topbar > .actions {
  align-items: center;
  justify-content: space-between;
}

.user-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.container {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 16px 12px 28px;
}

.page-head,
.calendar-head {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.page-head h1,
.page-head h2,
.calendar-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
}

.page-head p,
.calendar-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.actions > *,
.toolbar button,
.inline-form button {
  flex: 1 1 auto;
}

.button,
button,
input[type="submit"] {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

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

.button:hover,
button:hover,
input[type="submit"]:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  text-decoration: none;
}

.button.primary,
button.primary,
input[type="submit"].primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover,
button.primary:hover,
input[type="submit"].primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.button.danger,
button.danger {
  border-color: #f2b7af;
  color: var(--danger);
  background: var(--danger-soft);
}

.toolbar,
.panel,
.table-wrap,
.stat-card,
.day-column,
.item-card,
.comment,
.login-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar,
.panel {
  margin-bottom: 14px;
  padding: 14px;
}

.toolbar form,
.inline-form {
  display: grid;
  gap: 10px;
}

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

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat-card {
  min-height: 96px;
  padding: 14px;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

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

.table-wrap {
  overflow: hidden;
}

table,
thead,
tbody,
tr,
th,
td {
  display: block;
}

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

tbody {
  display: grid;
  gap: 10px;
  padding: 10px;
}

tr {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

td {
  display: grid;
  grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td[colspan] {
  grid-template-columns: 1fr;
}

td[colspan]::before {
  content: none;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

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

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

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

.error-box {
  margin-bottom: 14px;
  border: 1px solid #f3b5ad;
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
}

.calendar-board {
  display: grid;
  gap: 12px;
}

.day-column {
  min-height: 0;
  overflow: hidden;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 800;
}

.day-items {
  display: grid;
  gap: 9px;
  padding: 10px;
}

.item-card {
  display: grid;
  gap: 8px;
  padding: 11px;
  color: var(--text);
}

.item-card:hover {
  border-color: var(--line-strong);
  background: #fcfdff;
  text-decoration: none;
}

.item-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-grid {
  display: grid;
  gap: 14px;
}

.kv {
  display: grid;
  gap: 10px;
}

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

.kv dd {
  margin: -7px 0 0;
  min-width: 0;
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.comment {
  padding: 11px;
  background: #fbfcfe;
}

.comment p {
  margin: 8px 0;
}

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

.login-box {
  width: min(420px, 100%);
  padding: 18px;
}

@media (min-width: 560px) {
  .container {
    padding: 22px 18px 34px;
  }

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

  .toolbar form,
  .inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .toolbar button,
  .inline-form button {
    align-self: end;
  }
}

@media (min-width: 760px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 12px 22px;
  }

  .nav {
    justify-content: center;
    margin-inline: 0;
    overflow: visible;
    padding: 0;
  }

  .topbar > .actions {
    justify-content: end;
  }

  .page-head,
  .calendar-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 18px;
    margin-bottom: 18px;
  }

  .actions > * {
    flex: 0 0 auto;
  }

  .actions form,
  .actions form button {
    width: auto;
  }

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

  .detail-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  }

  .kv {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 9px 14px;
  }

  .kv dd {
    margin: 0;
  }
}

@media (min-width: 980px) {
  .stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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

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

  thead {
    position: static;
    display: table-header-group;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  tbody {
    display: table-row-group;
    padding: 0;
  }

  tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
  }

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

  th {
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 13px;
    font-weight: 800;
  }

  td::before {
    content: none;
  }

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

@media (min-width: 1120px) {
  .calendar-board {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
  }

  .day-column {
    min-height: 380px;
  }
}
