:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --border: #d7e0ea;
  --text: #152033;
  --text-soft: #4a5a73;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --danger: #b42318;
  --warning: #b54708;
  --chip-text: #0f172a;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #e8f3f2 0%, transparent 42%),
    radial-gradient(circle at 95% 20%, #e6eef8 0%, transparent 40%),
    var(--bg);
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1440px, 97vw);
  margin: 18px auto 40px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.app-header {
  background: linear-gradient(120deg, #ffffff, #f1f7fc);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  gap: 8px 12px;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 8px 14px;
}

.planning-switcher {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.planning-switcher label {
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.planning-switcher select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid #d8e6df;
  border-radius: 999px;
  background: #eff8f3;
  color: #0b5f59;
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 600;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: 0.15s ease;
}

.button:hover {
  border-color: #bccbda;
  transform: translateY(-1px);
}

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

.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.button-danger {
  background: #fff5f4;
  color: var(--danger);
  border-color: #f9d0cb;
}

.button-warning {
  background: #fff9f1;
  color: var(--warning);
  border-color: #f5d7ad;
}

.tabs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  padding: 8px;
  gap: 8px;
}

.tab-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text-soft);
}

.tab-btn.active {
  background: #ecf6f5;
  border-color: #bedfda;
  color: #064e48;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 170px;
}

.field-wide {
  min-width: min(420px, 100%);
  flex: 1 1 420px;
}

.field label {
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid #bfe4df;
  border-color: #91c8c0;
}

.field select[multiple] {
  min-height: 136px;
}

.access-editor {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-muted);
}

.access-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 180px);
  gap: 10px;
  align-items: center;
}

.access-user {
  font-size: 0.9rem;
  color: var(--text);
}

.access-empty {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.calendar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.calendar-meta p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.calendar-wall {
  --months-count: 6;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 4px;
}

.month-column {
  min-width: 208px;
  flex: 1 0 208px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.month-column-header {
  background: linear-gradient(120deg, #edf5fc, #f0faf6);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  font-weight: 700;
  text-transform: capitalize;
  font-size: 0.9rem;
}

.month-column-days {
  display: grid;
  gap: 0;
  padding: 6px;
}

.wall-day-row {
  min-height: 29px;
  padding: 0 5px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #ffffff;
}

.wall-day-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.week-tag,
.day-tag {
  display: inline-block;
  border-radius: 4px;
  line-height: 1.2;
  font-weight: 700;
}

.week-tag {
  min-width: 32px;
  text-align: center;
  font-size: 0.68rem;
  color: #566580;
  background: #f5f8fc;
  border: 1px solid #dde6f0;
  padding: 1px 3px;
}

.week-tag.empty {
  visibility: hidden;
}

.day-tag {
  min-width: 66px;
  font-size: 0.72rem;
  color: #25344c;
  padding: 1px 0;
}

.wall-day-periods {
  flex: 0 0 auto;
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(var(--track-count), 14px);
  gap: 4px;
  align-items: stretch;
  margin: 0;
}

.wall-day-periods.no-tracks {
  display: none;
}

.period-rail {
  display: block;
  position: relative;
  width: 14px;
  height: 100%;
}

.period-rail::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--rail-top, 0) * 1%);
  bottom: calc(var(--rail-bottom, 0) * 1%);
  min-height: 2px;
  background: var(--rail-fill-color, var(--rail-color, transparent));
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 0;
}

.period-rail.empty::before {
  display: none;
}

.period-rail.start::before {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.period-rail.end::before {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.period-rail.single::before {
  border-radius: 999px;
}

.period-rail.proposal::before {
  border: 2px solid var(--rail-color, rgba(15, 23, 42, 0.18));
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.88) 0 4px,
      rgba(255, 255, 255, 0.28) 4px 8px
    ),
    linear-gradient(var(--rail-fill-color, transparent), var(--rail-fill-color, transparent));
}

.legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: #ffffff;
  font-size: 0.82rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.15);
}

.legend-color.proposal-preview {
  border: 2px solid var(--primary);
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.88) 0 3px,
      rgba(255, 255, 255, 0.25) 3px 6px
    ),
    linear-gradient(rgba(15, 118, 110, 0.24), rgba(15, 118, 110, 0.24));
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border: 1px solid #e8edf2;
  padding: 7px;
  font-size: 0.86rem;
  vertical-align: top;
}

.data-table th {
  background: #f7fafd;
  text-align: left;
}

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

.proposal-details {
  display: grid;
  gap: 4px;
}

.proposal-color-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.section-separator {
  margin: 18px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.editor {
  width: 100%;
  min-height: 380px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 10px;
}

.message {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 0.87rem;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: #0a6d35;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 28, 0.62);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 999;
}

.login-card {
  width: min(560px, 94vw);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 12px;
}

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

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  max-width: 350px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.toast.visible {
  opacity: 1;
}

.print-header {
  margin-bottom: 14px;
}

.calendar-wall.print-compact .month-column {
  min-width: 180px;
}

.calendar-wall.print-compact .wall-day-row {
  min-height: 24px;
}

@media (max-width: 960px) {
  .header-meta {
    width: 100%;
    justify-content: stretch;
  }

  .planning-switcher {
    min-width: 100%;
  }

  .summary-chip {
    width: 100%;
    justify-content: center;
  }

  .month-column {
    min-width: 192px;
    flex-basis: 192px;
  }

  .day-tag {
    min-width: 58px;
  }

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

@page {
  size: A4 landscape;
  margin: 6mm;
}

@media print {
  html,
  body {
    width: 100%;
    margin: 0;
    background: #ffffff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell {
    width: 100%;
    margin: 0;
    gap: 2.6mm;
  }

  .app-header,
  .tabs,
  .overlay,
  .toast,
  .no-print {
    display: none !important;
  }

  .panel {
    box-shadow: none;
    border: 0.6px solid #c9d4df;
    border-radius: 4px;
    padding: 2.4mm;
  }

  .panel-title {
    margin: 0 0 1.4mm;
    font-size: 9px;
  }

  .calendar-wall {
    display: grid;
    grid-template-columns: repeat(var(--months-count), minmax(0, 1fr));
    gap: 1.2mm;
    overflow: hidden;
    align-items: stretch;
  }

  .month-column {
    min-width: 0;
    border: 0.6px solid #d2dde8;
    border-radius: 2px;
  }

  .month-column-header {
    border-bottom-width: 0.6px;
    padding: 1mm 1.2mm;
    font-size: 7.3px;
  }

  .month-column-days {
    gap: 0;
    padding: 0.55mm;
  }

  .wall-day-row {
    min-height: 3.9mm;
    padding: 0 0.45mm;
    gap: 0.7mm;
  }

  .week-tag,
  .day-tag {
    font-size: 5.5px;
    padding: 0;
    border-width: 0.4px;
  }

  .week-tag {
    min-width: 5.6mm;
  }

  .day-tag {
    min-width: 10.6mm;
  }

  .wall-day-periods {
    gap: 0.32mm;
    margin: 0;
  }

  .period-rail {
    width: 1.28mm;
    height: 100%;
  }

  .period-rail::before {
    min-height: 0.45mm;
    border-width: 0.35px;
  }

  .legend {
    margin-top: 1.2mm;
    gap: 0.8mm;
  }

  .legend-item {
    font-size: 6px;
    border-width: 0.45px;
    padding: 0.4mm 1.1mm;
    gap: 1mm;
  }

  .legend-color {
    width: 2mm;
    height: 2mm;
    border-width: 0.4px;
  }

  .message {
    font-size: 6px;
    min-height: 0;
    margin-top: 0.8mm;
  }
}
