:root {
      color-scheme: light;
      --bg: #f4f6f9;
      --panel: #ffffff;
      --panel2: #f0f3f7;
      --ink: #0f172a;
      --muted: #64748b;
      --line: #e2e8f0;
      --accent: #059669;
      --accent2: #0d9488;
      --danger: #dc2626;
      --warn: #d97706;
      --ok: #059669;
      --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
      --radius: 8px;
      --support: #0284c7;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: var(--bg);
      color: var(--ink);
      letter-spacing: 0;
      min-height: 100vh;
    }
    button, input, select, textarea { font: inherit; }
    button {
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 7px;
      padding: 0 13px;
      color: var(--ink);
      background: #ffffff;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
      font-weight: 700;
      cursor: pointer;
    }
    button:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; }
    button:disabled { opacity: 0.45; cursor: not-allowed; }
    button.primary { color: #ffffff; background: linear-gradient(180deg, #34d399, #059669); border-color: #10b981; }
    button.danger { color: #ffffff; background: linear-gradient(180deg, #ef4444, #dc2626); border-color: #f87171; }
    button.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
    button.ghost:hover:not(:disabled) { background: #f1f5f9; color: var(--ink); border-color: var(--line); }
    input, select, textarea {
      width: 100%;
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 7px;
      padding: 0 12px;
      background: #ffffff;
      color: var(--ink);
      outline: none;
    }
    textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
    input:focus, select:focus, textarea:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
    label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
    .hidden { display: none !important; }
    .login {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 18px;
      background: #ffffff;
    }
    .login-box, .panel, .hero {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }
    .login-box { width: min(440px, 100%); padding: 20px; display: grid; gap: 14px; }
    .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
    .mark { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f8fafc; flex: 0 0 auto; }
    .mark img { width: 100%; height: 100%; object-fit: cover; }
    h1, h2, h3 { margin: 0; color: var(--ink); }
    h1 { font-size: 18px; font-weight: 800; }
    h2 { font-size: 16px; font-weight: 800; }
    h3 { font-size: 13px; font-weight: 750; }
    .muted { color: var(--muted); font-size: 12px; }
    .app { display: block; background: var(--bg); min-height: 100vh; }
    .topbar {
      position: sticky;
      top: 0;
      z-index: 10;
      min-height: 68px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 14px;
      background: rgba(255, 255, 255, 0.96);
      border-bottom: 1px solid var(--line);
      backdrop-filter: blur(18px);
      box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
    }
    .topbar-nav {
      display: flex;
      align-items: center;
      gap: 10px;
      flex: 1 1 auto;
      justify-content: flex-end;
      flex-wrap: wrap;
      min-width: 0;
    }
    .topbar-online { margin: 0; flex-shrink: 0; }
    .screen-picker,
    .subnav-picker {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 1 1 220px;
      min-width: 0;
      max-width: min(440px, 100%);
    }
    .subnav-picker { flex: 1 1 280px; max-width: min(520px, 100%); margin-bottom: 4px; }
    .screen-picker-label,
    .subnav-picker-label {
      font-size: 12px;
      font-weight: 650;
      color: var(--muted);
      white-space: nowrap;
    }
    .screen-picker select,
    .subnav-picker select {
      flex: 1;
      min-width: 0;
      cursor: pointer;
      font-weight: 650;
    }
    .usage-periods { display: flex; gap: 8px; flex-wrap: wrap; }
    .usage-periods button.active { color: #ffffff; border-color: #10b981; background: linear-gradient(180deg, #34d399, #059669); }
    .players-online-badge { margin: 0; }
    .player-list-row { cursor: pointer; }
    .player-list-row.is-online { border-color: #bbf7d0; background: #f0fdf4; }
    .player-list-row:hover { border-color: #94a3b8; background: #f8fafc; }
    .player-list-row.is-online:hover { border-color: #6ee7b7; background: #ecfdf5; }
    .avatar { position: relative; }
    .avatar.is-online { box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px #10b981; }
    .avatar-online-dot {
      position: absolute;
      right: -1px;
      bottom: -1px;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #10b981;
      border: 2px solid #ffffff;
      box-shadow: 0 0 6px rgba(16, 185, 129, 0.55);
    }
    .list-section-label {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: #047857;
      padding: 6px 2px 2px;
    }
    .list-section-label.muted-section { color: var(--muted); margin-top: 10px; }
    .list-section-label.muted-section .dot { background: #94a3b8; box-shadow: none; }
    button.is-loading { opacity: 0.72; cursor: wait; }
    .usage-row { display: grid; gap: 4px; font-size: 12px; }
    .usage-row strong { font-size: 14px; }
    main { display: grid; gap: 14px; padding: 14px; max-width: 1380px; margin: 0 auto; width: 100%; }
    .hero { position: relative; overflow: hidden; padding: 20px; display: grid; gap: 10px; border-color: #bae6fd; }
    .hero:before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(16, 185, 129, 0.08), transparent 50%, rgba(14, 165, 233, 0.06)); pointer-events: none; }
    .hero > * { position: relative; }
    .hero-title { font-size: 25px; line-height: 1.05; font-weight: 900; }
    .status { display: inline-flex; align-items: center; gap: 8px; width: fit-content; border: 1px solid #bbf7d0; border-radius: 999px; padding: 7px 10px; color: #047857; background: #ecfdf5; font-size: 12px; font-weight: 750; }
    .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(5, 150, 105, 0.45); }
    .dot.bad { background: var(--danger); box-shadow: 0 0 8px rgba(220, 38, 38, 0.4); }
    .grid { display: grid; gap: 12px; }
    .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .stat { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
    .stat .value { margin-top: 4px; font-size: 22px; font-weight: 900; color: var(--ink); overflow-wrap: anywhere; }
    .panel { overflow: hidden; }
    .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); background: #f8fafc; }
    .panel-body { padding: 14px; display: grid; gap: 12px; }
    .tools { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
    .form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
    .wide { grid-column: 1 / -1; }
    .actions { display: flex; gap: 9px; flex-wrap: wrap; }
    .quick-actions { display: grid; grid-template-columns: repeat(auto-fit,minmax(175px,1fr)); gap: 12px; }
    .quick-actions button { min-height: 76px; text-align: left; display: grid; align-content: center; gap: 4px; font-size: 15px; }
    .quick-actions small { color: var(--muted); font-size: 11px; font-weight: 650; }
    .help-strip { padding: 10px 12px; border: 1px solid #bae6fd; border-radius: 8px; background: #f0f9ff; color: #0369a1; font-size: 13px; font-weight: 650; }
    .support-card { border-color: #7dd3fc; }
    .list { display: grid; gap: 9px; }
    .row {
      display: grid;
      gap: 8px;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #ffffff;
    }
    .row.clickable { cursor: pointer; }
    .row.clickable:hover { border-color: #94a3b8; background: #f8fafc; }
    .row.clickable.is-selected { border-color: #10b981; box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2); }
    .row-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
    .person { display: flex; align-items: center; gap: 10px; min-width: 0; }
    .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #ffffff; background: linear-gradient(145deg, #059669, #34d399); font-weight: 900; font-size: 12px; flex: 0 0 auto; }
    .pill { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); background: #f1f5f9; color: #334155; font-size: 12px; font-weight: 700; }
    .pill.ok { color: #047857; background: #ecfdf5; border-color: #bbf7d0; }
    .pill.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
    .pill.bad { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
    .drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(4px); }
    .drawer {
      position: fixed;
      z-index: 31;
      left: 10px;
      right: 10px;
      top: 10px;
      bottom: 10px;
      overflow: auto;
      background: #ffffff;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
    }
    .drawer .panel-head { position: sticky; top: 0; z-index: 1; }
    .drawer .panel-body { padding-bottom: 28px; }
    .table { display: grid; gap: 8px; }
    .kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
    .kv strong { color: var(--muted); }
    .toast {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: 16px;
      z-index: 50;
      display: none;
      padding: 13px 14px;
      border: 1px solid #bbf7d0;
      border-radius: 8px;
      background: #ffffff;
      color: var(--ink);
      box-shadow: var(--shadow);
      font-size: 13px;
    }
    .footer-brand {
      margin-top: 32px;
      padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
      display: grid;
      place-items: center;
      gap: 5px;
      background: #ffffff;
      border-top: 1px solid var(--line);
      color: var(--muted);
      font-size: 12px;
    }
    .store-ref-table { width: 100%; border-collapse: collapse; font-size: 12px; }
    .store-ref-table th, .store-ref-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
    .store-ref-table th { color: var(--muted); font-weight: 800; background: #f8fafc; position: sticky; top: 0; }
    .store-ref-wrap { max-height: min(62vh, 640px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; }
    .footer-brand img { width: 100%; max-width: 288px; height: auto; border-radius: 6px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1); }
    .empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; background: #f8fafc; }
    .danger-zone { border-color: #fecaca; }
    .feature-note {
      padding: 12px 14px;
      border: 1px solid #bae6fd;
      border-radius: 8px;
      background: #f0f9ff;
      color: #0c4a6e;
      font-size: 13px;
      line-height: 1.45;
    }
    code { font-size: 0.92em; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
    .combo-field { position: relative; display: grid; gap: 6px; }
    .combo-menu {
      position: absolute;
      left: 0;
      right: 0;
      top: calc(100% + 4px);
      z-index: 45;
      max-height: min(280px, 50vh);
      overflow: auto;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #ffffff;
      box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    }
    .combo-option {
      display: grid;
      gap: 2px;
      width: 100%;
      min-height: 0;
      padding: 9px 12px;
      border: none;
      border-radius: 0;
      border-bottom: 1px solid var(--line);
      background: transparent;
      box-shadow: none;
      text-align: left;
      font-weight: 600;
      color: var(--ink);
      cursor: pointer;
    }
    .combo-option:last-child { border-bottom: none; }
    .combo-option:hover,
    .combo-option.is-active { background: #f0fdf4; }
    .combo-option strong { font-size: 13px; }
    .combo-option .muted { font-size: 11px; font-weight: 500; }
    .combo-empty { padding: 12px; color: var(--muted); font-size: 12px; text-align: center; }
    .combo-option-custom { border-top: 1px solid var(--line); background: #f8fafc; }
    .combo-option-custom:not([disabled]):hover { background: #fff7ed; }
    .combo-option-custom strong { color: #b45309; }
    .shop-panel.hidden { display: none !important; }
    @media (min-width: 780px) {
      .stats { grid-template-columns: repeat(4,minmax(0,1fr)); }
      .row { grid-template-columns: 1fr auto; align-items: center; }
      .drawer { left: auto; width: min(680px, calc(100vw - 32px)); }
    }
    @media (min-width: 1100px) {
      .drawer { width: min(820px, calc(100vw - 48px)); }
      #view-dashboard { grid-template-columns: 1.1fr .9fr; align-items: start; }
      #view-dashboard .hero, #view-dashboard #stats { grid-column: 1 / -1; }
    }
    @media (max-width: 480px) {
      .form { grid-template-columns: 1fr; }
      .topbar { align-items: flex-start; flex-direction: column; }
      .topbar-nav { width: 100%; justify-content: stretch; }
      .screen-picker { flex: 1 1 100%; max-width: none; }
      .screen-picker-label { display: none; }
      .subnav-picker-label { display: none; }
      .topbar .brand h1 { font-size: 16px; }
      .hero-title { font-size: 22px; }
      button { min-height: 40px; }
    }
