:root {
  color-scheme: light;
  --background: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-muted: #f0f1f3;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --primary: #0071e3;
  --primary-dark: #0068d1;
  --danger: #d70015;
  --warning: #b45b00;
  --info: #0071e3;
  --success: #248a3d;
  --focus: rgba(0, 113, 227, 0.22);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.08);
  --shadow-light: 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Text",
    "SF Pro Display",
    "Segoe UI",
    system-ui,
    sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 32px;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 24px;
}

.auth-brand {
  padding-top: 28px;
}

.brand-logo {
  display: block;
  width: min(220px, 70vw);
  height: auto;
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-soft);
}

.auth-brand h1 {
  margin: 0 0 10px;
  font-size: 44px;
  line-height: 1.05;
  font-weight: 700;
}

.auth-brand p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.auth-panels {
  display: grid;
  gap: 16px;
}

.technical-settings {
  display: grid;
  gap: 10px;
}

.technical-settings summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.technical-settings label {
  margin-top: 10px;
}

.app-layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(210, 210, 215, 0.72);
  background: rgba(255, 255, 255, 0.72);
  padding: 20px;
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  padding-bottom: 8px;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow-light);
}

.sidebar-brand strong {
  display: block;
  font-size: 21px;
  font-weight: 700;
}

.sidebar-brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.tabs {
  display: grid;
  gap: 4px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  font-weight: 600;
  transition:
    background 0.16s ease,
    color 0.16s ease;
}

.tab.active {
  background: #e8eef8;
  color: #0057b8;
}

.tab:hover {
  background: var(--surface-muted);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 0 0 4px;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel {
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-light);
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header p {
  margin: 4px 0 0;
}

.stack {
  display: grid;
  gap: 14px;
}

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

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

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

.tab-panel {
  display: grid;
  gap: 16px;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 9px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
  background: #fff;
}

input::placeholder,
textarea::placeholder {
  color: #8e8e93;
}

input[type="file"] {
  padding-top: 8px;
}

.checkbox {
  align-items: center;
  grid-template-columns: auto 1fr;
  min-height: 42px;
}

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

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

.weekday-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-solid);
}

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

.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 15px;
  color: var(--text);
  background: #e9e9ec;
  font-weight: 600;
  transition:
    transform 0.12s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

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

.button:active {
  transform: translateY(0);
}

.button.primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 113, 227, 0.22);
}

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

.button.secondary {
  border: 1px solid var(--border);
  background: #fff;
}

.wide-button {
  width: 100%;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

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

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

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.tariff-list {
  display: grid;
  gap: 10px;
}

.tariff-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 29, 31, 0.28);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.setup-wizard {
  display: grid;
  gap: 16px;
}

.setup-wizard-modal {
  width: min(940px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.setup-wizard-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.setup-step {
  display: grid;
  gap: 8px;
  min-height: 142px;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.setup-step.done {
  border-color: rgba(36, 138, 61, 0.35);
  background: #f4fbf6;
}

.setup-step-number {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #e9e9ec;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.setup-step.done .setup-step-number {
  background: var(--success);
  color: #fff;
}

.checklist-source-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.checklist-page {
  display: grid;
  gap: 18px;
}

.checklist-template-wizard {
  display: grid;
  gap: 14px;
}

.checklist-template-wizard summary {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  list-style: none;
}

.checklist-template-wizard summary::-webkit-details-marker {
  display: none;
}

.checklist-template-wizard summary::after {
  content: "Открыть";
  margin-left: auto;
  border-radius: 8px;
  background: #e9e9ec;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.checklist-template-wizard[open] summary::after {
  content: "Свернуть";
}

.checklist-template-wizard .checklist-templates-panel,
.checklist-template-wizard .checklist-upload-panel {
  min-width: 0;
  border: 1px solid rgba(210, 210, 215, 0.78);
  border-radius: 8px;
  background: #f9f9fb;
  padding: 14px;
}

.checklist-templates-panel,
.checklist-library-panel {
  display: grid;
  gap: 14px;
}

.template-apply-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(200px, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid rgba(210, 210, 215, 0.8);
  border-radius: 8px;
  background: #f9f9fb;
  padding: 14px;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.template-list .item {
  min-height: 100%;
}

.checklist-builder-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.checklist-form-card {
  align-content: start;
  min-width: 0;
}

.checklist-form-card p {
  margin: 4px 0 0;
}

.checklist-settings-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(120px, 0.7fr) minmax(
      180px,
      1fr
    );
  gap: 12px;
  align-items: end;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.file-field input[type="file"] {
  min-height: 48px;
  border-style: dashed;
  background: #fff;
}

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 12px;
  border: 0;
  border-radius: 8px;
  background: #e9e9ec;
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.checklist-form-card .weekday-row {
  gap: 6px;
}

.checklist-form-card .weekday-row label {
  min-width: 48px;
  justify-content: center;
}

.checklist-library-panel .panel-header {
  align-items: end;
}

.checklist-library-panel .panel-header select {
  max-width: 340px;
}

.checklist-list-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(340px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.list-column {
  display: grid;
  gap: 10px;
  min-height: 160px;
  border: 1px solid rgba(210, 210, 215, 0.78);
  border-radius: 8px;
  background: #f9f9fb;
  padding: 12px;
}

.list-column-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 82px;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-light);
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.list.compact {
  gap: 8px;
}

.item {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: var(--surface-solid);
  padding: 12px;
  color: var(--text);
  text-align: left;
}

.item-button {
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.item-button:hover,
.item-button.selected {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.12);
  transform: translateY(-1px);
}

.item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  font-size: 15px;
  font-weight: 700;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

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

.notification-wrap {
  position: relative;
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.popover {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 10px;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.notification-item.unread {
  border-left: 4px solid var(--primary);
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.new,
.pill.in_progress {
  border-color: rgba(180, 91, 0, 0.4);
  color: var(--warning);
}

.pill.submitted {
  border-color: rgba(0, 113, 227, 0.42);
  color: var(--info);
}

.pill.accepted {
  border-color: rgba(36, 138, 61, 0.42);
  color: var(--success);
}

.pill.rejected,
.pill.expired {
  border-color: rgba(215, 0, 21, 0.42);
  color: var(--danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.detail-item {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.detail-item strong {
  font-size: 14px;
  font-weight: 700;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.calendar-day {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(210, 210, 215, 0.86);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-light);
}

.mini-task {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid #ececf0;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.mini-task span:first-child {
  color: var(--text);
  font-weight: 700;
}

.notice {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-weight: 600;
}

.global-notice {
  position: fixed;
  z-index: 50;
  top: 16px;
  left: 50%;
  width: min(720px, calc(100vw - 32px));
  transform: translateX(-50%);
  box-shadow: var(--shadow-soft);
}

.notice.error {
  border-left-color: var(--danger);
}

.lists-pair {
  align-items: start;
}

@media (max-width: 980px) {
  .auth-layout,
  .app-layout,
  .grid.two,
  .grid.three,
  .inline-form,
  .tariff-card,
  .setup-steps,
  .checklist-source-grid,
  .template-apply-form,
  .checklist-builder-grid,
  .checklist-settings-grid,
  .checklist-list-grid,
  .metric-row,
  .detail-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 16px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .mini-task {
    grid-template-columns: 1fr;
  }

  .checklist-library-panel .panel-header {
    align-items: stretch;
  }

  .checklist-library-panel .panel-header select {
    max-width: none;
  }
}
