:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6b76;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #027a48;
  --border: #d9dee3;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #efe7d7 0%, var(--bg) 220px);
  color: var(--text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar,
.tabs,
.status-bar,
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar,
.panel-header,
.inline-actions,
.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

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

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

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

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.danger,
button.link.danger {
  background: transparent;
  color: var(--danger);
  padding: 0;
}

button.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tabs button {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-dark);
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.status-bar {
  color: var(--muted);
  margin-bottom: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel.compact {
  margin-bottom: 1rem;
}

.panel-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.form-grid label,
.inline-actions label,
.demand-grid label,
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 160px;
}

.checkbox {
  flex-direction: row !important;
  align-items: center;
}

input[type="text"],
input[type="number"],
input[type="time"],
select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.bedarf-list {
  display: grid;
  gap: 1rem;
}

.bedarf-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  background: #fcfcfb;
}

.bedarf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.shift-summary,
.demand-grid {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.shift-block,
.muted,
.sub {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-wrap {
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.matrix {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem;
  text-align: center;
  vertical-align: top;
  min-width: 88px;
}

.matrix thead th,
.sticky-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
}

.matrix .sticky-col {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 4;
  text-align: left;
  min-width: 220px;
}

.assign {
  width: 100%;
  min-height: 2.2rem;
  border-radius: 10px;
  background: #eef2f6;
  color: var(--text);
}

.assign-X {
  background: #dbeafe;
}

.assign-K {
  background: #fde68a;
}

.assign-V {
  background: #bbf7d0;
  border: 2px solid var(--ok);
  font-weight: 700;
}

.assign-empty {
  color: transparent;
}

.assign-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.coverage-under {
  background: #ffe08a !important;
  color: #1f2933;
}

.coverage-ok {
  background: #7dff9b !important;
  color: #062b16;
}

.coverage-over {
  background: #ff8f8f !important;
  color: #3f0000;
}

.badge {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  margin: 0.1rem;
  font-size: 0.85rem;
}

.shift-editor-list {
  display: grid;
  gap: 0.4rem;
}

.shift-editor {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(90px, 1fr) 80px auto;
  gap: 0.35rem;
  align-items: center;
  min-width: 480px;
}

.modal-dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  width: min(420px, calc(100vw - 2rem));
}

.modal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.modal-content {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.shift-head {
  cursor: pointer;
  min-width: 132px !important;
}

.shift-head.coverage-under,
.shift-head.coverage-ok,
.shift-head.coverage-over {
  border: 2px solid rgba(15, 23, 42, 0.3);
}

.shift-head.active-filter {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.day-label,
.task-label {
  font-weight: 700;
}

.responsible {
  font-weight: 700;
}

.bedarf-table td {
  text-align: left;
}

.person-name {
  width: 100%;
  margin-bottom: 0.35rem;
}

.auth-panel {
  max-width: 420px;
}

.compact-table .participants-cell {
  white-space: normal;
  text-align: left;
  min-width: 260px;
  max-width: 420px;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

@media (max-width: 800px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
