/*
 * Mobile-First CSS
 * ----------------
 * Base styles target mobile (>= 390px, iPhone 13/14/15).
 * Desktop/tablet layouts are layered on top via min-width media queries:
 *   @media (min-width: 768px)   — Tablet portrait, small laptops (--bp-md)
 *   @media (min-width: 1024px)  — Tablet landscape, desktop        (--bp-lg)
 *   @media (min-width: 1280px)  — Wide desktop                     (--bp-xl)
 * Note: CSS custom properties cannot be used inside @media queries,
 * so the --bp-* tokens below are documentation only. Use the pixel
 * values directly in media queries and keep them in sync with the tokens.
 */

:root {
      /* Colors */
      --bg: #f5f6fa;
      --surface: #ffffff;
      --surface2: #f0f1f5;
      --border: #e2e4ea;
      --text: #1a1d27;
      --text-muted: #6b7280;
      --accent: #6366f1;
      --accent-light: #818cf8;
      --accent2: #8b5cf6;
      --accent2-light: #a78bfa;
      --green: #16a34a;
      --orange: #d97706;
      --red: #dc2626;
      --cyan: #0891b2;

      /* Shadows */
      --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
      --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
      --shadow-lg: 0 8px 32px rgba(0,0,0,0.2);
      --shadow-accent: 0 8px 32px rgba(99, 102, 241, 0.2);
      --text-shadow: var(--text-shadow);

      /* Radii */
      --radius-sm: 3px;
      --radius-md: 6px;
      --radius-lg: 8px;
      --radius-xl: 12px;
      --radius-2xl: 16px;

      /* Transitions */
      --transition-fast: all 0.15s;
      --transition-base: all 0.3s;

      /* Breakpoints (documentation tokens — use literal px in @media) */
      --bp-md: 768px;
      --bp-lg: 1024px;
      --bp-xl: 1280px;
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
    }

    header {
      padding: 10px 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 8px;
      max-width: 1600px;
      margin: 0 auto;
    }

    header h1 {
      font-size: 17px;
      font-weight: 700;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    header .subtitle {
      color: var(--text-muted);
      font-size: 13px;
    }

    .header-meta {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 4px;
    }

    .main-nav {
      display: none;
      gap: 4px;
      background: var(--surface2);
      border-radius: var(--radius-xl);
      padding: 4px;
    }

    .nav-btn {
      padding: 8px 20px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      font-size: 13px;
      font-weight: 500;
      border-radius: var(--radius-lg);
      cursor: pointer;
      transition: var(--transition-fast);
      white-space: nowrap;
    }

    .nav-btn.active {
      background: var(--accent);
      color: white;
    }

    @media (hover: hover) {
      .nav-btn:hover:not(.active) {
        background: var(--surface);
        color: var(--text);
      }
    }

    main {
      padding: 12px;
      padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
      max-width: 1600px;
      margin: 0 auto;
    }

    /* KPIs: horizontal scroll-snap carousel on mobile (default) */
    .kpi-grid {
      display: flex;
      gap: 10px;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scroll-padding: 12px;
      padding: 0 12px 6px;
      margin: 0 -12px 16px;
      -webkit-overflow-scrolling: touch;
    }

    .kpi-grid::-webkit-scrollbar { display: none; }

    /* Beauftragung filter chips (analytics tab) — horizontally scrollable on mobile */
    .beauftragung-chips {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      scroll-snap-type: x proximity;
      -webkit-overflow-scrolling: touch;
      padding-bottom: 4px;
      margin-bottom: 12px;
    }
    .beauftragung-chips:empty { display: none; }
    .beauftragung-chips::-webkit-scrollbar { display: none; }
    .beauftragung-chip {
      flex: 0 0 auto;
      scroll-snap-align: start;
      padding: 8px 14px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      cursor: pointer;
      min-height: 36px;
    }
    .beauftragung-chip.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }

    .kpi-card {
      background: var(--surface);
      border-radius: var(--radius-xl);
      padding: 14px 16px;
      box-shadow: var(--shadow-sm);
      transition: transform 0.15s, box-shadow 0.15s;
      flex: 0 0 70%;
      min-width: 0;
      scroll-snap-align: start;
    }

    @media (hover: hover) {
      .kpi-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
      }
    }

    .kpi-label {
      font-size: 11px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 4px;
    }

    .kpi-value {
      font-size: 22px;
      font-weight: 700;
    }

    .kpi-sub {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 4px;
    }

    /* Charts: single column, tight on mobile (default).
       minmax(0, 1fr) — not plain 1fr — so wide children (sprint timeline,
       sync-history table) stay inside their overflow-x container instead of
       forcing the grid column to min-content and overflowing the viewport. */
    .chart-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 10px;
      margin-bottom: 24px;
    }

    /* Grid items default to min-width: auto (== min-content). Force min-width: 0
       so long children don't blow the card's boundary. */
    .chart-card { min-width: 0; }

    .chart-card {
      background: var(--surface);
      border-radius: var(--radius-xl);
      padding: 12px;
      box-shadow: var(--shadow-sm);
    }

    .chart-card.full {
      grid-column: 1 / -1;
    }

    .chart-card h3 {
      font-size: 13px;
      font-weight: 600;
      margin-bottom: 10px;
      color: var(--text);
    }

    .chart-container {
      position: relative;
      width: 100%;
      height: 220px;
    }

    .chart-container.tall {
      height: 260px;
    }

    /* Table styles
       Tables render only when isWideLayout() is true (see app.js).
       On mobile the detail list uses .entries-compact cards below. */
    .table-wrapper {
      overflow-x: auto;
      max-height: 500px;
      overflow-y: auto;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }

    thead th {
      background: var(--surface2);
      padding: 10px 14px;
      text-align: left;
      font-weight: 600;
      color: var(--text-muted);
      position: sticky;
      top: 0;
      z-index: 2;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }

    thead th .sort-arrow {
      margin-left: 4px;
      opacity: 0.4;
    }

    thead th.active .sort-arrow {
      opacity: 1;
      color: var(--accent);
    }

    tbody td {
      padding: 10px 14px;
      border-top: 1px solid var(--border);
      vertical-align: top;
    }

    /* Hover states only on devices with a real pointer, to avoid
       sticky-hover on touch tablets that also match min-width: 768px. */
    @media (hover: hover) {
      thead th:hover { color: var(--text); }
      tbody tr:hover { background: var(--surface2); }
    }

    .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 600;
    }

    .hours-bar {
      height: 6px;
      border-radius: var(--radius-sm);
      background: var(--border);
      position: relative;
      min-width: 80px;
    }

    .hours-bar-fill {
      height: 100%;
      border-radius: var(--radius-sm);
      background: linear-gradient(90deg, var(--accent), var(--accent2));
    }

    .section { display: none; }
    .section.active { display: block; }

    .desc-cell {
      max-width: 400px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    @media (hover: hover) {
      .desc-cell:hover { white-space: normal; }
    }

    /* Budget section — single column on mobile, stacks Beauftragungen/Budget/Forecast */
    .budget-section {
      background: var(--surface);
      border-radius: var(--radius-xl);
      padding: 16px;
      box-shadow: var(--shadow-sm);
      margin-bottom: 24px;
    }

    .budget-section h2 {
      font-size: 15px;
      font-weight: 700;
      margin-bottom: 20px;
    }

    .budget-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      gap: 12px;
    }

    .budget-block {
      padding: 12px;
      border-radius: var(--radius-xl);
      background: var(--surface2);
    }

    .budget-block h4 {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 12px;
    }

    .budget-block .budget-nums {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      margin-bottom: 6px;
    }

    .budget-block .budget-total {
      font-size: 13px;
      color: var(--text-muted);
    }

    .budget-block .budget-used {
      font-size: 18px;
      font-weight: 700;
    }

    .budget-block .budget-pct {
      font-size: 14px;
      font-weight: 600;
    }

    .budget-bar {
      height: 20px;
      border-radius: var(--radius-xl);
      background: var(--border);
      overflow: hidden;
      position: relative;
      margin-top: 8px;
      display: flex;
    }

    .budget-bar-fill {
      height: 100%;
      transition: width 0.6s ease;
      position: relative;
    }

    .budget-bar-fill:first-child {
      border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    }

    .budget-bar-fill:last-child {
      border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    }

    .budget-bar-fill:only-child {
      border-radius: var(--radius-xl);
    }

    .budget-bar-fill.b1 {
      background: linear-gradient(90deg, var(--accent), var(--accent-light));
    }

    .budget-bar-fill.b2 {
      background: linear-gradient(90deg, var(--accent2), var(--accent2-light));
    }

    .budget-bar-fill.total {
      background: linear-gradient(90deg, var(--accent), var(--accent2));
    }

    .budget-bar-label {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 11px;
      font-weight: 600;
      color: white;
      text-shadow: var(--text-shadow);
    }

    .budget-remaining {
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
      font-size: 12px;
      color: var(--text-muted);
    }

    .budget-bar-fill.forecast {
      background: rgba(251, 146, 60, 0.55);
      border-left: 2px dashed rgba(255, 255, 255, 0.7);
      cursor: default;
    }

    .budget-bar-fill.forecast-upper {
      background: rgba(251, 146, 60, 0.25);
      border-left: 1px dashed rgba(251, 146, 60, 0.4);
      cursor: default;
    }

    /* Over-budget (Ueberhang): bar capped at 100% but signalled in red. */
    .budget-bar-fill.over {
      background: linear-gradient(90deg, #f87171, var(--red));
    }

    .budget-block .budget-pct.over {
      color: var(--red);
    }

    .budget-remaining span.over {
      color: var(--red);
      font-weight: 600;
    }

    .budget-breakdown {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 4px;
    }

    .budget-overhang {
      font-size: 12px;
      font-weight: 600;
      color: var(--red);
      margin-top: 8px;
    }

    /* Budget-planning deduction (Rabatt/Zugestaendnis). */
    .deduction {
      color: var(--red);
      font-weight: 600;
    }

    .fc-tip-header {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      padding-bottom: 6px;
      margin-bottom: 2px;
      border-bottom: 1px solid var(--border);
    }

    .fc-tip-row {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      padding: 6px 0;
      border-bottom: 1px solid var(--border);
      font-size: 12px;
    }

    .fc-tip-row:last-of-type { border-bottom: 1px solid var(--border); }

    .fc-tip-title { color: var(--text); }

    .fc-tip-hours {
      font-weight: 600;
      color: #f97316;
      white-space: nowrap;
    }

    .fc-tip-total {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      padding: 6px 0 0;
      font-size: 12px;
      font-weight: 700;
      color: var(--text);
    }

    .forecast-toggle {
      font-size: 12px;
      color: var(--text-muted);
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      user-select: none;
    }

    .forecast-toggle input[type="checkbox"] {
      accent-color: #f97316;
      width: 16px;
      height: 16px;
      cursor: pointer;
    }

    .budget-stacked-bar {
      height: 32px;
      border-radius: var(--radius-xl);
      background: var(--border);
      overflow: hidden;
      display: flex;
      margin-top: 12px;
      margin-bottom: 6px;
    }

    .budget-stacked-bar .seg {
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 600;
      color: white;
      text-shadow: var(--text-shadow);
      transition: width 0.6s ease;
    }

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

    .budget-legend-item {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--text-muted);
    }

    .budget-legend-dot {
      width: 10px;
      height: 10px;
      border-radius: var(--radius-sm);
      flex-shrink: 0;
    }

    /* Sync controls — stack on mobile, align in a row on wider viewports */
    .sync-controls {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
    }

    .sync-status {
      font-size: 11px;
      color: var(--text-muted);
      white-space: nowrap;
    }

    .sync-btn {
      background: var(--surface2);
      border: none;
      color: var(--text-muted);
      padding: 10px 14px;
      min-height: 40px;
      width: 100%;
      justify-content: center;
      border-radius: var(--radius-lg);
      font-size: 13px;
      cursor: pointer;
      transition: var(--transition-fast);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    @media (hover: hover) {
      .sync-btn:hover {
        background: var(--accent);
        color: white;
      }
    }

    .sync-btn.syncing i,
    .sync-btn.syncing svg {
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    /* Action button (used for Sprint/Focus/Plan create buttons) */
    .upload-btn {
      background: var(--surface2);
      border: none;
      color: var(--text-muted);
      padding: 10px 14px;
      min-height: 40px;
      border-radius: var(--radius-lg);
      font-size: 13px;
      cursor: pointer;
      transition: var(--transition-fast);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    @media (hover: hover) {
      .upload-btn:hover {
        background: var(--accent);
        color: white;
      }
    }

    /* Toast notification — sits above bottom-tab-bar on mobile, with safe-area.
       Hidden state must be invisible AND non-interactive: without opacity: 0
       and pointer-events: none the toast's solid background overlaps the
       bottom-tab-bar at z-index 10000 and eats taps through the bar. */
    .toast {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: calc(70px + env(safe-area-inset-bottom, 12px));
      z-index: 10000;
      background: var(--surface);
      border-radius: var(--radius-xl);
      padding: 16px 20px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.15);
      max-width: none;
      opacity: 0;
      pointer-events: none;
      transform: translateY(120%);
      transition: transform 0.3s, opacity 0.3s;
    }

    .toast.show {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
    }

    .toast.success { border-left: 4px solid var(--green); }
    .toast.error { border-left: 4px solid var(--red); }
    .toast.loading { border-left: 4px solid var(--accent); }

    .toast-title {
      font-weight: 600;
      font-size: 14px;
      margin-bottom: 4px;
    }

    .toast-body {
      font-size: 12px;
      color: var(--text-muted);
    }

    /* Modal — full-screen on mobile (default), centered card on wide viewports */
    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9998;
      background: rgba(0,0,0,0.3);
      backdrop-filter: blur(2px);
      padding: 0;
      align-items: stretch;
      justify-content: stretch;
    }

    .modal-overlay.active {
      display: flex;
    }

    .modal {
      background: var(--surface);
      border-radius: 0;
      width: 100%;
      max-width: none;
      height: 100dvh;
      max-height: none;
      box-shadow: 0 8px 32px rgba(0,0,0,0.2);
      display: flex;
      flex-direction: column;
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 16px;
      border-bottom: 1px solid var(--border);
      flex: 0 0 auto;
    }

    .modal-header h3 { margin: 0; font-size: 16px; }

    .modal-close {
      background: none;
      border: none;
      font-size: 22px;
      color: var(--text-muted);
      cursor: pointer;
      padding: 4px 8px;
      min-width: 44px;
      min-height: 44px;
    }

    .modal-body {
      padding: 16px;
      flex: 1 1 auto;
      overflow-y: auto;
    }

    .modal-footer {
      padding: 12px 16px env(safe-area-inset-bottom, 12px);
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      border-top: 1px solid var(--border);
      position: sticky;
      bottom: 0;
      background: var(--surface);
      flex: 0 0 auto;
      z-index: 2;
    }

    .form-group {
      margin-bottom: 16px;
      flex: 1;
    }

    .form-group label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 6px;
    }

    /* Inputs: 16px font on mobile avoids iOS auto-zoom on focus */
    .form-group input, .form-group textarea, .form-group select,
    input[type="date"], input[type="text"], input[type="number"], input[type="password"] {
      width: 100%;
      padding: 10px 12px;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      font-size: 16px;
      font-family: inherit;
      background: var(--surface);
      color: var(--text);
      outline: none;
    }

    .form-group input:focus, .form-group textarea:focus, .form-group select:focus {
      border-color: var(--accent);
    }

    /* Stacked form rows by default; side-by-side at wider viewports */
    .form-row {
      display: flex;
      flex-direction: column;
      gap: 0;
    }

    /* Primary/secondary/danger buttons sized for touch by default */
    .btn-primary {
      padding: 12px 20px;
      min-height: 44px;
      border: none;
      background: var(--accent);
      color: white;
      border-radius: var(--radius-lg);
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
    }

    @media (hover: hover) {
      .btn-primary:hover { opacity: 0.9; }
    }

    .btn-secondary {
      padding: 12px 20px;
      min-height: 44px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text-muted);
      border-radius: var(--radius-lg);
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
    }

    @media (hover: hover) {
      .btn-secondary:hover { background: var(--surface2); }
    }

    .btn-danger {
      padding: 12px 20px;
      min-height: 44px;
      border: none;
      background: #ef4444;
      color: white;
      border-radius: var(--radius-lg);
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }

    @media (hover: hover) {
      .btn-danger:hover:not(:disabled) { background: #dc2626; }
    }
    .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

    .btn-icon {
      padding: 10px;
      min-width: 44px;
      min-height: 44px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      border-radius: var(--radius-md);
      cursor: pointer;
      transition: var(--transition-fast);
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    @media (hover: hover) {
      .btn-icon:hover {
        background: var(--surface2);
        color: var(--accent);
      }
      .btn-icon-danger:hover {
        color: var(--red);
      }
    }

    .btn-icon svg {
      width: 16px;
      height: 16px;
    }

    /* Sprint cards */
    .sprint-card {
      background: var(--surface2);
      border-radius: var(--radius-xl);
      padding: 16px;
      margin-bottom: 10px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
    }

    .sprint-card-body { flex: 1; }

    .sprint-card-title {
      font-weight: 600;
      font-size: 14px;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .sprint-card-desc {
      font-size: 12px;
      color: var(--text-muted);
      margin-bottom: 6px;
    }

    .sprint-card-dates {
      font-size: 11px;
      color: var(--text-muted);
    }

    .sprint-card-actions {
      display: flex;
      gap: 6px;
      flex-shrink: 0;
      align-self: center;
    }

    /* Sprint Timeline */
    .timeline {
      position: relative;
      padding: 8px 0;
    }

    .timeline-header {
      position: relative;
      height: 24px;
      margin-bottom: 8px;
      margin-left: 90px;
    }

    .timeline-header-cell {
      position: absolute;
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-align: center;
      top: 4px;
    }

    .timeline-row {
      display: flex;
      align-items: center;
      height: 40px;
      position: relative;
      border-radius: var(--radius-md);
    }

    .timeline-row:nth-child(even) {
      background: var(--surface2);
    }

    @media (hover: hover) {
      .timeline-row:hover { z-index: 5; }
    }

    .timeline-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text);
      width: 90px;
      flex-shrink: 0;
      padding-left: 12px;
    }

    .timeline-track {
      flex: 1;
      position: relative;
      height: 28px;
    }

    .timeline-bar {
      position: absolute;
      height: 28px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      padding: 0 10px;
      font-size: 11px;
      font-weight: 500;
      color: white;
      white-space: nowrap;
      cursor: default;
      transition: opacity 0.15s;
    }

    @media (hover: hover) {
      .timeline-bar:hover { opacity: 0.85; }
    }

    .sprint-tooltip {
      display: none;
      position: fixed;
      z-index: 9999;
      background: var(--surface);
      color: var(--text-muted);
      border: 1px solid var(--border);
      padding: 12px 14px;
      border-radius: var(--radius-xl);
      font-size: 12px;
      font-weight: 400;
      white-space: normal;
      max-width: 320px;
      min-width: 180px;
      pointer-events: none;
      box-shadow: var(--shadow-md);
      line-height: 1.5;
    }

    .sprint-tooltip.visible {
      display: block;
    }

    .timeline-today {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 2px;
      background: var(--red);
      z-index: 2;
    }

    .timeline-today::after {
      content: 'Heute';
      position: absolute;
      top: -16px;
      left: -14px;
      font-size: 9px;
      color: var(--red);
      font-weight: 600;
    }

    .project-checkboxes {
      max-height: 40vh;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 8px 12px;
      background: var(--surface2);
    }

    .project-checkboxes .empty-hint {
      color: var(--text-muted);
      font-size: 12px;
      padding: 4px 0;
    }

    .project-checkboxes label {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 4px 0;
      font-size: 13px;
      cursor: pointer;
      text-transform: none;
      font-weight: 400;
      letter-spacing: 0;
      color: var(--text);
    }

    .project-checkboxes label input[type="checkbox"] {
      width: auto;
      margin: 0;
    }

    .project-checkboxes .project-hours {
      margin-left: auto;
      color: var(--text-muted);
      font-size: 12px;
    }

    .project-badge {
      display: inline-block;
      font-size: 11px;
      padding: 2px 8px;
      border-radius: 10px;
      margin: 2px 2px 0 0;
    }

    .project-badge.jira { background: #6366f122; color: #6366f1; }
    .project-badge.harvest { background: #f59e0b22; color: #d97706; }

    /* Logout button */
    .logout-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      border-radius: var(--radius-lg);
      color: var(--text-muted);
      background: var(--surface2);
      text-decoration: none;
      transition: var(--transition-fast);
      flex-shrink: 0;
    }

    @media (hover: hover) {
      .logout-btn:hover {
        background: var(--red);
        color: white;
      }
    }

    /* Chart toggle list (Einstellungen) — one column on mobile */
    .chart-toggle-list {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

    .chart-toggle-list label {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 14px;
      min-height: 44px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      font-size: 13px;
      cursor: pointer;
      transition: background 0.15s;
    }

    @media (hover: hover) {
      .chart-toggle-list label:hover { background: var(--surface2); }
    }

    .chart-toggle-list input[type="checkbox"] {
      margin: 0;
      width: 16px;
      height: 16px;
      cursor: pointer;
    }

    /* Role-based visibility */
    .role-viewer .nav-btn[data-tab="fokuspunkte"],
    .role-viewer .nav-btn[data-tab="budgetplanung"],
    .role-viewer .nav-btn[data-tab="einstellungen"],
    .role-viewer #einstellungen,
    .role-viewer .forecast-toggle {
      display: none !important;
    }

    /* ============================================================
       BOTTOM TAB BAR (mobile only) + INFO TILES + COMPACT ENTRIES
       ============================================================ */

    .bottom-tab-bar {
      display: flex;
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background: var(--surface);
      border-top: 1px solid var(--border);
      padding: 6px 4px env(safe-area-inset-bottom, 4px);
      z-index: 9995;
      box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
    }

    /* Role-based hiding for viewer on mobile bottom nav */
    .role-viewer .bottom-tab-btn[data-tab="fokuspunkte"],
    .role-viewer .bottom-tab-btn[data-tab="budgetplanung"],
    .role-viewer .bottom-tab-btn[data-tab="einstellungen"] {
      display: none !important;
    }

    .bottom-tab-btn {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2px;
      background: transparent;
      border: none;
      padding: 8px 4px;
      color: var(--text-muted);
      font-size: 10px;
      font-weight: 500;
      cursor: pointer;
      min-height: 52px;
      line-height: 1;
      overflow: hidden;
    }

    /* Labels truncate instead of pushing the flex track wider than the viewport. */
    .bottom-tab-btn span {
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .bottom-tab-btn i, .bottom-tab-btn svg {
      width: 20px;
      height: 20px;
    }

    .bottom-tab-btn.active {
      color: var(--accent);
    }

    .bottom-tab-btn.active svg {
      stroke-width: 2.4;
    }

    /* Info tiles (mobile alternative to doughnut charts) */
    .chart-container.tile-mode {
      height: auto !important;
      min-height: 0;
    }

    .tile-mode .info-tile {
      background: var(--surface2);
      border-radius: var(--radius-xl);
      padding: 14px 12px;
      text-align: center;
      border-left: 3px solid var(--tile-color, var(--accent));
    }

    .tile-mode {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }

    .tile-label {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.4px;
      color: var(--text-muted);
      margin-bottom: 6px;
      font-weight: 600;
    }

    .tile-value {
      font-size: 18px;
      font-weight: 700;
      color: var(--text);
    }

    .tile-pct {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 4px;
    }

    /* Compact entry list — default detail-view rendering on mobile.
       Wide viewports (>= 768px) swap to the full <table> via app.js. */
    .entries-compact {
      max-height: none;
      overflow: visible;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .compact-entry {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 10px 12px;
      font-size: 13px;
    }

    .ce-line1 {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }

    .ce-src {
      flex: 0 0 auto;
      width: 6px;
      height: 6px;
      border-radius: 50%;
    }

    .ce-src.jira { background: #6366f1; }
    .ce-src.harvest { background: #f59e0b; }

    .ce-issue {
      flex: 0 0 auto;
      font-size: 11px;
      color: var(--accent);
      background: transparent;
      padding: 0;
    }

    .ce-title {
      flex: 1 1 auto;
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .ce-right {
      flex: 0 0 auto;
      display: flex;
      gap: 8px;
      align-items: baseline;
      font-variant-numeric: tabular-nums;
    }

    .ce-date {
      font-size: 11px;
      color: var(--text-muted);
    }

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

    .ce-line2 {
      margin-top: 3px;
      font-size: 11px;
      color: var(--text-muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Mobile sprint timeline (card list) */
    .sprint-mobile-list {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .sprint-mobile-current {
      background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
      color: white;
      border-radius: var(--radius-xl);
      padding: 16px;
    }

    .smc-label {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.6px;
      opacity: 0.8;
      margin-bottom: 6px;
    }

    .smc-title {
      font-size: 18px;
      font-weight: 700;
    }

    .smc-dates {
      font-size: 12px;
      opacity: 0.85;
      margin-top: 2px;
    }

    .smc-bar {
      height: 6px;
      background: rgba(255,255,255,0.3);
      border-radius: var(--radius-sm);
      margin: 10px 0 6px;
      overflow: hidden;
    }

    .smc-bar-fill {
      height: 100%;
      background: rgba(255,255,255,0.95);
      transition: width 0.3s;
    }

    .smc-meta {
      font-size: 12px;
      opacity: 0.9;
    }

    .sprint-mobile-section {
      background: var(--surface2);
      border-radius: var(--radius-lg);
      padding: 10px 12px;
    }

    .sms-label {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: var(--text-muted);
      margin-bottom: 6px;
      font-weight: 600;
      cursor: pointer;
      list-style: none;
    }

    details.sprint-mobile-section summary::-webkit-details-marker { display: none; }

    .sms-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 0;
      font-size: 13px;
    }

    .sms-item + .sms-item {
      border-top: 1px solid var(--border);
    }

    .sms-name { font-weight: 500; }

    .sms-date {
      font-size: 11px;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }

    .sms-done .sms-name { opacity: 0.6; }

    /* Very small phones */
    @media (max-width: 380px) {
      .kpi-card { flex-basis: 80%; }
      .tile-mode { grid-template-columns: repeat(2, 1fr); }
      .smc-title { font-size: 16px; }
      .chart-card { padding: 10px; }
      .chart-card h3 { font-size: 12px; }
    }

    /* =========================================================
       MOBILE-FIRST ENHANCEMENTS
       Layer desktop styles on top of mobile base. Add component
       enhancements in their own milestone; layout + nav lives here.
       ========================================================= */

    /* Tablet and up: top nav replaces bottom-tab-bar, looser padding */
    @media (min-width: 768px) {
      .main-nav { display: flex; }
      .bottom-tab-bar { display: none; }
      header { padding: 16px; gap: 10px; }
      main { padding: 16px; padding-bottom: 16px; }

      /* KPIs become a 2-col grid (flex carousel was mobile) */
      .kpi-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        overflow-x: visible;
        scroll-snap-type: none;
        padding: 0;
        margin: 0 0 24px 0;
      }

      .kpi-card {
        flex: none;
        min-width: 0;
        scroll-snap-align: none;
        padding: 20px;
      }

      .kpi-label { font-size: 12px; margin-bottom: 8px; }
      .kpi-value { font-size: 28px; }
      .kpi-sub { font-size: 12px; }

      /* Chart cards get more breathing room */
      .chart-grid { gap: 20px; }
      .chart-card { padding: 20px; }
      .chart-card h3 { font-size: 15px; margin-bottom: 16px; }
      .chart-container { height: 320px; }
      .chart-container.tall { height: 450px; }

      /* Modals become centered cards instead of fullscreen */
      .modal-overlay {
        padding: 20px;
        align-items: center;
        justify-content: center;
      }

      .modal {
        border-radius: 16px;
        max-width: 520px;
        height: auto;
        max-height: 90vh;
      }

      .modal-header { padding: 20px 24px; }
      .modal-body { padding: 20px 24px; }
      .modal-footer {
        padding: 16px 24px;
        position: static;
      }

      /* Forms go side-by-side where layout allows */
      .form-row { flex-direction: row; gap: 12px; }

      /* Desktop inputs can be slightly smaller now that iOS zoom isn't a concern */
      .form-group input, .form-group textarea, .form-group select,
      input[type="date"], input[type="text"], input[type="number"], input[type="password"] {
        font-size: 13px;
      }

      /* Buttons return to compact desktop size */
      .btn-primary, .btn-secondary, .btn-danger {
        padding: 8px 20px;
        min-height: 0;
        font-size: 13px;
      }

      .upload-btn {
        padding: 8px 14px;
        min-height: 0;
        font-size: 12px;
      }

      /* Icon buttons don't need 44px touch target when a real pointer is in use */
      .btn-icon {
        padding: 6px;
        min-width: 0;
        min-height: 0;
      }

      .modal-close {
        padding: 0 4px;
        min-width: 0;
        min-height: 0;
      }

      /* Toast anchors to bottom-right on wide viewports */
      .toast {
        left: auto;
        right: 24px;
        bottom: 24px;
        max-width: 400px;
      }

      /* Budget section gets more generous padding and typography */
      .budget-section { padding: 24px; }
      .budget-section h2 { font-size: 17px; }
      .budget-block { padding: 16px; }
      .budget-block .budget-used { font-size: 22px; }
      .forecast-toggle { font-size: 13px; }

      /* Einstellungen controls return to inline row layout */
      .sync-controls {
        flex-direction: row;
        align-items: center;
      }

      .sync-btn {
        padding: 8px 14px;
        min-height: 0;
        width: auto;
        justify-content: flex-start;
        font-size: 12px;
      }

      /* Chart-toggle list wraps into responsive columns */
      .chart-toggle-list {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
      }

      .chart-toggle-list label {
        padding: 10px 14px;
        min-height: 0;
      }
    }

    /* Desktop: full padding, type sizes, 2-column chart grid, 3-column budget */
    @media (min-width: 1024px) {
      header { padding: 20px 32px; gap: 16px; }
      header h1 { font-size: 22px; }
      .header-meta { font-size: 12px; }
      main { padding: 24px 32px; }

      .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      }

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

      .budget-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
        gap: 20px;
      }
    }

    /* =========================================================
       A11Y: focus-visible outlines, reduced motion, visually-hidden
       ========================================================= */

    :focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
      border-radius: var(--radius-sm);
    }

    /* Buttons already have their own background/border; keep the outline subtle */
    .nav-btn:focus-visible,
    .bottom-tab-btn:focus-visible,
    .btn-icon:focus-visible,
    .modal-close:focus-visible,
    .logout-btn:focus-visible {
      outline-offset: -2px;
    }

    /* Form inputs get accent border already; layer focus-visible on top */
    .form-group input:focus-visible,
    .form-group textarea:focus-visible,
    .form-group select:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 0;
    }

    .visually-hidden {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }
