﻿    :root {
      --bg: #f5f7fb;
      --card: #ffffff;
      --line: #d9e0ea;
      --line-strong: #bcc7d8;
      --text: #162033;
      --muted: #5f6f86;
      --soft: #eef3f9;
      --accent: #244c8f;
      --accent-soft: #e7eefc;
      --success: #1e8a56;
      --success-soft: #e9f8f0;
      --warning: #b36b00;
      --warning-soft: #fff4d7;
      --extra: #7a4d00;
      --extra-soft: #fff7e6;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: Inter, Arial, Helvetica, sans-serif;
      background: var(--bg);
      color: var(--text);
    }

    .page {
      max-width: 1700px;
      margin: 0 auto;
      padding: 24px;
    }

    .header {
      margin-bottom: 20px;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 16px;
      flex-wrap: wrap;
    }

    h1 {
      margin: 0 0 8px;
      font-size: clamp(28px, 4vw, 42px);
      line-height: 1.05;
    }

    .subtitle {
      margin: 0;
      color: var(--muted);
      font-size: 15px;
    }

    .theme-control {
      display: grid;
      gap: 6px;
      min-width: 150px;
    }

    .theme-control label {
      margin: 0;
      color: var(--muted);
    }

    .section {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 18px;
      box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
      margin-bottom: 18px;
    }

    .section h2 {
      margin: 0 0 14px;
      font-size: 20px;
    }

    .section-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 14px;
    }

    .section-note {
      color: var(--muted);
      font-size: 14px;
      margin: 0;
    }

    .grid {
      display: grid;
      gap: 14px;
    }

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

    .metric,
    .input-card {
      background: linear-gradient(180deg, #ffffff 0%, var(--soft) 100%);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 14px;
    }

    .metric {
      border-left: 4px solid var(--accent);
    }

    .metric-label {
      font-size: 13px;
      color: var(--muted);
      margin-bottom: 6px;
    }

    .metric-value {
      font-size: 30px;
      font-weight: 800;
      line-height: 1;
    }

    .metric-sub {
      margin-top: 6px;
      font-size: 12px;
      color: var(--muted);
    }

    .envelopes-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 14px;
      margin-bottom: 16px;
    }

    label {
      display: block;
      font-size: 13px;
      font-weight: 700;
      margin-bottom: 8px;
    }

    input[type="number"],
    input[type="search"],
    select {
      width: 100%;
      height: 44px;
      border-radius: 12px;
      border: 1px solid var(--line-strong);
      padding: 0 12px;
      font-size: 16px;
      color: var(--text);
      background: #fff;
      outline: none;
    }

    input[type="number"]:focus,
    input[type="search"]:focus,
    select:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(36, 76, 143, 0.12);
    }

    .hint {
      margin-top: 8px;
      font-size: 12px;
      color: var(--muted);
    }

    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 14px;
    }

    .toolbar-left,
    .toolbar-right {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: center;
    }

    button {
      appearance: none;
      border: 1px solid var(--line-strong);
      background: #fff;
      color: var(--text);
      border-radius: 12px;
      padding: 10px 14px;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    }

    button.primary {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }

    button:hover {
      filter: brightness(0.98);
      transform: translateY(-1px);
    }

    .table-shell {
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: #fff;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
      scrollbar-color: #aab7ca #eef3f9;
    }

    table {
      width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      min-width: 1150px;
    }

    th, td {
      padding: 7px 8px;
      border-right: 1px solid var(--line);
      border-bottom: 1px solid var(--line);
      text-align: center;
      white-space: nowrap;
      background: #fff;
    }

    thead th {
      background: #eaf0f7;
      font-size: 13px;
      font-weight: 800;
      z-index: 2;
    }

    .album-table thead tr:first-child th {
      height: 46px;
      background: #1f3557;
      color: #fff;
      border-color: rgba(255, 255, 255, 0.14);
      letter-spacing: 0;
    }

    .group-cell {
      background: #eef3f8;
      font-weight: 800;
      min-width: 84px;
      color: #233754;
    }

    .selection-cell {
      text-align: left;
      font-weight: 700;
      min-width: 190px;
      color: #1d2f4a;
    }

    .code-cell {
      min-width: 62px;
      font-weight: 800;
      background: #f2f5f8 !important;
      color: #6b7788;
      cursor: default;
    }

    .number-cell {
      min-width: 58px;
      font-variant-numeric: tabular-nums;
    }

    .sticky-top {
      position: sticky;
      top: 0;
      z-index: 4;
    }

    .sticky-col-1,
    .sticky-col-2,
    .sticky-col-3 {
      position: sticky;
      z-index: 3;
    }

    .sticky-col-1 { left: 0; }
    .sticky-col-2 { left: 84px; }
    .sticky-col-3 { left: 284px; }

    .album-table td.sticky-col-1,
    .album-table td.sticky-col-2,
    .album-table td.sticky-col-3,
    .album-table th.sticky-col-1,
    .album-table th.sticky-col-2,
    .album-table th.sticky-col-3,
    .count-table td.sticky-col-1,
    .count-table td.sticky-col-2,
    .count-table th.sticky-col-1,
    .count-table th.sticky-col-2 {
      box-shadow: 1px 0 0 var(--line);
    }

    .album-table .sticky-col-1,
    .album-table .sticky-col-2,
    .album-table .sticky-col-3,
    .count-table .sticky-col-1,
    .count-table .sticky-col-2 {
      background: #fff;
    }

    .album-table {
      min-width: 1500px;
      font-size: 13px;
    }

    .album-table td {
      height: 46px;
    }

    .album-table tbody tr.album-team-group-start td {
      border-top: 2px solid var(--line-strong);
    }

    .album-table tbody tr.album-extra-row td {
      background: var(--extra-soft);
    }

    .album-table tbody tr.album-extra-row .group-cell,
    .album-table tbody tr.album-extra-row .selection-cell {
      background: #ffefd0;
      color: var(--extra);
    }

    .album-table tbody tr.album-extra-row + tr.album-team-group-start td,
    .album-table tbody tr.album-team-row + tr.album-extra-row td {
      border-top: 3px solid #d5af65;
    }

    .album-table tbody tr:hover td {
      background: #f8fbff;
    }

    .album-table tbody tr.album-extra-row:hover td {
      background: #fff1d4;
    }

    .album-table tbody tr:nth-child(even) td,
    .count-table tbody tr:nth-child(even) td {
      background: #fcfdff;
    }

    .album-table tbody tr:nth-child(even) td.sticky-col-1,
    .album-table tbody tr:nth-child(even) td.sticky-col-2,
    .album-table tbody tr:nth-child(even) td.sticky-col-3,
    .count-table tbody tr:nth-child(even) td.sticky-col-1,
    .count-table tbody tr:nth-child(even) td.sticky-col-2 {
      background: #fcfdff;
    }

    .album-table tbody tr.album-extra-row td,
    .album-table tbody tr.album-extra-row:nth-child(even) td {
      background: var(--extra-soft);
    }

    .album-table tbody tr.album-extra-row .group-cell,
    .album-table tbody tr.album-extra-row .selection-cell,
    .album-table tbody tr.album-extra-row:nth-child(even) .group-cell,
    .album-table tbody tr.album-extra-row:nth-child(even) .selection-cell {
      background: #ffefd0;
      color: var(--extra);
    }

    .album-table tbody tr:hover td,
    .album-table tbody tr:nth-child(even):hover td {
      background: #f8fbff;
    }

    .album-table tbody tr.album-extra-row:hover td,
    .album-table tbody tr.album-extra-row:nth-child(even):hover td {
      background: #fff1d4;
    }

    .album-table th:last-child,
    .album-table td:last-child,
    .count-table th:last-child,
    .count-table td:last-child,
    .mini-table th:last-child,
    .mini-table td:last-child {
      border-right: 0;
    }

    .album-table tr:last-child td,
    .count-table tr:last-child td,
    .mini-table tr:last-child td {
      border-bottom: 0;
    }

    .count-table {
      min-width: 980px;
    }

    .count-table .selection-cell {
      min-width: 220px;
    }

    .count-input {
      width: 90px;
      min-width: 90px;
      text-align: center;
    }

    .total-cell {
      font-weight: 800;
      background: var(--accent-soft);
      min-width: 92px;
    }

    .mini-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
      gap: 14px;
    }

    .mini-table {
      min-width: 100%;
    }

    .mini-table th {
      background: #edf2f8;
      font-size: 13px;
      font-weight: 800;
    }

    .badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--muted);
      background: #f5f8fc;
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 6px 10px;
    }

    .footer-note {
      color: var(--muted);
      font-size: 13px;
      margin-top: 10px;
    }

    .album-sticker {
      min-width: 58px;
      font-weight: 700;
      cursor: pointer;
      user-select: none;
      touch-action: manipulation;
      border-radius: 0;
      transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    }

    .album-label {
      display: inline-block;
    }

    .album-type-badge {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 24px;
      margin-left: 5px;
      padding: 2px 5px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 800;
      line-height: 1;
      vertical-align: middle;
    }

    .album-sticker.shiny {
      background: #fffdf0;
      box-shadow: inset 0 0 0 1px rgba(194, 141, 0, 0.22);
    }

    .album-sticker.profiled-normal {
      background: #eef7ff;
      box-shadow: inset 0 0 0 1px rgba(36, 76, 143, 0.18);
    }

    .album-sticker.shiny .album-type-badge {
      background: #f4c430;
      color: #3b2a00;
    }

    .album-sticker.profiled-normal .album-type-badge {
      background: #244c8f;
      color: #fff;
    }

    .album-qty {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 28px;
      margin-left: 5px;
      padding: 2px 5px;
      border-radius: 999px;
      background: rgba(30, 138, 86, 0.12);
      color: var(--success);
      font-size: 11px;
      font-weight: 800;
      line-height: 1;
      vertical-align: middle;
    }

    .album-sticker:hover {
      background: #eef5ff !important;
      box-shadow: inset 0 0 0 2px rgba(36, 76, 143, 0.18);
    }

    .album-sticker.owned {
      background: var(--success-soft) !important;
      color: var(--success);
      box-shadow: inset 0 0 0 2px rgba(30, 138, 86, 0.18);
    }

    .album-sticker.complete {
      background: #d9f4e8 !important;
      box-shadow: inset 0 0 0 2px rgba(30, 138, 86, 0.34);
    }

    .album-sticker.complete .album-qty {
      background: var(--success);
      color: #fff;
    }

    .album-sticker.repeated {
      background: var(--warning-soft) !important;
      color: #8a5a00;
      box-shadow: inset 0 0 0 2px rgba(179, 107, 0, 0.28);
    }

    .album-sticker.repeated .album-qty {
      background: var(--warning);
      color: #fff;
    }

    .album-empty-cell {
      background: #f6f8fb !important;
      color: var(--muted);
      box-shadow: inset 0 0 0 1px rgba(217, 224, 234, 0.35);
    }

    .album-actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: center;
      margin-bottom: 14px;
    }

    .inline-control {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin: 0;
      color: var(--muted);
    }

    .inline-control input {
      width: 86px;
      height: 40px;
    }

    .mobile-album-picker {
      display: none;
      margin-top: 14px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: #fff;
      overflow: hidden;
    }

    .mobile-album-controls {
      display: grid;
      gap: 8px;
      padding: 14px;
      background: #f7faff;
      border-bottom: 1px solid var(--line);
    }

    .mobile-album-controls label {
      font-size: 13px;
      font-weight: 800;
      color: var(--muted);
    }

    .mobile-album-controls select {
      min-height: 44px;
    }

    .mobile-album-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 8px;
      padding: 14px;
    }

    .mobile-album-sticker {
      min-height: 46px;
      padding: 8px 6px;
      border-radius: 10px;
      touch-action: manipulation;
    }

    .mobile-album-sticker.owned {
      background: var(--success-soft);
      color: var(--success);
      border-color: rgba(30, 138, 86, 0.35);
      box-shadow: inset 0 0 0 2px rgba(30, 138, 86, 0.14);
    }

    .mobile-album-sticker.complete {
      background: #d9f4e8;
      color: var(--success);
      border-color: rgba(30, 138, 86, 0.35);
    }

    .mobile-album-sticker.repeated {
      background: var(--warning-soft);
      color: #8a5a00;
      border-color: rgba(179, 107, 0, 0.35);
    }

    .mobile-album-sticker.shiny {
      border-color: rgba(194, 141, 0, 0.35);
    }

    .mobile-album-sticker.profiled-normal {
      border-color: rgba(36, 76, 143, 0.35);
    }

    .chart-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
      gap: 14px;
      margin-top: 14px;
    }

    .chart-card {
      border: 1px solid var(--line);
      border-radius: 16px;
      background: #fff;
      padding: 16px;
    }

    .chart-card h3 {
      margin: 0 0 6px;
      font-size: 18px;
    }

    .chart-card p {
      margin: 0 0 14px;
      color: var(--muted);
      font-size: 13px;
    }

    .bar-list {
      display: grid;
      gap: 12px;
    }

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

    .bar-name {
      font-size: 13px;
      font-weight: 700;
    }

    .bar-track {
      width: 100%;
      height: 12px;
      border-radius: 999px;
      background: #edf2f8;
      overflow: hidden;
      border: 1px solid #e1e7f0;
    }

    .bar-fill {
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg, #244c8f, #4c7bd9);
    }

    .bar-value {
      min-width: 40px;
      text-align: right;
      font-size: 13px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
    }

    .backup-grid {
      display: grid;
      grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
      gap: 14px;
    }

    .backup-panel {
      border: 1px solid var(--line);
      border-radius: 16px;
      background: var(--card);
      padding: 14px;
    }

    .backup-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 12px;
    }

    textarea {
      width: 100%;
      min-height: 170px;
      resize: vertical;
      border: 1px solid var(--line-strong);
      border-radius: 12px;
      padding: 12px;
      font: 13px/1.4 Consolas, "Courier New", monospace;
      color: var(--text);
      background: #fff;
      outline: none;
    }

    textarea:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(36, 76, 143, 0.12);
    }

    .status-line {
      min-height: 18px;
      margin-top: 8px;
      color: var(--muted);
      font-size: 13px;
    }

    body[data-theme="dark"] {
      --bg: #000000;
      --card: #080808;
      --line: #242424;
      --line-strong: #3a3a3a;
      --text: #f4f4f4;
      --muted: #a6a6a6;
      --soft: #111111;
      --accent: #f1f1f1;
      --accent-soft: #151515;
      --success: #45d483;
      --success-soft: #092114;
      --warning: #ffbf3f;
      --warning-soft: #261900;
      --extra: #ffd166;
      --extra-soft: #150f05;
    }

    body[data-theme="dark"] .section {
      box-shadow: none;
    }

    body[data-theme="dark"] .metric,
    body[data-theme="dark"] .input-card {
      background: linear-gradient(180deg, #111111 0%, #070707 100%);
    }

    body[data-theme="dark"] input[type="number"],
    body[data-theme="dark"] input[type="search"],
    body[data-theme="dark"] textarea,
    body[data-theme="dark"] select,
    body[data-theme="dark"] button {
      background: #0b0b0b;
      color: var(--text);
      border-color: var(--line-strong);
    }

    body[data-theme="dark"] button.primary {
      background: #f1f1f1;
      color: #000000;
      border-color: #f1f1f1;
    }

    body[data-theme="dark"] input[type="number"]:focus,
    body[data-theme="dark"] input[type="search"]:focus,
    body[data-theme="dark"] textarea:focus,
    body[data-theme="dark"] select:focus {
      border-color: #f1f1f1;
      box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
    }

    body[data-theme="dark"] .badge {
      background: #101010;
      border-color: var(--line);
      color: var(--muted);
    }

    body[data-theme="dark"] .table-shell,
    body[data-theme="dark"] .chart-card,
    body[data-theme="dark"] .backup-panel {
      background: #050505;
      border-color: var(--line);
    }

    body[data-theme="dark"] th,
    body[data-theme="dark"] td {
      background: #070707;
      border-color: var(--line);
    }

    body[data-theme="dark"] thead th {
      background: #111111;
      color: var(--text);
    }

    body[data-theme="dark"] .album-table thead tr:first-child th {
      background: #000000;
      color: #ffffff;
      border-color: #2a2a2a;
    }

    body[data-theme="dark"] .group-cell,
    body[data-theme="dark"] .album-table .sticky-col-1,
    body[data-theme="dark"] .album-table .sticky-col-2,
    body[data-theme="dark"] .album-table .sticky-col-3,
    body[data-theme="dark"] .count-table .sticky-col-1,
    body[data-theme="dark"] .count-table .sticky-col-2 {
      background: #0d0d0d;
      color: #f0f0f0;
    }

    body[data-theme="dark"] .selection-cell {
      color: #f2f2f2;
    }

    body[data-theme="dark"] .code-cell,
    body[data-theme="dark"] .album-empty-cell {
      background: #111111 !important;
      color: #7d7d7d;
    }

    body[data-theme="dark"] .album-table tbody tr:nth-child(even) td,
    body[data-theme="dark"] .count-table tbody tr:nth-child(even) td {
      background: #0b0b0b;
    }

    body[data-theme="dark"] .album-table tbody tr:nth-child(even) td.sticky-col-1,
    body[data-theme="dark"] .album-table tbody tr:nth-child(even) td.sticky-col-2,
    body[data-theme="dark"] .album-table tbody tr:nth-child(even) td.sticky-col-3,
    body[data-theme="dark"] .count-table tbody tr:nth-child(even) td.sticky-col-1,
    body[data-theme="dark"] .count-table tbody tr:nth-child(even) td.sticky-col-2 {
      background: #0d0d0d;
    }

    body[data-theme="dark"] .album-table tbody tr.album-extra-row td,
    body[data-theme="dark"] .album-table tbody tr.album-extra-row:nth-child(even) td {
      background: var(--extra-soft);
    }

    body[data-theme="dark"] .album-table tbody tr.album-extra-row .group-cell,
    body[data-theme="dark"] .album-table tbody tr.album-extra-row .selection-cell,
    body[data-theme="dark"] .album-table tbody tr.album-extra-row:nth-child(even) .group-cell,
    body[data-theme="dark"] .album-table tbody tr.album-extra-row:nth-child(even) .selection-cell {
      background: #241700;
      color: var(--extra);
    }

    body[data-theme="dark"] .album-table tbody tr:hover td,
    body[data-theme="dark"] .album-table tbody tr:nth-child(even):hover td {
      background: #151515;
    }

    body[data-theme="dark"] .album-table tbody tr.album-extra-row:hover td,
    body[data-theme="dark"] .album-table tbody tr.album-extra-row:nth-child(even):hover td {
      background: #241807;
    }

    body[data-theme="dark"] .album-sticker.shiny {
      background: #1d1702;
      color: #f6d96c;
      box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.35);
    }

    body[data-theme="dark"] .album-sticker.profiled-normal {
      background: #101010;
      color: #efefef;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    }

    body[data-theme="dark"] .album-sticker.profiled-normal .album-type-badge {
      background: #e6e6e6;
      color: #000000;
    }

    body[data-theme="dark"] .mobile-album-sticker.profiled-normal {
      border-color: rgba(255, 255, 255, 0.35);
    }

    body[data-theme="dark"] .album-sticker:hover {
      background: #1a1a1a !important;
      box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
    }

    body[data-theme="dark"] .album-sticker.owned,
    body[data-theme="dark"] .mobile-album-sticker.owned {
      background: var(--success-soft) !important;
      color: var(--success);
    }

    body[data-theme="dark"] .album-sticker.complete,
    body[data-theme="dark"] .mobile-album-sticker.complete {
      background: #082916 !important;
      color: var(--success);
    }

    body[data-theme="dark"] .album-sticker.repeated,
    body[data-theme="dark"] .mobile-album-sticker.repeated {
      background: var(--warning-soft) !important;
      color: var(--warning);
    }

    body[data-theme="dark"] .mobile-album-picker,
    body[data-theme="dark"] .mobile-album-controls {
      background: #070707;
      border-color: var(--line);
    }

    body[data-theme="dark"] .bar-track {
      background: #151515;
      border-color: #303030;
    }

    body[data-theme="dark"] .bar-fill {
      background: linear-gradient(90deg, #f4f4f4, #8a8a8a);
    }

    body[data-theme="dark"] .total-cell {
      background: #141414;
    }

    @media (max-width: 900px) {
      .page {
        padding: 14px;
      }

      .section {
        padding: 14px;
        border-radius: 16px;
      }

      .sticky-col-2 { left: 84px; }
      .sticky-col-3 { left: 244px; }

      .selection-cell {
        min-width: 160px;
      }

      .mobile-album-picker {
        display: block;
      }

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

    @media (max-width: 420px) {
      .mobile-album-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
    }