:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #1c1b19;
  --muted: #6b6760;
  --line: #ddd8cf;
  --accent: #c45c26;
  --open: #4a6fa5;
  --danger: #a33b2d;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(28, 27, 25, 0.04);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(196, 92, 38, 0.08), transparent 40%),
    linear-gradient(180deg, #f7f5f1 0%, var(--bg) 100%);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  padding: 2rem 1.5rem 1rem;
  max-width: 1920px;
  margin: 0 auto;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  flex: 0 1 auto;
}

.brand-title-row {
  display: flex;
  align-items: flex-end;
  gap: 1.1rem;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: 42px;
  width: auto;
  flex-shrink: 0;
}

.brand-title-row h1 {
  line-height: 1;
  padding-bottom: 0;
}

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

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.refresh-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  font: inherit;
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.logout-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font: inherit;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: rgba(163, 59, 45, 0.25);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 0.35rem;
}

.login-card h1 {
  font-size: 1.65rem;
}

.login-lead {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.login-label {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
}

.login-input:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  border-color: var(--accent);
}

.login-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.login-submit {
  margin-top: 0.85rem;
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-submit:hover {
  filter: brightness(0.95);
}

main {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.1rem;
}

.filter-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.is-active {
  border-color: var(--accent);
  background: #f7e6db;
  color: #8a3d14;
}

.search-panel {
  flex: 1 1 280px;
  margin: 0;
  max-width: 520px;
  min-width: 200px;
}

.refresh-btn {
  flex-shrink: 0;
}

.search-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.search-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font: inherit;
  color: var(--ink);
}

.search-input:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  border-color: var(--accent);
}

.search-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(28, 27, 25, 0.08);
  max-height: 360px;
  overflow: auto;
  padding: 0.35rem;
}

.search-empty {
  margin: 0;
  padding: 0.75rem 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
}

.search-item:hover {
  background: #f7f4ef;
}

.search-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-item-path {
  color: var(--muted);
  font-size: 0.78rem;
  word-break: break-all;
  margin-top: 0.15rem;
}

.tile-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
}

.disable-tile-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.disable-tile-btn:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.disable-tile-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.add-project-btn {
  flex-shrink: 0;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.add-project-btn:hover:not(:disabled) {
  filter: brightness(0.95);
}

.add-project-btn:disabled {
  border-color: var(--line);
  background: #ece8e1;
  color: var(--muted);
  cursor: default;
}

.global-error {
  background: #f8e8e5;
  color: var(--danger);
  border: 1px solid #e7c4bd;
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.tiles {
  display: grid;
  gap: 1.1rem;
  /* max. 6 Spalten; darunter automatisch weniger */
  grid-template-columns: repeat(
    auto-fill,
    minmax(max(280px, calc((100% - 5 * 1.1rem) / 6)), 1fr)
  );
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.tile-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  word-break: break-word;
}

.tile-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.9rem;
}

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 0.85rem;
}

.tile-path {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.tile-meta {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.tile-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.tile-link:hover {
  text-decoration: underline;
}

.ticket-list li {
  border-top: 1px solid var(--line);
  padding-top: 0.55rem;
}

.ticket-list a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.ticket-list a:hover .ticket-title {
  color: var(--accent);
}

.ticket-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.ticket-iid {
  font-weight: 600;
  color: var(--ink);
}

.ticket-status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #8a3d14;
  background: #f7e6db;
  border: 1px solid #e8c4ad;
}

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

.ticket-item.ticket-in-progress {
  border-left: 3px solid var(--accent);
  padding-left: 0.55rem;
  margin-left: -0.15rem;
}

.ticket-title {
  font-size: 0.85rem;
  line-height: 1.35;
}

.ticket-activity {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.empty-tickets,
.tile-error,
.tile-loading {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0.5rem 0 1rem;
}

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

.chart-wrap {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.85rem;
  align-items: center;
}

.chart-wrap canvas {
  max-width: 88px;
  max-height: 88px;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.legend-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  display: inline-block;
}

.swatch-progress {
  background: var(--accent);
}

.swatch-open {
  background: var(--open);
}

.legend-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

@media (max-width: 900px) {
  .page-header {
    flex-wrap: wrap;
  }

  .search-panel {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-block {
    align-items: stretch;
  }

  .brand-title-row {
    align-items: flex-end;
  }

  .search-panel {
    order: unset;
    max-width: none;
  }

  .refresh-btn,
  .logout-btn {
    width: 100%;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
  }

  .chart-wrap {
    grid-template-columns: 80px 1fr;
  }
}
