:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f8f8f5;
  --ink: #121316;
  --ink-2: #1d1f25;
  --text: #1b1d22;
  --muted: #6f7480;
  --line: #dedfd8;
  --line-strong: #cccec5;
  --accent: #7c5cff;
  --accent-2: #ede9ff;
  --green: #17a77f;
  --green-2: #e2f6ef;
  --amber: #f4b640;
  --amber-2: #fff2d0;
  --red: #ce4b61;
  --red-2: #fde7ec;
  --shadow: 0 18px 44px rgba(20, 22, 28, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top left, rgba(124, 92, 255, 0.08), transparent 34%), var(--bg);
}

.login-card {
  width: min(390px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-mark,
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.login-card h1 {
  margin: 16px 0 7px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span,
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.input,
.textarea,
.select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 10px;
  outline: none;
}

.textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.48;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}

.primary,
.secondary,
.ghost,
.danger,
.icon-button,
.nav-button,
.chip-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.primary {
  background: var(--ink);
  color: #fff;
  padding: 0 13px;
  font-weight: 850;
}

.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  padding: 0 12px;
  font-weight: 800;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 0 10px;
  font-weight: 750;
}

.danger {
  background: var(--red-2);
  color: var(--red);
  border-color: #f0c8d0;
  padding: 0 12px;
  font-weight: 820;
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  font-weight: 900;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 16px 12px;
  background: var(--ink);
  color: #fff;
  border-right: 1px solid #272a32;
}

.brand {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0 4px;
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand small {
  color: #a8afbd;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.nav-button {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  padding: 0 10px;
  background: transparent;
  color: #b9bfca;
  font-weight: 800;
}

.nav-button span:first-child {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #202229;
  color: #fff;
  font-size: 12px;
}

.nav-button:hover,
.nav-button.active {
  background: #23262e;
  color: #fff;
}

.nav-button.active span:first-child {
  background: var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  color: #a8afbd;
  font-size: 12px;
  padding: 0 4px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border: 1px solid #30333c;
  border-radius: 999px;
  padding: 7px 9px;
  background: #1b1d22;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 242, 0.94);
  backdrop-filter: blur(12px);
}

.search {
  position: relative;
}

.search input {
  height: 38px;
  padding-left: 34px;
  background: #fff;
}

.search span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 900;
}

.top-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.user-badge {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  font-weight: 800;
}

.user-badge span:nth-child(2) {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge small {
  color: var(--muted);
  font-weight: 850;
}

.main {
  min-width: 0;
  padding: 18px;
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.view-heading h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: 0;
}

.view-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: 0 7px 20px rgba(20, 22, 28, 0.04);
}

.metric span {
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.metric small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.command-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid #252832;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.overview-command {
  margin-bottom: 12px;
}

.command-panel h3 {
  margin: 3px 0 5px;
  font-size: 20px;
  letter-spacing: 0;
}

.command-panel p {
  margin: 0;
  color: #c7ccd6;
  line-height: 1.42;
}

.command-panel .primary {
  background: #fff;
  color: var(--ink);
}

.command-panel .secondary {
  background: #242731;
  color: #fff;
  border-color: #383c49;
}

.eyebrow {
  color: #9cf0d2;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
}

.notice-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: #fff8e8;
  border: 1px solid #efd59e;
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.notice-band h3,
.notice-band p {
  margin: 0;
}

.notice-band p {
  color: #6e572b;
  margin-top: 3px;
  line-height: 1.4;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.overview-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.status-tile {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.status-tile strong {
  display: block;
  font-size: 20px;
}

.status-tile span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.status-tile.accent {
  background: var(--accent-2);
  border-color: #d8d0ff;
}

.status-tile.amber {
  background: var(--amber-2);
  border-color: #ecd6a5;
}

.status-tile.red {
  background: var(--red-2);
  border-color: #f0c8d0;
}

.status-tile.green {
  background: var(--green-2);
  border-color: #c6eadc;
}

.panel,
.list-pane,
.editor-pane {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(20, 22, 28, 0.04);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 14px;
}

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

.item-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.item-card.clickable {
  width: 100%;
  text-align: left;
}

.item-card.clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.10);
}

.active-note {
  border-color: var(--accent);
  background: var(--accent-2);
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.item-title span:first-child {
  overflow-wrap: anywhere;
}

.item-meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.item-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.badge,
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  min-height: 22px;
  padding: 0 8px;
}

.badge {
  background: var(--accent-2);
  color: var(--accent);
}

.badge.green {
  background: var(--green-2);
  color: var(--green);
}

.badge.amber {
  background: var(--amber-2);
  color: #8a5a0a;
}

.badge.red {
  background: var(--red-2);
  color: var(--red);
}

