:root {
      --bg: #0f1419;
      --surface: #1a2332;
      --surface2: #243044;
      --border: #2d3a4f;
      --text: #e8eef7;
      --text-muted: #8b9cb3;
      --accent: #3b82f6;
      --accent-hover: #2563eb;
      --success: #10b981;
      --danger: #ef4444;
      --radius: 10px;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    html {
      -webkit-text-size-adjust: 100%;
      height: -webkit-fill-available;
    }
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      min-height: -webkit-fill-available;
      line-height: 1.45;
      overscroll-behavior-y: none;
    }
    button, .btn, label, th, a {
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    input, select {
      font-size: 16px !important;
      -webkit-appearance: none;
      appearance: none;
    }

    header {
      background: #1e3a5f;
      border-bottom: 1px solid var(--border);
      padding: 0.85rem 1rem;
      position: -webkit-sticky;
      position: sticky;
      top: 0;
      z-index: 100;
    }
    .header-inner {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 0.6rem;
      max-width: 1400px;
      margin: 0 auto;
    }
    .logo { display: flex; align-items: center; gap: 0.6rem; }
    .logo-icon {
      width: 36px; height: 36px;
      background: var(--accent);
      border-radius: 8px;
      display: flex; align-items: center; justify-content: center;
      font-weight: 800; color: #fff; font-size: 1rem;
      flex-shrink: 0;
    }
    .logo h1 { font-size: 1.1rem; font-weight: 700; }
    .logo span { display: block; font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }

    .header-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
    .btn {
      display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
      padding: 0.55rem 0.85rem;
      border-radius: 8px; border: none;
      font-size: 0.82rem; font-weight: 600;
      cursor: pointer;
      color: var(--text);
      background: var(--surface2);
      border: 1px solid var(--border);
    }
    .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
    .btn-success { background: var(--success); border-color: var(--success); color: #fff; }
    .btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }

    .stats-bar {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 0.5rem;
      padding: 0.75rem 1rem;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      max-width: 1400px;
      margin: 0 auto;
    }
    .stat-card {
      background: var(--surface2);
      border-radius: 8px;
      padding: 0.65rem 0.75rem;
      border: 1px solid var(--border);
    }
    .stat-card .label {
      font-size: 0.65rem; color: var(--text-muted);
      text-transform: uppercase; letter-spacing: 0.03em;
    }
    .stat-card .value { font-size: 1.1rem; font-weight: 700; }
    .stat-card .value.accent { color: var(--accent); }
    .stat-card .value.success { color: var(--success); }

    .main {
      display: grid;
      grid-template-columns: 280px 1fr;
      max-width: 1400px;
      margin: 0 auto;
      min-height: 50vh;
    }
    .sidebar {
      background: var(--surface);
      border-right: 1px solid var(--border);
      padding: 1rem;
      overflow-y: auto;
      max-height: calc(100vh - 160px);
      position: -webkit-sticky;
      position: sticky;
      top: 60px;
      -webkit-overflow-scrolling: touch;
    }
    .sidebar h2 {
      font-size: 0.95rem; font-weight: 700;
      margin-bottom: 0.85rem;
      display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    }
    .filter-group { margin-bottom: 1rem; }
    .filter-group > label {
      display: block; font-size: 0.72rem; font-weight: 600;
      color: var(--text-muted); margin-bottom: 0.35rem;
      text-transform: uppercase; letter-spacing: 0.03em;
    }
    .filter-group input[type="text"],
    .filter-group input[type="number"],
    .filter-group select {
      width: 100%;
      padding: 0.55rem 0.7rem;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      outline: none;
    }
    .range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .checkbox-list {
      max-height: 160px; overflow-y: auto;
      background: var(--bg); border: 1px solid var(--border);
      border-radius: 8px; padding: 0.35rem;
      -webkit-overflow-scrolling: touch;
    }
    .checkbox-item {
      display: flex; align-items: center; gap: 0.55rem;
      padding: 0.45rem 0.5rem; border-radius: 6px;
      font-size: 0.82rem; cursor: pointer;
      border: 1px solid transparent;
      margin-bottom: 2px;
      user-select: none;
      -webkit-user-select: none;
    }
    .checkbox-item:active { background: var(--surface2); }
    .checkbox-item input {
      position: absolute;
      opacity: 0;
      width: 0;
      height: 0;
      pointer-events: none;
    }
    /* Custom visible checkbox */
    .checkbox-item .box {
      width: 22px;
      height: 22px;
      min-width: 22px;
      border-radius: 5px;
      border: 2px solid #5b6b82;
      background: #0f1419;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: background 0.12s, border-color 0.12s;
    }
    .checkbox-item .box::after {
      content: '';
      display: none;
      width: 6px;
      height: 11px;
      border: solid #fff;
      border-width: 0 2.5px 2.5px 0;
      transform: rotate(45deg);
      margin-top: -2px;
    }
    .checkbox-item input:checked + .box {
      background: #3b82f6;
      border-color: #3b82f6;
    }
    .checkbox-item input:checked + .box::after {
      display: block;
    }
    
    .checkbox-item.is-checked {
      background: rgba(59, 130, 246, 0.12);
      border-color: rgba(59, 130, 246, 0.35);
    }
    .checkbox-item.is-checked .cb-label {
      color: #fff;
      font-weight: 600;
    }

    .checkbox-item input:checked ~ .cb-label {
      color: #fff;
      font-weight: 600;
    }
    .checkbox-item .cb-label {
      color: var(--text-muted);
      line-height: 1.3;
    }
    /* Selected row highlight */
    .checkbox-item:has(input:checked) {
      background: rgba(59, 130, 246, 0.12);
      border-color: rgba(59, 130, 246, 0.35);
    }

    .content { padding: 0.85rem 1rem 1.5rem; overflow-x: auto; }
    .toolbar {
      display: flex; flex-wrap: wrap; gap: 0.6rem;
      align-items: center; justify-content: space-between;
      margin-bottom: 0.75rem;
    }
    .search-box { flex: 1; min-width: 180px; max-width: 360px; }
    .search-box input {
      width: 100%;
      padding: 0.6rem 0.85rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      outline: none;
    }
    .results-info { font-size: 0.8rem; color: var(--text-muted); }
    .results-info strong { color: var(--text); }

    .table-wrap {
      background: var(--surface);
      border-radius: var(--radius);
      border: 1px solid var(--border);
      overflow: hidden;
    }
    table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
    thead { background: var(--surface2); }
    th {
      padding: 0.65rem 0.75rem; text-align: left;
      font-weight: 600; color: var(--text-muted);
      text-transform: uppercase; font-size: 0.68rem;
      letter-spacing: 0.03em; border-bottom: 1px solid var(--border);
      white-space: nowrap; cursor: pointer; user-select: none;
    }
    th.sorted { color: var(--accent); }
    td {
      padding: 0.55rem 0.75rem;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }
    tbody tr:active { background: rgba(59,130,246,0.08); }
    .price { font-weight: 600; color: var(--success); white-space: nowrap; }
    .badge {
      display: inline-block; padding: 0.15rem 0.5rem;
      border-radius: 20px; font-size: 0.7rem; font-weight: 600;
      background: rgba(16,185,129,0.15); color: var(--success);
    }
    .project-tag {
      display: inline-block; padding: 0.12rem 0.45rem;
      border-radius: 5px; font-size: 0.7rem; font-weight: 600;
      background: rgba(59,130,246,0.15); color: #60a5fa;
    }
    .unit-num { font-family: ui-monospace, monospace; font-size: 0.78rem; color: var(--text-muted); }

    .pagination {
      display: flex; align-items: center; justify-content: space-between;
      padding: 0.85rem 0; flex-wrap: wrap; gap: 0.6rem;
    }
    .page-btns { display: flex; gap: 0.3rem; flex-wrap: wrap; }
    .page-btn {
      min-width: 38px; height: 38px;
      display: flex; align-items: center; justify-content: center;
      border-radius: 8px; border: 1px solid var(--border);
      background: var(--surface); color: var(--text);
      font-size: 0.85rem; cursor: pointer;
    }
    .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
    .page-btn:disabled { opacity: 0.35; }
    .page-size select {
      padding: 0.4rem 0.55rem;
      background: var(--surface); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text);
    }

    .empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
    .boot-msg {
      text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.95rem;
    }
    .iphone-help {
      display: none;
      background: #3b2f1a;
      border: 1px solid #a16207;
      color: #fde68a;
      padding: 0.85rem 1rem;
      margin: 0.75rem 1rem;
      border-radius: 8px;
      font-size: 0.85rem;
      line-height: 1.5;
    }
    .iphone-help strong { color: #fbbf24; }

    .modal-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.55); z-index: 300;
      align-items: center; justify-content: center;
      padding: 1rem;
    }
    .modal-overlay.show { display: flex; }
    .modal {
      background: var(--surface); border-radius: 12px;
      border: 1px solid var(--border); padding: 1.25rem;
      width: 100%; max-width: 400px;
    }
    .modal h3 { margin-bottom: 0.85rem; font-size: 1.05rem; }
    .modal .form-group { margin-bottom: 0.85rem; }
    .modal .form-group label {
      display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem;
    }
    .modal .form-group select {
      width: 100%; padding: 0.55rem;
      background: var(--bg); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text);
    }
    .modal-actions { display: flex; gap: 0.45rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
    .modal-actions .btn { flex: 1; min-width: 100px; }

    .mobile-bottom-bar { display: none; }
    .filter-backdrop { display: none; }
    .desktop-only { display: inline-flex; }
    .mobile-only { display: none; }

    @media (max-width: 900px) {
      .stats-bar { grid-template-columns: repeat(2, 1fr); }
      .main { grid-template-columns: 1fr; }
      .desktop-only { display: none !important; }
      .mobile-only { display: inline-flex !important; }

      .sidebar {
        display: none;
        position: fixed; inset: 0; z-index: 250;
        max-height: none; top: 0;
        background: var(--bg);
        padding: 1rem 1rem 6rem;
        border-right: none;
        -webkit-overflow-scrolling: touch;
      }
      .sidebar.open { display: block; }
      .filter-backdrop.show {
        display: block; position: fixed; inset: 0;
        background: rgba(0,0,0,0.45); z-index: 240;
      }
      .mobile-bottom-bar {
        display: flex !important;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 0.55rem 0.65rem;
        padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
        gap: 0.4rem;
      }
      .mobile-bottom-bar .btn { flex: 1; padding: 0.7rem 0.4rem; font-size: 0.8rem; }
      .content { padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }

      .table-wrap { border: none; background: transparent; overflow: visible; }
      table, thead, tbody, th, td, tr { display: block; }
      thead { display: none; }
      tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 0.65rem;
        padding: 0.75rem 0.9rem;
      }
      tbody td {
        border: none; padding: 0.22rem 0;
        display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem;
        font-size: 0.84rem;
      }
      tbody td:before {
        content: attr(data-label);
        font-weight: 600; color: var(--text-muted);
        font-size: 0.7rem; text-transform: uppercase;
        min-width: 78px; flex-shrink: 0;
      }
      .toolbar { flex-direction: column; align-items: stretch; }
      .search-box { max-width: none; }
      .pagination { flex-direction: column; align-items: center; }
    }
    @media (max-width: 480px) {
      .stats-bar { grid-template-columns: 1fr 1fr; }
      .logo span { display: none; }
    }
