:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface2: #242424;
    --surface3: #2e2e2e;
    --border: #333;
    --text: #f0f0f0;
    --text-muted: #888;
    --text-dim: #555;
    --accent: #4f8ef7;
    --accent-dim: #1e3a6e;
    --green: #3ecf8e;
    --green-dim: #0f3d25;
    --yellow: #f5a623;
    --yellow-dim: #3d2a0a;
    --red: #e55;
    --red-dim: #3d1010;
    --surface-1: var(--surface);
    --fill-danger: var(--red);
    --fill-warning: var(--yellow);
    --bg-danger: var(--red-dim);
    --text-danger: var(--red);
    --radius: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  [data-theme="light"] {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface2: #f0f0f0;
    --surface3: #e5e5e5;
    --border: #ddd;
    --text: #111;
    --text-muted: #555;
    --text-dim: #999;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    font-size: 15px;
  }

  /* ── LAYOUT ── */
  #app { display: flex; flex-direction: column; height: 100dvh; }

  #header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    position: sticky; top: 0; z-index: 100;
  }

  #header h1 { font-size: 18px; font-weight: 600; flex: 1; }
  #header .back-btn { display: none; }

  #main { flex: 1; overflow-y: auto; padding: 12px 16px; padding-bottom: calc(80px + var(--safe-bottom)); }

  /* ── FAB ── */
  #fab-area {
    position: fixed;
    bottom: calc(16px + var(--safe-bottom));
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 200;
  }

  .fab {
    width: 52px; height: 52px;
    border-radius: 50%;
    border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    transition: transform 0.15s, opacity 0.15s;
  }
  .fab:active { transform: scale(0.92); }
  .fab-main { background: var(--accent); color: #fff; width: 58px; height: 58px; font-size: 26px; }
  .fab-record { background: var(--red); color: #fff; }
  .fab-recording { animation: pulse-red 1s infinite; }

  @keyframes pulse-red {
    0%,100% { box-shadow: 0 0 0 0 rgba(238,85,85,0.5); }
    50% { box-shadow: 0 0 0 12px rgba(238,85,85,0); }
  }

  /* ── STATUS BADGES ── */
  .badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }
  .badge-planned   { background: #1e3a6e; color: #4f8ef7; }
  .badge-active    { background: var(--yellow-dim); color: var(--yellow); }
  .badge-done      { background: var(--green-dim); color: var(--green); }

  /* ── PROJECT CARDS ── */
  .project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .project-card:active { background: var(--surface2); }
  .project-card.status-done { opacity: 0.6; }

  .card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
  .card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
  .card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .card-deadline { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
  .card-deadline.overdue { color: var(--red); }
  .card-progress { margin-top: 10px; }
  .progress-bar { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
  .progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }
  .progress-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

  /* ── SECTION HEADERS ── */
  .section-label {
    font-size: 11px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-dim);
    margin: 20px 0 8px;
  }
  .section-label:first-child { margin-top: 0; }

  /* ── PROJECT DETAIL ── */
  #detail-view { display: none; }
  #detail-view.active { display: block; }
  #list-view.hidden { display: none; }

  .detail-header-info { margin-bottom: 16px; }
  .detail-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; line-height: 1.3; }
  .detail-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

  .detail-tabs {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
  }
  .tab-btn {
    flex: 1; padding: 10px 4px;
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: color 0.15s, border-color 0.15s;
  }
  .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

  /* ── TODOS ── */
  .todo-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }
  .todo-check {
    width: 22px; height: 22px; min-width: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    transition: all 0.15s;
    margin-top: 1px;
  }
  .todo-check.done { background: var(--green); border-color: var(--green); color: #fff; }
  .todo-check.active { border-color: var(--yellow); }
  .todo-body { flex: 1; min-width: 0; }
  .todo-text { font-size: 14px; line-height: 1.4; }
  .todo-text.done-text { text-decoration: line-through; color: var(--text-muted); }
  .todo-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
  .todo-actions { display: flex; gap: 6px; align-items: center; }
  .icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-size: 15px; padding: 4px;
    border-radius: 6px; transition: color 0.15s, background 0.15s;
  }
  .icon-btn:hover { color: var(--text); background: var(--surface3); }

  /* ── NOTES & MEDIA ── */
  .note-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
  }
  .note-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
  .note-date { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

  @media (min-width: 768px) {
    .todo-master-detail,
    .note-master-detail {
      display: flex;
      gap: 0;
      height: 100%;
      min-height: 0;
    }
    .todo-master,
    .note-master {
      border-right: 1px solid var(--border);
      overflow-y: auto;
      padding-right: 12px;
      flex-shrink: 0;
    }
    .todo-master { width: 340px; }
    .note-master { width: 300px; }
    .todo-detail-panel,
    .note-detail-panel {
      flex: 1;
      padding: 16px;
      overflow-y: auto;
      min-width: 0;
    }
    .todo-master .todo-item,
    .note-master .note-item {
      cursor: pointer;
    }
    .todo-master-active,
    .note-master-active {
      background: var(--accent-dim);
      border-left: 3px solid var(--accent);
    }
    .inline-detail-head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }
    .detail-readonly {
      color: var(--text-dim);
      font-size: 12px;
      margin-top: 4px;
    }
    .detail-placeholder {
      color: var(--text-dim);
      font-size: 14px;
      padding: 24px 4px;
    }
    .note-master-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 10px;
    }
    .note-detail-textarea {
      width: 100%;
      min-height: 260px;
      resize: vertical;
    }
    .cal-container {
      height: 100%;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-height: 0;
    }
    .cal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }
    .cal-view-toggle,
    .cal-nav {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }
    .cal-title {
      font-size: 15px;
      font-weight: 700;
      text-align: center;
      color: var(--text);
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .cal-weekdays {
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      gap: 0;
      color: var(--text-dim);
      font-size: 11px;
      font-weight: 700;
      text-align: center;
      margin-bottom: 4px;
    }
    .cal-grid-month {
      height: calc(100vh - 200px);
      flex: 0 0 calc(100vh - 200px);
      overflow: hidden;
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      grid-template-rows: repeat(6, minmax(0, 1fr));
      min-height: 0;
    }
    .cal-grid-week,
    .cal-week-grid {
      height: calc(100vh - 200px);
      flex: 0 0 calc(100vh - 200px);
      overflow: hidden;
      display: grid;
      grid-template-columns: repeat(7, 1fr);
      min-height: 0;
    }
    .cal-day {
      border: 1px solid var(--border);
      padding: 4px;
      min-height: 0;
      overflow-y: auto;
      background: var(--surface);
    }
    .cal-week-col {
      min-height: 0;
      overflow-y: auto;
    }
    .cal-day.today {
      border-color: var(--accent);
    }
    .cal-day.other-month {
      opacity: 0.4;
    }
    .cal-day-num,
    .cal-day-label {
      color: var(--text-dim);
      font-size: 11px;
      font-weight: 700;
      margin-bottom: 4px;
    }
    .cal-day-single {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 8px 0;
    }
    .cal-chip {
      display: block;
      width: 100%;
      border: none;
      margin: 0 0 3px;
      padding: 1px 6px;
      border-radius: 10px;
      font-size: 10px;
      line-height: 16px;
      text-align: left;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      cursor: pointer;
    }
    .cal-chip-high { background: #e55; color: #fff; }
    .cal-chip-medium { background: #f5a623; color: #fff; }
    .cal-chip-low { background: #3ecf8e; color: #fff; }
    .cal-chip-none { background: var(--surface3); color: var(--text-muted); }
    .cal-chip-project { background: var(--accent-dim); color: var(--accent); }
    .cal-chip-overdue {
      box-shadow: inset 0 0 0 1px var(--red);
    }
    .cal-empty {
      color: var(--text-dim);
      font-size: 11px;
      padding: 4px 0;
    }
  }

  .media-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .media-icon { font-size: 24px; }
  .media-info { flex: 1; min-width: 0; }
  .media-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .media-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  .media-play { background: var(--accent); border: none; color: #fff; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .media-img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }

  /* ── MODAL / SHEET ── */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: flex-end;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
  }
  .modal-overlay.open { opacity: 1; pointer-events: all; }

  .sheet {
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 20px calc(20px + var(--safe-bottom));
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    transform: translateY(30px);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  }
  .modal-overlay.open .sheet { transform: translateY(0); }

  .sheet-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
  .sheet-close {
    position: absolute; top: 16px; right: 16px;
    background: var(--surface3); border: none; color: var(--text-muted);
    width: 30px; height: 30px; border-radius: 50%;
    font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }

  /* ── FORM ELEMENTS ── */
  .field { margin-bottom: 14px; }
  .field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.3px; text-transform: uppercase; }
  .field input, .field textarea, .field select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    padding: 11px 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
  }
  .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
  .field textarea { min-height: 90px; resize: vertical; }
  .field select option { background: var(--surface2); }

  .status-row { display: flex; gap: 8px; }
  .status-option {
    flex: 1; padding: 9px 6px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
  }
  .status-option.sel-planned.selected { border-color: var(--text-dim); background: var(--surface3); color: var(--text); }
  .status-option.sel-active.selected  { border-color: var(--yellow); background: var(--yellow-dim); color: var(--yellow); }
  .status-option.sel-done.selected    { border-color: var(--green); background: var(--green-dim); color: var(--green); }

  .btn-row { display: flex; gap: 10px; margin-top: 6px; }
  .btn {
    flex: 1; padding: 13px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-size: 15px; font-weight: 600;
    transition: opacity 0.15s, transform 0.1s;
  }
  .btn:active { transform: scale(0.97); }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-ghost { background: var(--surface3); color: var(--text-muted); }
  .btn-danger { background: var(--red-dim); color: var(--red); }

  /* ── RECORD MODAL ── */
  .record-center { text-align: center; padding: 20px 0; }
  .record-timer { font-size: 42px; font-weight: 200; letter-spacing: 2px; color: var(--red); margin-bottom: 8px; }
  .record-status { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
  .record-btn-big {
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 3px solid var(--red);
    background: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
    font-size: 28px;
    transition: all 0.15s;
  }
  .record-btn-big.recording { background: var(--red); color: #fff; }
  .record-btn-big:active { transform: scale(0.92); }

  .audio-preview { margin-top: 16px; }
  audio { width: 100%; margin-bottom: 12px; }

  /* ── EMPTY STATES ── */
  .empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
  .empty-icon { font-size: 40px; margin-bottom: 10px; }
  .empty-text { font-size: 14px; }

  /* ── SEARCH ── */
  #search-bar {
    position: relative; margin-bottom: 14px;
  }
  #search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    padding: 10px 13px 10px 38px;
    font-family: inherit;
    outline: none;
  }
  #search-input:focus { border-color: var(--accent); }
  .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 15px; pointer-events: none; }

  /* ── CONTEXT MENU ── */
  .ctx-menu {
    position: fixed; z-index: 400;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    min-width: 180px;
  }
  .ctx-item {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.1s;
  }
  .ctx-item:hover { background: var(--surface3); }
  .ctx-item.danger { color: var(--red); }

  /* ── FILTER CHIPS ── */
  .filter-row { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
  .filter-row::-webkit-scrollbar { display: none; }
  .chip {
    padding: 5px 13px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
  }
  .chip.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

  /* ── PHOTO GRID ── */
  .photo-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 8px; }
  .photo-thumb { aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer; }
  .photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

  /* ── INFO NOTES TABS ── */
  .tab-content { display: none; }
  .tab-content.active { display: block; }

  /* ── DEADLINE WARNING ── */
  .deadline-soon { color: var(--yellow); }
  .deadline-over { color: var(--red); }

  /* ── TODO CATEGORY TAG ── */
  .todo-cat { font-size: 10px; padding: 2px 7px; border-radius: 8px; background: var(--surface3); color: var(--text-muted); white-space: nowrap; flex-shrink: 0; vertical-align: middle; margin-left: 6px; }

  /* ── PRIORITY ── */
  .priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
  .priority-dot.high   { background: #e55; }
  .priority-dot.medium { background: #f5a623; }
  .priority-dot.low    { background: #3ecf8e; }
  .priority-row { display: flex; gap: 8px; }
  .priority-option {
    flex: 1; padding: 8px 4px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: none; color: var(--text-muted);
    font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 6px;
  }
  .priority-option.sel-high.selected   { border-color: #e55;     background: rgba(238,85,85,0.15);    color: #e55; }
  .priority-option.sel-medium.selected { border-color: #f5a623;  background: rgba(245,166,35,0.15);   color: #f5a623; }
  .priority-option.sel-low.selected    { border-color: #3ecf8e;  background: rgba(62,207,142,0.15);   color: #3ecf8e; }
  .priority-option.sel-none.selected   { border-color: var(--text-dim); background: var(--surface3); color: var(--text); }

  /* ── INLINE PRIORITY PILLS ── */
  .priority-pills { display: flex; gap: 3px; flex-shrink: 0; }
  .priority-pill {
    font-size: 10px; font-weight: 700; line-height: 1;
    padding: 2px 7px; border-radius: 10px;
    border: 1.5px solid; cursor: pointer;
    max-height: 18px; display: inline-flex; align-items: center;
    transition: background 0.12s, color 0.12s;
    user-select: none;
  }
  .priority-pill.pill-high   { border-color: #e55;    color: #e55;    background: transparent; }
  .priority-pill.pill-medium { border-color: #f5a623; color: #f5a623; background: transparent; }
  .priority-pill.pill-low    { border-color: #3ecf8e; color: #3ecf8e; background: transparent; }
  .priority-pill.pill-high.on   { background: #e55;    color: #fff; }
  .priority-pill.pill-medium.on { background: #f5a623; color: #fff; }
  .priority-pill.pill-low.on    { background: #3ecf8e; color: #fff; }

  /* ── DRAG HANDLE ── */
  .drag-handle { color: var(--text-dim); cursor: grab; padding: 0 4px; display: flex; align-items: center; }
  .drag-handle:active { cursor: grabbing; }

  /* ── SWIPE TO DELETE HINT ── */
  .delete-confirm {
    background: var(--red-dim);
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; color: var(--red);
  }

  /* scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

  /* ── DASHBOARD ── */
  #dashboard-view { display: none; }
  .stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-bottom: 4px; }
  @media (min-width: 768px) { .stats-row { grid-template-columns: repeat(4,1fr); gap: 8px; } }
  .stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; text-align: center; }
  @media (min-width: 768px) { .stat-card { padding: 10px 12px; } }
  .stat-value { font-size: 15px; font-weight: 700; line-height: 1.1; }
  @media (min-width: 768px) { .stat-value { font-size: 22px; } }
  .stat-label { font-size: 9px; color: var(--text-muted); margin-top: 3px; font-weight: 600; }
  @media (min-width: 768px) { .stat-label { font-size: 10px; } }
  .stat-card.c-active .stat-value  { color: var(--yellow); }
  .stat-card.c-open   .stat-value  { color: var(--accent); }
  .stat-card.c-over   .stat-value  { color: var(--red);    }
  .stat-card.c-lent    .stat-value { color: var(--yellow); }
  .stat-card.c-overdue .stat-value { color: var(--red);    }
  .stat-card.c-value   .stat-value { color: var(--green);  }
  .quick-capture { display: flex; gap: 8px; margin-bottom: 4px; }
  .qc-btn { flex: 1; padding: 10px 6px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.15s; }
  .qc-btn:active { background: var(--surface2); }
  .activity-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .activity-item:last-child { border-bottom: none; }
  .activity-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
  .activity-body { flex: 1; min-width: 0; }
  .activity-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .activity-meta  { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  .activity-time  { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
  .today-item { display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; border-radius: 4px; }
  .today-item:last-child { border-bottom: none; }
  .today-item:hover { background: var(--surface2); }
  .today-col1 { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
  .today-title { flex: 1; font-size: 13px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .today-dl { font-size: 11px; white-space: nowrap; min-width: 140px; text-align: right; }
  .project-tag { font-size: 10px; padding: 2px 7px; border-radius: 10px; background: var(--accent-dim); color: var(--accent); white-space: nowrap; min-width: 120px; text-align: center; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

  /* ── "HEUTE / ALS NÄCHSTES" SCROLLABLE ── */
  .today-section {
    max-height: 220px !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .today-section::-webkit-scrollbar { width: 6px; }
  .today-section::-webkit-scrollbar-track { background: transparent; }
  .today-section::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  .today-section::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

  /* ── ALL-TODOS MOBILE LAYOUT ── */
  @media (max-width: 767px) {
    .all-todos-list .today-item { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
    .all-todos-list .today-col1 { flex: 1; min-width: 0; order: 1; }
    .all-todos-list .today-dl   { order: 2; min-width: 0; flex-shrink: 0; }
    .all-todos-list .priority-pills { order: 3; padding-left: 30px; }
  }

  /* ── ENHANCED CARDS ── */
  .card-counts   { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
  .card-count    { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 3px; }
  .card-next     { font-size: 11px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-updated  { font-size: 11px; color: var(--text-dim); }

  /* ── BLOCKED ── */
  .blocked-badge  { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--red); font-weight: 600; }
  .blocked-reason { font-size: 11px; color: var(--red); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── MOBILE BOTTOM NAV ── */
  #bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(56px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--border); display: flex; z-index: 150; padding-bottom: var(--safe-bottom); }
  .nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: none; color: var(--text-muted); font-size: 10px; font-weight: 600; cursor: pointer; padding: 0; transition: color 0.15s; -webkit-tap-highlight-color: transparent; }
  .nav-btn.active { color: var(--accent); }
  .nav-icon { font-size: 20px; line-height: 1; }

  .admin-page { padding: 14px 16px 32px; position: relative; }
  .admin-close { display: none; position: absolute; top: 12px; right: 16px; width: 34px; height: 34px; border: none; border-radius: 50%; background: var(--surface3); color: var(--text-muted); cursor: pointer; font-size: 16px; }

  /* ── Grouped admin layout ── */
  .admin-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
  .admin-group:last-child { margin-bottom: 0; }
  .admin-group-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .admin-group-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
  .admin-group-body { padding: 14px; }
  .admin-two-col { display: grid; grid-template-columns: 1fr; gap: 0; }
  @media (min-width: 768px) { .admin-two-col { grid-template-columns: 1fr 1fr; gap: 12px; } .admin-two-col .admin-group { margin-bottom: 0; } }

  .admin-subsection { margin-bottom: 22px; }
  .admin-subsection:last-child { margin-bottom: 0; }
  .admin-subsection h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 10px; }
  .admin-subsection-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
  .admin-subsection-hd h3 { margin-bottom: 0; }
  .admin-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

  .admin-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .admin-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
  .admin-actions-row .btn { flex: none; padding: 9px 14px; font-size: 13px; }

  .admin-status { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
  .admin-status span { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
  .admin-status.is-active { color: var(--green); }
  .admin-status.is-active span { background: var(--green); }
  .admin-status.is-inactive { color: var(--red); }
  .admin-status.is-inactive span { background: var(--red); }

  .admin-toggle-btn { background: var(--surface3); color: var(--text-muted); }
  .admin-toggle-btn.is-active { background: var(--green); color: #fff; }
  .admin-toggle-btn.is-inactive { background: var(--surface3); color: var(--text-muted); }
  .admin-toggle-btn:disabled { opacity: 0.7; cursor: wait; }

  /* Visual on/off switch (Registrierung) */
  .admin-toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .admin-toggle { width: 40px; height: 22px; border-radius: 11px; background: var(--surface3); border: none; cursor: pointer; position: relative; padding: 0; flex-shrink: 0; transition: background 0.15s; }
  .admin-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
  .admin-toggle.is-active { background: var(--green); }
  .admin-toggle.is-active .admin-toggle-thumb { transform: translateX(18px); }
  .admin-toggle:disabled { opacity: 0.6; cursor: wait; }

  .admin-danger-btn { background: none; border: 1.5px solid var(--red); color: var(--red); }
  .admin-danger-btn:hover { background: var(--red-dim); }

  .admin-link-btn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 0; }
  .admin-link-btn:hover { text-decoration: underline; }

  .admin-code { margin-top: 12px; border: 1px solid var(--accent); background: var(--accent-dim); border-radius: var(--radius); padding: 18px; text-align: center; }
  .admin-code-value { color: var(--accent); font-size: 34px; font-weight: 800; letter-spacing: 0.16em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  .admin-code-timer { margin-top: 6px; color: var(--text-muted); font-size: 12px; }

  .admin-device-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .admin-device-row:last-child { border-bottom: none; }
  .admin-device-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .admin-device-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-device-date { font-size: 11px; color: var(--text-muted); }

  .admin-token-value { display: block; font-size: 12px; background: var(--surface3); padding: 7px 10px; border-radius: var(--radius-sm); word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

  .admin-service-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
  .admin-service-row:last-child { border-bottom: none; }
  .admin-service-dot { font-size: 13px; flex-shrink: 0; line-height: 1; }
  .admin-service-name { flex: 1; font-size: 13px; }
  .admin-service-status { font-size: 12px; color: var(--text-muted); }

  .admin-metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .admin-metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-width: 0; }
  .admin-metric-label { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; margin-bottom: 6px; }
  .admin-metric-value { color: var(--text); font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }

  .admin-version-grid { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; }
  .admin-version-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .admin-version-cell .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); font-weight: 700; }
  .admin-version-cell .val { font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ── System-Updates group ── */
  .admin-count-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
  .admin-count-badge.ok { background: var(--green-dim); color: var(--green); }
  .admin-count-badge.warn { background: var(--yellow-dim); color: var(--yellow); }
  .admin-updates-lastrun { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
  .admin-warning-banner { display: flex; gap: 8px; align-items: flex-start; background: var(--yellow-dim); border: 1px solid var(--yellow); color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; line-height: 1.5; margin-bottom: 14px; }
  .admin-pkg-table { display: flex; flex-direction: column; }
  .admin-pkg-row { display: grid; grid-template-columns: 1.1fr 1.3fr 1.8fr; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 12px; align-items: center; }
  .admin-pkg-row:last-child { border-bottom: none; }
  .admin-pkg-row.hd { font-weight: 700; text-transform: uppercase; font-size: 10px; color: var(--text-muted); letter-spacing: 0.4px; }
  .admin-pkg-row.warn-row { background: var(--yellow-dim); }
  .admin-pkg-row.major-row { background: var(--accent-dim); }
  .admin-pkg-note-warn { color: var(--yellow); font-weight: 600; }
  .admin-pkg-note-major { color: var(--accent); font-weight: 600; }

  /* ── Audit-Log group ── */
  .admin-group-hd-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .admin-filter-select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
  .admin-audit-scroll { overflow-x: auto; }
  .admin-audit-table { display: flex; flex-direction: column; min-width: 560px; }
  .admin-audit-row { display: grid; grid-template-columns: 90px 90px 90px 1.6fr 1.6fr; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 12px; align-items: center; }
  .admin-audit-row:last-child { border-bottom: none; }
  .admin-audit-row.hd { font-weight: 700; text-transform: uppercase; font-size: 10px; color: var(--text-muted); letter-spacing: 0.4px; }
  .admin-audit-time { color: var(--text-muted); }
  .admin-audit-actor { font-weight: 600; }
  .admin-audit-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-audit-change { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ── DASHBOARD 2-COL + PROJECT GRID ── */
  .dash-two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
  #dashboard-right-panel { min-height: 600px; }
  .project-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 8px; }

  /* ── WISCHBARE PROJEKTKACHELN ── */
  .project-slider-section { margin: 12px 0; }
  .project-slider { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 4px; }
  .project-slider::-webkit-scrollbar { display: none; }
  .project-slider-card { flex: 0 0 80vw; max-width: 300px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; }
  .project-slider-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
  .slider-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); transition: background 0.2s; }
  .slider-dot.active { background: var(--accent); }

  /* ── MOBILER KALENDER-TAB ── */
  #calendar-view { padding: 0 16px; }
  .cal-view-switcher { display: flex; gap: 6px; padding: 10px 0; align-items: center; }
  .cal-view-btn { padding: 4px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; color: var(--text); }
  .cal-view-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
  .cal-fab-btn { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

  /* ── SIDEBAR COMPACT PROJECT ITEMS ── */
  .sidebar-project { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--border); margin-bottom: 6px; transition: background 0.15s; background: var(--surface); }
  .sidebar-project:hover { background: var(--surface2); }
  .sidebar-active { border-color: var(--accent) !important; background: var(--accent-dim) !important; }
  .sidebar-project-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
  .sidebar-title { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .sidebar-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-dim); margin-top: 3px; }
  .sidebar-next { font-size: 11px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* ── DESKTOP ── */
  @media (min-width: 768px) {
    #main { display: flex !important; flex-direction: row; overflow: hidden; padding: 0; }

    /* Left: main content (dashboard or detail) */
    #content-area { flex: 1; min-width: 0; overflow-y: auto; height: 100%; position: relative; }
    #bottom-nav { position: static; width: 100%; display: flex; flex-direction: row; height: auto; border-top: none; border-bottom: 1px solid var(--border); padding: 8px 16px; gap: 8px; z-index: auto; }
    #bottom-nav .nav-btn { flex: 0 0 auto; flex-direction: row; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 12px; gap: 6px; }
    #bottom-nav .nav-btn.active { border-color: var(--accent); background: var(--accent-dim); }
    .admin-page { padding: 18px 20px 36px; }
    .admin-close { display: block; }
    .admin-actions { grid-template-columns: repeat(2, minmax(0, 220px)); }
    .admin-metrics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    #detail-view { padding: 20px 24px; padding-bottom: 40px; }
    #detail-view.active { display: block; }

    /* Right: compact project sidebar */
    #list-view { width: 320px; min-width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; height: 100%; padding: 12px 16px; display: block !important; order: 2; transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease, opacity 0.25s ease; }
    #list-view.hidden { display: block !important; }
    #list-view.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; opacity: 0; overflow: hidden; border-left: none; }
    #sidebar-toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 10; width: 20px; height: 48px; background: var(--surface2); border: 1px solid var(--border); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-dim); transition: background 0.15s, color 0.15s; }
    #sidebar-toggle:hover { background: var(--accent-dim); color: var(--accent); }

    /* Hide verbose filter chips in the sidebar */
    .chip[data-filter="open_todos"],
    .chip[data-filter="recently_changed"] { display: none; }

    /* Dashboard 2-col and project grid */
    .dash-two-col { grid-template-columns: 1fr 1.5fr; }
    .project-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .project-slider-section { display: none; }
    #calendar-view { display: none !important; }
    #nav-calendar { display: none; }

    #fab-area { bottom: 16px; }
    .back-btn { display: none !important; }
    .modal-overlay { align-items: center; }
    .sheet { border-radius: var(--radius); max-width: 480px; margin: 0 auto; }
  }

  /* Mobile: adjust main padding for bottom nav + FABs */
  @media (max-width: 767px) {
    #main { padding-bottom: calc(56px + 80px + var(--safe-bottom)); }
    #fab-area { bottom: calc(56px + 16px + var(--safe-bottom)); }
    #sidebar-toggle { display: none; }
  }

/* ══ GANTT VIEW ══════════════════════════════════════════ */
#gantt-view {
  padding: 12px 16px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#gantt-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.btn-view-switch {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-view-switch.active,
.btn-view-switch:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#gantt-container {
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.custom-gantt {
  --gantt-header-h: 52px;
  --gantt-row-h: 32px;
  --gantt-project-blue: var(--accent);
  --gantt-project-green: var(--green);
  --gantt-project-yellow: var(--yellow);
  --fill-warning: var(--yellow);
  --fill-success: var(--green);
  --surface-3: var(--surface3);
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.gantt-label-pane {
  flex: 0 0 180px;
  width: 180px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.gantt-label-heading {
  height: var(--gantt-header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.gantt-label-body {
  height: calc(100% - var(--gantt-header-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.gantt-label-body::-webkit-scrollbar {
  display: none;
}

.gantt-label-row,
.gantt-line-row {
  height: var(--gantt-row-h);
  box-sizing: border-box;
}

.gantt-label-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  white-space: nowrap;
  overflow: hidden;
}

.gantt-project-label {
  color: #fff;
  font-weight: 700;
}

.gantt-project-label.status-active { background: var(--gantt-project-blue); }
.gantt-project-label.status-done { background: var(--gantt-project-green); }
.gantt-project-label.status-planned { background: var(--gantt-project-yellow); }

.gantt-toggle {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  border: 0;
  border-radius: 4px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.gantt-child-label {
  padding-left: 30px;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--surface);
}

.gantt-child-label:hover {
  background: var(--surface2);
  color: var(--text);
}

.gantt-label-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gantt-label-diamond {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 12px;
  line-height: 1;
  margin-left: -18px;
}

.gantt-timeline-pane {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.gantt-timeline-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.gantt-timeline-inner {
  min-height: 100%;
}

.gantt-time-header {
  position: sticky;
  top: 0;
  z-index: 4;
  height: var(--gantt-header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.gantt-month-row,
.gantt-day-row {
  position: relative;
  height: 26px;
}

.gantt-month-cell,
.gantt-day-cell {
  position: absolute;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 8px;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
}

.gantt-month-cell {
  font-weight: 700;
  color: var(--text-muted);
}

.gantt-row-stack {
  position: relative;
}

.gantt-line-row {
  position: relative;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background-image: linear-gradient(to right, color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 1px);
  background-size: 84px 100%;
}

.gantt-line-row.type-project {
  background-color: color-mix(in srgb, var(--surface2) 55%, transparent);
}

.gantt-bar,
.gantt-diamond {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  cursor: pointer;
}

.gantt-project-bar {
  height: 16px;
  border-radius: 4px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.gantt-project-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-todo-bar {
  height: 10px;
  min-width: 10px;
  border-radius: 5px;
}

.gantt-todo-bar-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

.type-project.status-active .gantt-project-bar { background: var(--gantt-project-blue); }
.type-project.status-done .gantt-project-bar { background: var(--gantt-project-green); }
.type-project.status-planned .gantt-project-bar { background: var(--gantt-project-yellow); }

.gantt-line-row.status-active .gantt-todo-bar { background: var(--fill-warning); }
.gantt-line-row.status-done .gantt-todo-bar { background: var(--fill-success); }
.gantt-line-row.status-planned .gantt-todo-bar { background: var(--surface-3); }

.gantt-line-row.type-appointment .gantt-todo-bar {
  background: transparent;
  border: 2px dashed currentColor;
}

.gantt-line-row.type-appointment.status-active { color: var(--fill-warning); }
.gantt-line-row.type-appointment.status-done { color: var(--fill-success); }
.gantt-line-row.type-appointment.status-planned { color: var(--text-dim); }

.gantt-diamond {
  width: 22px;
  height: 22px;
  margin-left: -11px;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  line-height: 22px;
}

.gantt-line-row.status-done .gantt-diamond { color: var(--fill-success); }
.gantt-line-row.status-active .gantt-diamond { color: var(--fill-warning); }
.gantt-line-row.status-planned .gantt-diamond { color: var(--surface-3); }

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  z-index: 3;
  pointer-events: none;
}

/* Frappe Gantt bar overrides */
#gantt-container .gantt-project-group .bar,
#dashboard-gantt-container .gantt-project-group .bar {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2px;
  height: 22px !important;
}
#gantt-container .gantt-project-group .bar-label,
#dashboard-gantt-container .gantt-project-group .bar-label {
  font-weight: 700;
  fill: #1a1a1a;
  text-anchor: middle;
}

#gantt-container .gantt-planned .bar,
#dashboard-gantt-container .gantt-planned .bar {
  fill: #6366f1;
  opacity: 0.55;
}

#gantt-container .gantt-active .bar,
#dashboard-gantt-container .gantt-active .bar {
  fill: var(--yellow, #f5a623);
}

#gantt-container .gantt-done .bar,
#dashboard-gantt-container .gantt-done .bar {
  fill: var(--green, #3ecf8e);
  opacity: 1;
}

/* Todo-flagged Gantt markers (🏁 Meilenstein / 📅 Termin checkboxes on todos)
   custom_class ist ein einzelnes Token (z.B. "gantt-milestone-active"), da
   Frappe Gantt den Wert per DOMTokenList.add() setzt und bei einem String
   mit Leerzeichen einen InvalidCharacterError wirft. */
#gantt-container [class*="gantt-milestone-"] .bar,
#dashboard-gantt-container [class*="gantt-milestone-"] .bar {
  width: 14px !important;
  height: 14px !important;
  rx: 0;
  ry: 0;
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5px;
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(45deg);
}
#gantt-container [class*="gantt-milestone-"] .bar-progress,
#dashboard-gantt-container [class*="gantt-milestone-"] .bar-progress {
  display: none;
}

#gantt-container [class*="gantt-appointment-"] .bar,
#dashboard-gantt-container [class*="gantt-appointment-"] .bar {
  fill: var(--surface);
  stroke: #0891b2;
  stroke-width: 2px;
  stroke-dasharray: 4 2;
}
#gantt-container [class*="gantt-appointment-"] .bar-progress,
#dashboard-gantt-container [class*="gantt-appointment-"] .bar-progress {
  display: none;
}

/* Erledigte (status=done) Meilenstein-/Termin-Todos sollen trotz Flag-Farbe gruen erscheinen */
#gantt-container .gantt-milestone-done .bar,
#dashboard-gantt-container .gantt-milestone-done .bar {
  fill: var(--green, #3ecf8e);
}

#gantt-container .gantt-appointment-done .bar,
#dashboard-gantt-container .gantt-appointment-done .bar {
  stroke: var(--green, #3ecf8e);
}

/* Dark mode for Frappe Gantt */
#gantt-container.gantt-dark .grid-background {
  fill: var(--surface);
}

#gantt-container.gantt-dark .grid-row:nth-child(even) {
  fill: var(--surface2, #1a1a1a);
}

#gantt-container.gantt-dark .tick,
#gantt-container.gantt-dark .row-line {
  stroke: var(--border);
}

#gantt-container.gantt-dark .lower-text,
#gantt-container.gantt-dark .upper-text {
  fill: var(--text-muted);
}

/* ══ MILESTONE LIST (project-detail tab) ════════════════ */
.milestone-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.milestone-item:last-child {
  border-bottom: none;
}

.milestone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.milestone-body {
  flex: 1;
  min-width: 0;
}

.milestone-title {
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.milestone-title:hover {
  color: var(--accent);
}

.milestone-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ══ CALENDAR MILESTONE CHIP ════════════════════════════ */
@media (max-width: 900px) {
  .cal-chip-milestone {
    background: #7c3aed;
    color: #fff;
  }
}

.cal-chip-milestone {
  background: #7c3aed;
  color: #fff;
}

/* ══ DASHBOARD RIGHT PANEL ══════════════════════════════ */
.panel-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.panel-tabs-left { display: flex; gap: 4px; }
.panel-tabs-right { display: none; gap: 4px; }
@media (min-width: 768px) { .panel-tabs-right { display: flex; } }

.panel-tab {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}

.panel-tab.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.cal-add-appt {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 4px;
  display: block;
}
.cal-add-appt:hover { border-color: var(--accent); color: var(--accent); }

#dashboard-right-panel {
  height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dash-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
#dash-panel-gantt {
  overflow-x: auto;
}

/* ══ DASHBOARD MINI-KALENDER ════════════════════════════ */
.dash-cal { width: 100%; border-collapse: collapse; font-size: 12px; }
.dash-cal th { text-align: center; padding: 4px 2px; color: var(--text-dim); font-weight: 500; }
.dash-cal td { text-align: center; padding: 4px 2px; cursor: pointer; border-radius: var(--radius-sm); vertical-align: top; }
.dash-cal td:hover { background: var(--surface2); }
.dash-cal td.today { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.dash-cal td.selected { background: var(--surface3); }
.dash-cal td.has-events::after { content: '.'; display: block; color: var(--accent); font-size: 8px; line-height: 1; }
.dash-cal-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin: 1px; }
.dash-cal-dot.todo { background: #3b82f6; }
.dash-cal-dot.milestone { background: #8b5cf6; }
.dash-cal-dot.appointment { background: #d97706; }
.dash-cal-dots { line-height: 1; }
.dash-cal-day-list { margin-top: 8px; font-size: 12px; }
.dash-cal-day-item { display: flex; align-items: center; gap: 5px; padding: 4px 6px; border-radius: var(--radius-sm); margin-bottom: 2px; background: var(--surface2); }

/* ══ CALENDAR APPOINTMENT CHIP ══════════════════════════ */
@media (max-width: 900px) {
  .cal-chip-appointment {
    background: #d97706;
    color: #fff;
  }
}

.cal-chip-appointment {
  background: #d97706;
  color: #fff;
}

/* ══ CALENDAR TODO MILESTONE/TERMIN FLAGS ═══════════════ */
@media (max-width: 900px) {
  .cal-chip-todo-appointment {
    background: #0891b2;
    color: #fff;
  }
}

.cal-chip-todo-appointment {
  background: #0891b2;
  color: #fff;
}

/* ══ APPOINTMENT LIST ═══════════════════════════════════ */
.appointment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}

.appointment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.appointment-item:hover {
  background: var(--surface2);
}

.appointment-title {
  font-weight: 500;
  font-size: 14px;
}

.appointment-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ══ POST-ITS ═══════════════════════════════════════════ */
.postit-card {
  --pc-bg: #fef08a;
  --pc-text: #713f12;
  position: relative;
  width: 176px;
  min-height: 150px;
  flex-shrink: 0;
  background: var(--pc-bg);
  color: var(--pc-text);
  border-radius: 6px;
  padding: 12px 12px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
  transition: transform 0.15s;
}

.postit-card.dragging { opacity: 0.4; }
.postit-card:active { cursor: grabbing; }

.postit-card.color-yellow { --pc-bg: #fef08a; --pc-text: #713f12; }
.postit-card.color-blue   { --pc-bg: #bfdbfe; --pc-text: #1e3a5f; }
.postit-card.color-green  { --pc-bg: #bbf7d0; --pc-text: #14532d; }
.postit-card.color-red    { --pc-bg: #fecaca; --pc-text: #7f1d1d; }
.postit-card.color-purple { --pc-bg: #e9d5ff; --pc-text: #4c1d95; }
.postit-card.color-orange { --pc-bg: #fed7aa; --pc-text: #7c2d12; }

.postit-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  min-height: 40px;
  cursor: text;
  word-break: break-word;
  white-space: pre-wrap;
}

.postit-title-input {
  font: inherit;
  font-weight: 600;
  width: 100%;
  min-height: 40px;
  background: rgba(255,255,255,0.35);
  border: none;
  border-radius: 4px;
  padding: 2px 4px;
  color: inherit;
  resize: none;
}

.postit-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.postit-project-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.postit-deadline {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
}

.postit-colors {
  display: flex;
  gap: 4px;
}

.postit-color-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.25);
  cursor: pointer;
  padding: 0;
}
.postit-color-dot.color-yellow { background: #fef08a; }
.postit-color-dot.color-blue   { background: #bfdbfe; }
.postit-color-dot.color-green  { background: #bbf7d0; }
.postit-color-dot.color-red    { background: #fecaca; }
.postit-color-dot.color-purple { background: #e9d5ff; }
.postit-color-dot.color-orange { background: #fed7aa; }
.postit-color-dot.selected { border-color: rgba(0,0,0,0.6); box-shadow: 0 0 0 1.5px rgba(255,255,255,0.6); }

.postit-actions {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(0,0,0,0.12);
  padding-top: 6px;
  margin-top: auto;
}

.postit-action-btn {
  background: none;
  border: none;
  font-size: 13px;
  padding: 3px 5px;
  border-radius: 4px;
  cursor: pointer;
  color: inherit;
  opacity: 0.75;
}
.postit-action-btn:hover { opacity: 1; background: rgba(255,255,255,0.35); }

.postit-new {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: transparent;
  border: 2px dashed var(--border);
  box-shadow: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.postit-new:hover { border-color: var(--accent); color: var(--accent); }

.postit-new-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.postit-new-form textarea {
  font: inherit;
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  background: var(--surface);
  color: var(--text);
  resize: none;
}

.postit-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-width: thin;
}

.postit-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 2px 16px;
}

.postit-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.postit-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}

.postit-see-all {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

/* ══ DASHBOARD DESKTOP REDESIGN (>=768px, Übersicht only) ═══ */
@media (min-width: 768px) {
  .dash-stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    padding: 10px 4px;
    margin: -4px -4px 16px;
  }
  .dash-stats-chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
  }
  .stat-chip strong { color: var(--text); font-weight: 700; }
  .stat-chip:hover { border-color: var(--accent); }
  .stat-chip.stat-chip-danger { background: var(--bg-danger); color: var(--text-danger); border-color: transparent; }
  .stat-chip.stat-chip-danger strong { color: var(--text-danger); }
  .dash-stats-actions { display: flex; gap: 8px; }

  /* Two-column 1fr/1fr grid (desktop dashboard only — distinct from .dash-two-col) */
  .dash-grid-v2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
  .dash-col-left { display: flex; flex-direction: column; gap: 4px; }
  .dash-col-right { display: flex; flex-direction: column; min-height: 620px; height: calc(100vh - 122px); }
  .dash-cal-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .dash-cal-wrap .dash-panel { flex: 1 1 auto; overflow: hidden; }
  .dash-cal-wrap .cal-container { min-height: 0; }
  .dash-cal-wrap .cal-grid-month {
    flex: 1 1 auto;
    height: auto;
    min-height: 540px;
    grid-template-rows: repeat(6, minmax(86px, 1fr));
  }
  .dash-cal-wrap .cal-grid-week { flex: 1 1 auto; height: auto; min-height: 540px; }
  .dash-cal-wrap .cal-day { min-height: 86px; overflow: hidden; }
  /* "Heute / Als Nächstes" — desktop rows */
  .today-more-footer {
    text-align: center;
    font-size: 12px;
    color: var(--accent);
    padding: 8px 0 0;
    cursor: pointer;
    font-weight: 600;
  }
  .today-more-footer:hover { text-decoration: underline; }

  .dash-today-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
  }
  .dash-today-row:last-child { border-bottom: none; }
  .dash-today-row:hover { background: var(--surface2); }
  .dash-today-title-wrap { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
  .dash-today-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-today-project { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-today-dl { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
  .dash-today-dl.overdue { color: var(--text-danger); font-weight: 600; }

  /* Compact project list (right column) */
  .dash-project-list { display: flex; flex-direction: column; }
  .dash-project-row { padding: 8px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
  .dash-project-row:last-child { border-bottom: none; }
  .dash-project-row:hover { background: var(--surface2); }
  .dash-project-row-top { display: flex; align-items: center; gap: 8px; }
  .dash-project-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .dash-project-dot.status-planned { background: var(--text-dim); }
  .dash-project-dot.status-active  { background: var(--yellow); }
  .dash-project-dot.status-done    { background: var(--green); }
  .dash-project-name { flex: 1; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .dash-project-open { font-size: 11px; color: var(--text-dim); flex-shrink: 0; white-space: nowrap; }
  .dash-project-next { font-size: 11px; color: var(--text-muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-project-progress { margin-top: 4px; }

  /* Post-its carousel (desktop dashboard) */
  .postit-carousel { display: flex; align-items: center; gap: 8px; }
  .postit-carousel-row { overflow: hidden; }
  .postit-carousel-arrow {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .postit-carousel-arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
  .postit-carousel-arrow:disabled { opacity: 0.3; cursor: default; }
  .postit-carousel-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
  .postit-carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); border: none; cursor: pointer; padding: 0; }
  .postit-carousel-dot.active { background: var(--accent); }
}

/* ══ INVENTORY / LAGER ══════════════════════════════════════ */
#inventory-view { display: none; }

.inv-subnav { display: flex; gap: 8px; margin-bottom: 14px; }
.inv-subnav-btn { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: none; color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.inv-subnav-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.inv-chip-filters .filter-row { margin-bottom: 8px; }
.inv-chip-filters .filter-row:last-child { margin-bottom: 14px; }

/* ── STATS (2×2 mobile, 4-across desktop) ── */
.inv-stats-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; margin-bottom: 4px; }
@media (min-width: 768px) { .inv-stats-row { grid-template-columns: repeat(4,1fr); gap: 8px; } }

/* ── CONDITION BADGES ── */
.cond-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.cond-new    { background: #1e3a6e; color: #4f8ef7; }
.cond-good   { background: var(--green-dim); color: var(--green); }
.cond-used   { background: var(--yellow-dim); color: var(--yellow); }
.cond-broken { background: var(--red-dim); color: var(--red); }

.cond-option {
  flex: 1; padding: 9px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.cond-option.selected.cond-new    { border-color: #4f8ef7; background: #1e3a6e; color: #4f8ef7; }
.cond-option.selected.cond-good   { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.cond-option.selected.cond-used   { border-color: var(--yellow); background: var(--yellow-dim); color: var(--yellow); }
.cond-option.selected.cond-broken { border-color: var(--red); background: var(--red-dim); color: var(--red); }

/* ── ITEM GRID / CARDS ── */
.inv-item-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 4px; }
.inv-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.inv-item-card:active { background: var(--surface2); }
.inv-item-photo { aspect-ratio: 4/3; background: var(--surface3); position: relative; overflow: hidden; }
.inv-item-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.15s, opacity 0.15s; }
.inv-item-photo-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--text-dim); }
.inv-item-card.is-lent .inv-item-photo img,
.inv-item-card.is-lent .inv-item-photo-placeholder { filter: grayscale(1); opacity: 0.5; }
.inv-lent-banner {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.72); color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 5px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-item-body { padding: 10px 12px 12px; }
.inv-item-top-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.inv-item-name { font-size: 13px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.inv-item-breadcrumb { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-category-tag { display: inline-block; font-size: 10px; font-weight: 600; color: var(--text-muted); background: var(--surface3); padding: 2px 7px; border-radius: 10px; }

/* ── LOCATION TREE ── */
.inv-tree-row { display: flex; align-items: center; gap: 6px; padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s; }
.inv-tree-row:hover { background: var(--surface2); }
.inv-tree-row.active { background: var(--accent-dim); color: var(--accent); }
.inv-tree-toggle { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-dim); font-size: 10px; transition: transform 0.15s; }
.inv-tree-toggle.expanded { transform: rotate(90deg); }
.inv-tree-name { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-tree-count { font-size: 11px; color: var(--text-dim); background: var(--surface3); padding: 1px 7px; border-radius: 10px; flex-shrink: 0; }
.inv-tree-children { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 6px; }
.inv-tree-actions { display: flex; gap: 2px; flex-shrink: 0; }
.inv-tree-action-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; padding: 2px 5px; }
.inv-tree-action-btn:hover { color: var(--text); }

/* ── ITEM DETAIL ── */
.inv-detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.inv-back-btn { background: var(--surface3); border: none; color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.inv-detail-title { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.inv-detail-photos {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 14px;
  padding-bottom: 2px;
}
.inv-detail-photos::-webkit-scrollbar { display: none; }
.inv-detail-photo {
  flex: 0 0 78vw;
  max-width: 320px;
  aspect-ratio: 4/3;
  scroll-snap-align: start;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface3);
}
.inv-detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.inv-photo-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.inv-detail-photo-add {
  flex: 0 0 78vw;
  max-width: 320px;
  aspect-ratio: 4/3;
  scroll-snap-align: start;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-dim); cursor: pointer; background: var(--surface);
}

.inv-lend-banner-full { display: flex; align-items: center; gap: 10px; background: var(--yellow-dim); color: var(--yellow); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.inv-lend-banner-full.overdue { background: var(--red-dim); color: var(--red); }

.inv-field-grid { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin-bottom: 14px; }
.inv-field-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-dim); margin-top: 10px; }
.inv-field-value { font-size: 14px; color: var(--text); margin-top: 2px; word-break: break-word; }

.inv-collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  background: none; border: none; padding: 0;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
  margin: 20px 0 8px;
  font-family: inherit;
  cursor: pointer;
}
.inv-collapsible-icon { font-size: 10px; transition: transform 0.15s; }
.inv-collapsible-icon.expanded { transform: rotate(90deg); }

.inv-history-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.inv-history-item:last-child { border-bottom: none; }
.inv-history-name { font-weight: 600; }
.inv-history-dates { color: var(--text-dim); }

.inv-qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; background: var(--surface2); border-radius: var(--radius); margin: 14px 0; }
.inv-qr-box img { width: 140px; height: 140px; background: #fff; border-radius: 8px; padding: 8px; }

/* ── PHOTO UPLOAD (modal) ── */
.inv-modal-photos { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-bottom: 6px; }
.inv-modal-photo-thumb { aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative; background: var(--surface3); }
.inv-modal-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── AMAZON IMPORT (preview table) ── */
.inv-amazon-summary { font-size: 13px; color: var(--text-muted); margin: 4px 0 10px; }
.inv-amazon-scroll { overflow-x: auto; margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inv-amazon-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
.inv-amazon-table th, .inv-amazon-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.inv-amazon-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); white-space: nowrap; background: var(--surface2); }
.inv-amazon-table tbody tr:last-child td { border-bottom: none; }
.inv-amazon-table select { width: 100%; min-width: 130px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 12px; padding: 5px 6px; font-family: inherit; }
.inv-amazon-row-skipped { opacity: 0.45; }
.inv-amazon-row-skipped td { font-style: italic; font-size: 12px; }

@media (min-width: 768px) {
  .inv-item-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .inv-detail-photos {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    overflow-x: visible;
    scroll-snap-type: none;
  }
  .inv-detail-photo, .inv-detail-photo-add { flex: unset; max-width: none; aspect-ratio: 1; }
  .inv-field-grid { grid-template-columns: 1fr 1fr; }
}
