:root {
  --bg: #0F1117;
  --surface: #1A1D2E;
  --surface2: #252A3A;
  --border: #2E344A;
  --primary: #6366F1;
  --primary2: #818CF8;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --item-normal: #E2E8F0;
  --item-excellent: #22C55E;
  --item-ancient: #60A5FA;
  --item-socket: #A855F7;
  --item-option: #FBBF24;
  --item-harmony: #F472B6;
  --dim: #94A3B8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body, #root {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: #E2E8F0;
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.shell { height: 100%; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { padding: 12px 12px 24px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 6px 8px; }
.back { background: none; border: 0; color: var(--primary2); font-size: 15px; padding: 4px 6px; }

.navbar { display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.nav-item { flex: 1; background: none; border: 0; color: var(--dim); padding: 6px 0 5px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.nav-icon { font-size: 18px; line-height: 22px; }
.nav-label { font-size: 10px; }
.nav-on { color: var(--primary2); font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px; color: #fff; border: 0; border-radius: 8px; font-size: 14px; font-weight: 700; }
.btn:disabled { opacity: .5; }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.icon-btn { width: 34px; height: 34px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: #202638; border: 0; border-radius: 50%; color: #CBD5E1; font-size: 15px; }
.icon-btn:disabled { opacity: .4; }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-label { font-size: 11.5px; color: var(--dim); }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  background: var(--bg);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }

.check { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; min-height: 30px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.tab { flex: none; padding: 7px 12px; background: var(--surface2); color: var(--dim); border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.tab-on { background: var(--primary); border-color: var(--primary); color: #fff; }

.badge { display: inline-block; flex: none; padding: 1px 5px; border: 1px solid; border-radius: 4px; font-size: 9.5px; font-weight: 700; }

.server-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #131722; border: 1px solid #262C3E; border-radius: 8px; }
.server-on { background: #1E2438; border-color: var(--primary); }

.center-box { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 12px; text-align: center; }

.spinner { display: inline-block; flex: none; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); background: rgba(0, 0, 0, .65); }
.modal { display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: 100%; background: #141722; border: 1px solid #334155; border-radius: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 14px; font-weight: 700; color: #fff; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }

.toasts { position: fixed; z-index: 90; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 70px); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { max-width: 100%; padding: 8px 12px; background: rgba(30, 36, 56, .96); border: 1px solid var(--border); border-radius: 8px; color: #fff; font-size: 13px; }

.list-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #131722; border: 1px solid #262C3E; border-radius: 8px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.kv > :first-child { color: var(--dim); }
.table-wrap { overflow-x: auto; }
.table-wrap table { border-collapse: collapse; font-size: 12px; }
.table-wrap th, .table-wrap td { border: 1px solid var(--border); padding: 4px 6px; white-space: nowrap; text-align: left; }