.tag {
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.two-pane {
  display: grid;
  grid-template-columns: minmax(240px, 330px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.list-scroll {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.editor-body {
  padding: 14px;
}

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

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.button-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.comments {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 12px;
}

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

.comment:last-child {
  border-bottom: 0;
}

.comment p {
  margin: 4px 0 0;
  line-height: 1.42;
}

.upload-zone {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px dashed #aeb3bd;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

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

.file-card {
  min-height: 126px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--accent-2);
  color: var(--accent);
  font-weight: 950;
}

.file-mini {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
  gap: 14px;
  align-items: start;
}

.task-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(210px, 260px);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.task-row.dragging {
  opacity: 0.65;
  border-color: var(--accent);
}

.order {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 950;
}

.task-main strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.task-controls {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.task-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

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

.activity-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 9px;
}

.activity-item::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--green);
}

.activity-item p {
  margin: 0;
  line-height: 1.36;
}

.team-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 14px;
  align-items: start;
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 140px auto;
  gap: 8px;
  align-items: center;
}

.invite-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.invite-code {
  margin-top: 8px;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 7px 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 950;
}

.server-line {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 9px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.server-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.server-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.server-line strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.step-line {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.step-line strong {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-2);
  color: var(--accent);
}

.member-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--green-2);
  color: var(--green);
  font-weight: 950;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 110px;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  background: var(--ink);
  color: #fff;
  padding: 11px 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .metrics,
  .file-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .plan-grid,
  .team-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .task-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .task-controls {
    grid-column: 2 / -1;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #272a32;
    grid-template-rows: auto auto;
    gap: 12px;
  }

  .sidebar-footer {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(92px, 1fr));
    overflow-x: auto;
  }

  .nav-button {
    justify-content: center;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .main {
    padding: 14px;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .command-panel,
  .two-pane,
  .form-grid,
  .file-grid,
  .overview-status,
  .invite-card,
  .invite-form {
    grid-template-columns: 1fr;
  }

  .list-scroll {
    max-height: none;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 13px;
  }

  .login-card {
    padding: 20px;
  }

  .metrics,
  .notice-band,
  .task-row,
  .task-controls {
    grid-template-columns: 1fr;
  }

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

  .user-badge,
  .top-actions .secondary,
  .top-actions .ghost {
    width: 100%;
  }
}

/* Firmaraum v4: kompakte Kopf-Navigation und Admin-Unterbereiche */
.top-shell.shell {
  display: block;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(320px, 1fr) minmax(300px, 520px);
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(245, 246, 242, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-block {
  min-width: 0;
}

.brand-block .brand-mark {
  background: var(--ink);
}

.brand-block strong,
.brand-block small {
  color: var(--text);
}

.brand-block small {
  display: block;
  color: var(--muted);
}

.header-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.top-nav.nav {
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 1px;
}

.top-nav .nav-button {
  width: auto;
  min-height: 34px;
  flex: 0 0 auto;
  justify-content: center;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  border-color: var(--line);
}

.top-nav .nav-button span:first-child {
  width: 20px;
  height: 20px;
  background: var(--surface-soft);
  color: var(--muted);
}

.top-nav .nav-button:hover,
.top-nav .nav-button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.top-nav .nav-button.active span:first-child {
  background: var(--accent);
  color: #fff;
}

.header-meta {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.header-tools {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, auto);
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.header-tools .search input {
  height: 34px;
  min-height: 34px;
}

.top-actions {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-action {
  min-height: 34px;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 13px;
}

.header-status {
  min-height: 34px;
  padding: 0 10px;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.view-heading {
  margin-bottom: 12px;
}

.view-heading h2 {
  font-size: 22px;
}

.view-heading p {
  font-size: 13px;
}

.input,
.select {
  min-height: 36px;
  padding: 7px 10px;
}

.textarea {
  min-height: 150px;
  padding: 9px 10px;
}

.panel-header {
  padding: 10px 12px;
}

.panel-body,
.editor-body {
  padding: 12px;
}

.metric {
  padding: 11px;
}

.metric strong {
  font-size: 22px;
}

.overview-command.command-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 14px;
  margin-bottom: 12px;
}

.overview-command h3 {
  font-size: 19px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.admin-tab {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  min-height: 34px;
  padding: 0 12px;
  font-weight: 850;
  white-space: nowrap;
}

.admin-tab.active,
.admin-tab:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.admin-content {
  min-width: 0;
}

.compact-invite-form {
  grid-template-columns: minmax(170px, 1fr) 150px auto;
}

.member-admin-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(130px, 170px) auto;
  gap: 10px;
  align-items: center;
}

.member-admin-main {
  min-width: 0;
}

.member-admin-main strong {
  overflow-wrap: anywhere;
}

.compact-member {
  grid-template-columns: 38px minmax(0, 1fr) auto;
}

.mode-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

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

.empty {
  min-height: 82px;
  padding: 16px;
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  }

  .header-tools {
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    justify-content: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .app-header {
    position: static;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .header-tools {
    grid-template-columns: 1fr;
  }

  .top-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 3px;
  }

  .main {
    padding: 12px;
  }

  .overview-command.command-panel,
  .compact-invite-form,
  .member-admin-row,
  .mode-card {
    grid-template-columns: 1fr;
  }

  .member-admin-row .danger,
  .mode-card .secondary {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .top-actions {
    flex-direction: row;
    align-items: center;
  }

  .top-actions .secondary,
  .top-actions .ghost,
  .top-actions .primary,
  .header-status {
    width: auto;
    flex: 0 0 auto;
  }

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

/* Firmaraum v4.6: kompaktere Übersicht und ruhigere Planung */
.overview-top-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}

.overview-top-grid .overview-command {
  margin-bottom: 0;
  min-height: 100%;
}

.overview-metrics.metrics {
  margin-bottom: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.overview-metrics .metric {
  padding: 10px;
}

.overview-metrics .metric strong {
  font-size: 20px;
}

.overview-card-grid.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.overview-card-grid .panel-body {
  padding: 10px;
}

.plan-status-strip {
  margin-bottom: 12px;
}

.plan-board {
  overflow: hidden;
}

.plan-toolbar {
  align-items: flex-start;
}

.plan-toolbar > div:first-child {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.plan-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-button {
  min-height: 30px;
  padding: 0 9px;
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.chip-button span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
}

.chip-button.active,
.chip-button:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.chip-button.active span,
.chip-button:hover span {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.plan-task-form {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(150px, 0.8fr) 150px 140px 140px auto;
  gap: 9px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.plan-task-form .field {
  margin-bottom: 0;
}

.plan-details-field {
  grid-column: 1 / -2;
}

.plan-task-form .textarea {
  min-height: 64px;
}

.plan-inline-note {
  display: flex;
  gap: 9px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.plan-task-list {
  gap: 7px;
}

.plan-task-list .task-row {
  padding: 8px;
}

.plan-task-list .task-main strong {
  font-size: 14px;
}

.plan-task-list .item-meta {
  margin-top: 4px;
}

@media (max-width: 1180px) {
  .overview-top-grid,
  .overview-card-grid.dashboard-grid {
    grid-template-columns: 1fr;
  }

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

  .plan-title-field,
  .plan-details-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .overview-metrics.metrics,
  .plan-task-form {
    grid-template-columns: 1fr;
  }

  .plan-toolbar {
    flex-direction: column;
  }

  .plan-toolbar .button-row {
    width: 100%;
  }

  .plan-toolbar .button-row .primary,
  .plan-toolbar .button-row .secondary {
    width: 100%;
  }
}


/* Firmaraum v4.9: Seitenmenü, Projekte, Chat und Gruppen */
.with-side {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
}

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

.side-menu {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 100vh;
  align-self: start;
  background: var(--ink);
  color: #fff;
  border-right: 1px solid #272a32;
  padding: 10px;
  overflow: hidden;
}

.side-open {
  grid-template-columns: 220px minmax(0, 1fr);
}

.side-toggle,
.side-link {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  background: transparent;
  color: #b9bfca;
  padding: 0 8px;
  text-align: left;
  font-weight: 850;
}

.side-toggle span,
.side-link span:first-child {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #202229;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
}

.side-link:hover,
.side-link.active,
.side-toggle:hover {
  background: #23262e;
  color: #fff;
}

.side-link.active span:first-child {
  background: var(--accent);
}

.side-panel {
  display: grid;
  gap: 5px;
  margin-top: 14px;
}

.side-section-title {
  margin: 10px 8px 4px;
  color: #7f8795;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.side-closed .side-link,
.side-closed .side-toggle {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
}

.side-closed .side-link strong,
.side-closed .side-toggle strong,
.side-closed .side-section-title {
  display: none;
}

.muted-link {
  color: #8e96a6;
}

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
  gap: 14px;
  align-items: start;
}

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

.project-card {
  display: grid;
  gap: 10px;
}

.project-card p {
  margin: 8px 0 0;
  line-height: 1.45;
}

.project-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.project-stats span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.project-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.compact-textarea {
  min-height: 92px;
}

.chat-panel {
  overflow: hidden;
}

.chat-list {
  min-height: 360px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  display: grid;
  align-content: end;
  gap: 8px;
  background: var(--surface-soft);
}

.chat-message {
  max-width: min(680px, 88%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px 10px;
}

.chat-message.mine {
  justify-self: end;
  background: var(--accent-2);
  border-color: #d8d0ff;
}

.chat-message div {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}

.chat-message span {
  color: var(--muted);
  font-size: 11px;
}

.chat-message p {
  margin: 0;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.chat-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.group-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

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

@media (max-width: 980px) {
  .with-side,
  .side-open,
  .side-closed {
    grid-template-columns: 1fr;
  }

  .side-menu {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #272a32;
  }

  .side-panel {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .side-section-title {
    grid-column: 1 / -1;
  }

  .side-closed .side-link strong,
  .side-closed .side-toggle strong,
  .side-closed .side-section-title {
    display: block;
  }

  .side-closed .side-link,
  .side-closed .side-toggle {
    grid-template-columns: 26px minmax(0, 1fr);
    justify-items: stretch;
    padding: 0 8px;
  }

  .project-layout,
  .project-grid,
  .group-form,
  .chat-form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .side-panel {
    grid-template-columns: 1fr;
  }

  .project-stats {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }
}
