*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

:root {
  --bg:           #1b2333;
  --surface:      #232f42;
  --surface2:     #1e2a3a;
  --border:       #2e4060;
  --accent:       #c8a84b;
  --accent-hover: #b8963a;
  --red:          #cc2a2a;
  --red-hover:    #a82020;
  --text:         #c8d4e0;
  --muted:        #6a7f96;
  --success:      #3a9e5f;
  --radius:       4px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Top nav ---- */
.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 12px;
}
.nav-links { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-link { white-space: nowrap; }
.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--accent); color: #111; font-weight: 600; }
.nav-sep { color: var(--border); align-self: center; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-user { font-size: 13px; color: var(--muted); }
.burger-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.nav-links-user { display: none; }
.role-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.role-admin { background: var(--accent); color: #111; }
.role-user { background: var(--border); color: var(--text); }

/* ---- Layout ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Buttons ---- */
.btn-primary, .btn-secondary, .btn-danger, .btn-sm {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #3a5070; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- Forms ---- */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
select option { background: var(--surface2); }

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-form input,
.inline-form select { width: auto; }

.search-input {
  min-width: 200px;
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 10;
}
.data-table th:hover { color: var(--text); }
.data-table th.sorted-asc::after { content: ' ▲'; font-size: 10px; }
.data-table th.sorted-desc::after { content: ' ▼'; font-size: 10px; }
.data-table tr:hover { background: rgba(200,168,75,0.04); }
.data-table td a { color: var(--accent); }

/* ---- Column show/hide ---- */
.col-hidden { display: none !important; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.pagination button {
  padding: 4px 10px;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
}
.pagination button:hover { background: #3a5070; }
.pagination button.active { background: var(--accent); color: #111; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ---- Dropdowns ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  z-index: 50;
  min-width: 200px;
}

.filter-panel .filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.filter-panel .filter-row:last-child { margin-bottom: 0; }
.filter-panel label {
  font-size: 12px;
  color: var(--muted);
  min-width: 70px;
}
.filter-panel select {
  flex: 1;
  font-size: 12px;
  padding: 4px 6px;
}

.col-panel { max-height: 400px; overflow-y: auto; }
.col-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  padding: 3px 0;
  cursor: pointer;
  flex-direction: row;
}
.col-panel input[type="checkbox"] { accent-color: var(--accent); }

/* ---- Group badges ---- */
.group-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
}

/* ---- Player detail ---- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.detail-card.span-2 { grid-column: span 2; }
.identity-cols { display: flex; gap: 24px; flex-wrap: wrap; }
.identity-cols > div { flex: 1 1 220px; min-width: 0; }
.field-row { gap: 12px; }
.field-value.editable:empty::before { content: 'Add…'; color: var(--muted); font-style: italic; }
.field-value.editable::after { content: ' ✎'; color: var(--muted); font-size: 11px; opacity: 0; transition: opacity 0.15s; }
.field-value.editable:hover::after { opacity: 1; }
.field-value input { font-size: 13px; padding: 4px 6px; }
.detail-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.field-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}
.field-label { color: var(--muted); }
.field-value { color: var(--text); text-align: right; }
.field-value.editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
}
.field-value.editable:hover { color: var(--accent); }

.player-pic {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
}

/* ---- War mode ---- */
.war-section-full {
  max-width: 100%;
}

.status-open { color: var(--success); font-weight: 600; }
.status-protected { color: var(--red); font-weight: 600; }
.status-in-window { color: #c8a020; font-weight: 600; }

.war-name-inwindow { color: #e8a020; font-weight: 600; }
.war-name-open { color: var(--red); font-weight: 600; }

.war-type-select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 6px;
  font-size: 13px;
}
.war-actions { white-space: nowrap; }
.btn-icon-danger, .btn-icon-accent, .btn-icon-muted, .btn-icon-success {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
}
.btn-icon-danger { color: var(--red); }
.btn-icon-accent { color: var(--accent); }
.btn-icon-muted { color: var(--muted); }
.btn-icon-danger:hover { background: rgba(220, 53, 69, 0.15); }
.btn-icon-accent:hover { background: rgba(200, 168, 75, 0.15); }
.btn-icon-muted:hover { background: rgba(106, 127, 150, 0.2); }
.btn-icon-success { color: var(--success); }
.btn-icon-success:hover { background: rgba(58, 158, 95, 0.15); }

.event-log {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 12px;
  font-family: 'Consolas', monospace;
}
.event-log .event-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(46,64,96,0.3);
}
.event-log .event-ts { color: var(--muted); margin-right: 8px; }
.event-log .event-src { color: var(--accent); margin-right: 8px; }

/* ---- API key result ---- */
.api-key-result {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  font-family: 'Consolas', monospace;
  font-size: 13px;
  word-break: break-all;
}

/* ---- Login ---- */
.login-wrap {
  max-width: 360px;
  margin: 80px auto;
}
.login-wrap h1 {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 20px;
  text-align: center;
}
.login-wrap form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-wrap input {
  width: 100%;
}
.login-wrap h2 {
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 18px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-wrap .form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.login-wrap .btn-primary { width: 100%; padding: 10px; margin-top: 4px; }
.login-error, .error-msg {
  color: var(--red);
  background: rgba(204,42,42,0.12);
  border: 1px solid rgba(204,42,42,0.4);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
}

/* ---- Misc ---- */
.muted { color: var(--muted); }
.back-link { color: var(--muted); }
.back-link:hover { color: var(--accent); }
.text-danger { color: var(--red); }
.text-success { color: var(--success); }
.color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  vertical-align: middle;
  border: 1px solid var(--border);
}
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  animation: fadeIn 0.2s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  pointer-events: auto;
  cursor: pointer;
  max-width: min(420px, calc(100vw - 32px));
}
.toast-ok { background: var(--success); color: #fff; }
.toast-err { background: var(--red); color: #fff; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Overlay / Modal ---- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.overlay-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 340px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  width: 90%;
}
.overlay-panel h3 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.overlay-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.overlay-head h3 { flex: 1; margin: 0; padding: 0; border: none; word-break: break-word; }
.overlay-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin: -4px -4px 0 0;
}
.overlay-x:hover { color: var(--text); }
.overlay-body > p { margin-bottom: 8px; }
.overlay-panel .form-group {
  margin-bottom: 10px;
}
.overlay-panel .form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.overlay-panel .form-group input,
.overlay-panel .form-group select {
  width: 100%;
}
.overlay-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

/* ---- Autocomplete ---- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 60;
}
.autocomplete-list .ac-item {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.autocomplete-list .ac-item:hover,
.autocomplete-list .ac-item.ac-active {
  background: var(--accent);
  color: #111;
}

/* ---- Business tracker ---- */
.business-cities {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .business-cities { grid-template-columns: 1fr; }
}
.biz-available { color: var(--success); font-weight: 600; }
.biz-owned { color: var(--muted); }

/* ---- Online players ---- */
.online-names { display: flex; flex-wrap: wrap; gap: 4px; }
.online-name {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  background: rgba(46,64,96,0.3);
}
.online-name-hl {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---- Column drag ---- */
.data-table th.drag-over {
  border-left: 2px solid var(--accent);
}
.data-table th[draggable="true"] {
  cursor: grab;
}
.data-table th[draggable="true"]:active {
  cursor: grabbing;
}

/* ---- Group member overlay ---- */
.overlay-panel.wide { max-width: 800px; }
.member-filter {
  width: 100%;
  margin-bottom: 10px;
}
.selectable-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.selectable-list .sel-item {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid rgba(46,64,96,0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.selectable-list .sel-item:hover { background: rgba(200,168,75,0.08); }
.selectable-list .sel-item.selected { background: rgba(200,168,75,0.15); }
.selectable-list .sel-item.marked-delete { background: rgba(204,42,42,0.15); text-decoration: line-through; }
.sel-count { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---- Discord config ---- */
.alert-type-section {
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.alert-route-row select {
  min-width: 140px;
}

/* ---- Mobile: burger menu ---- */
@media (max-width: 768px) {
  .burger-btn { display: block; }
  .top-nav {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 2px;
    padding-top: 8px;
  }
  .top-nav.nav-open .nav-links { display: flex; }
  .nav-links .nav-link {
    padding: 10px 12px;
    font-size: 14px;
  }
  .nav-links .nav-sep { display: none; }
  .nav-right { display: none; }
  .nav-links-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .container { padding: 12px 16px; }
}

/* ---- Mobile: war rows ---- */
@media (max-width: 768px) {
  .war-row-mobile { cursor: pointer; }
  .war-row-mobile:active { background: rgba(200,168,75,0.1); }
  .war-name-cell { color: var(--accent); font-weight: 600; }
}

/* ---- Focus & accessibility ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input[type="search"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
body.no-scroll { overflow: hidden; }
.card h3 { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin: 22px 0 10px;
}
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: 0.45; cursor: default; }

/* ---- DataTable ---- */
.dt { position: relative; }
.dt-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.dt-search { flex: 1 1 220px; min-width: 0; max-width: 360px; }
.dt-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}
.dt-tool.active { background: var(--accent); color: #111; }
.dt-badge {
  background: var(--accent);
  color: #111;
  border-radius: 9px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 5px;
}
.dt-tool.active .dt-badge { background: #111; color: var(--accent); }
.dt-badge[hidden] { display: none; }
.dt-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

.dt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}
.dt-chips[hidden] { display: none; }
.dt-chip {
  display: inline-flex;
  align-items: stretch;
  background: rgba(200,168,75,0.12);
  border: 1px solid rgba(200,168,75,0.45);
  border-radius: 14px;
  font-size: 12px;
  overflow: hidden;
  max-width: 100%;
}
.dt-chip button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.dt-chip-body {
  padding: 4px 4px 4px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dt-chip-body b { color: var(--accent); font-weight: 600; }
.dt-chip-x { padding: 0 8px; display: inline-flex; align-items: center; color: var(--muted) !important; }
.dt-chip-x:hover { color: var(--text) !important; background: rgba(200,168,75,0.2) !important; }
.dt-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}
.dt-link:hover { text-decoration: underline; }

.dt-panel {
  position: absolute;
  z-index: 60;
  top: 42px;
  right: 0;
  width: 360px;
  max-width: 100%;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  padding: 12px;
}
.dt-panel[hidden] { display: none; }
.dt-panel-foot { display: none; }
.dt-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.dt-panel-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}
.dt-panel-x { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; display: inline-flex; }
.dt-panel-x:hover { color: var(--text); }
.dt-hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }

.dt-facet { border-top: 1px solid var(--border); }
.dt-facet-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 9px 2px;
  cursor: pointer;
  text-align: left;
}
.dt-facet-head > span:first-child { flex: 1; }
.dt-facet-n { color: var(--accent); font-size: 12px; font-weight: 600; }
.dt-facet-any { color: var(--muted); font-size: 12px; }
.dt-caret { color: var(--muted); display: inline-flex; transition: transform 0.15s; }
.dt-facet.open .dt-caret { transform: rotate(180deg); }
.dt-facet-body { padding: 0 0 10px; }
.dt-facet-search { width: 100%; margin-bottom: 6px; }
.dt-facet-actions { display: flex; gap: 6px; margin-bottom: 4px; }
.dt-facet-actions .dt-link:first-child { padding-left: 0; }
.dt-facet-list { max-height: 260px; overflow-y: auto; }
.dt-facet-loading { font-size: 12px; padding: 6px 0; }
.dt-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius);
}
.dt-check:hover { background: rgba(200,168,75,0.06); }
.dt-check input { flex: none; width: 15px; height: 15px; }
.dt-check-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-check-n { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dt-zero { opacity: 0.6; }

.dt-tiers { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.dt-tier {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 4px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px 8px;
}
.dt-tier-n { grid-column: 1 / -1; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dt-tier-col { min-width: 0; width: 100%; padding: 5px 8px; }
.dt-tier-dir { white-space: nowrap; }
.dt-tier-btns { display: inline-flex; gap: 2px; }
.dt-tier-add { width: 100%; }
.dt-icon {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dt-icon:hover:not(:disabled) { color: var(--text); border-color: var(--border); }
.dt-icon:disabled { opacity: 0.3; cursor: default; }
.dt-icon-x:hover:not(:disabled) { color: var(--red); }
.dt-col-list { display: flex; flex-direction: column; }
.dt-col-row { display: flex; align-items: center; gap: 4px; }
.dt-col-row .dt-check { flex: 1; }

.dt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dt-scroll-y { max-height: calc(100vh - 200px); overflow-y: auto; }
.dt-table th { white-space: nowrap; }
.dt-table th:not(.dt-sortable) { cursor: default; }
.dt-th { display: inline-flex; align-items: center; gap: 4px; }
.dt-table th.dt-sorted { color: var(--accent); }
.dt-arrow { font-size: 9px; display: inline-flex; align-items: flex-start; }
.dt-arrow sup { font-size: 9px; margin-left: 1px; }
.dt-th-filter { display: inline-flex; color: var(--accent); }
.dt-th-filter svg { width: 11px; height: 11px; }
.dt-msg td {
  text-align: center !important;
  color: var(--muted);
  padding: 28px 10px !important;
  white-space: normal !important;
}
.dt-msg .btn-sm { margin-left: 8px; }
.dt-loading .dt-table tbody { opacity: 0.55; transition: opacity 0.15s; }
.dt-actions { white-space: nowrap; }
.dt-actions .btn-sm + .btn-sm { margin-left: 4px; }
.dt-pages:empty { display: none; }
.dt-page-info { padding: 0 6px; }
.dt-desktop-only { display: inline; }
.card > .dt:last-child .dt-pages { margin-bottom: 0; }

/* Tappable rows */
.row-link { cursor: pointer; }
.clamp { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

/* ---- Phone layout ---- */
@media (max-width: 768px) {
  .page-header h1 { font-size: 18px; }
  .header-controls { margin-left: 0; width: 100%; }
  .dt-panel { width: 340px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 12px; }
  .card { padding: 12px; }
  .page-header { gap: 10px; }
  .page-header > .btn-primary, .page-header > .btn-danger { margin-left: auto; }

  /* Comfortable tap targets; 16px inputs stop iOS zooming on focus */
  .btn-primary, .btn-secondary, .btn-danger { padding: 9px 14px; min-height: 40px; }
  .btn-sm { min-height: 34px; padding: 6px 12px; }
  input[type="text"], input[type="password"], input[type="number"], input[type="search"],
  input[type="time"], select, textarea { font-size: 16px; min-height: 40px; }
  .inline-form { align-items: stretch; }
  .inline-form > input, .inline-form > select, .inline-form > .autocomplete-wrap { flex: 1 1 100%; width: 100%; }
  .inline-form > input[type="color"] { flex: 0 0 56px; width: 56px; min-height: 40px; padding: 2px; }
  .inline-form > input[type="color"] + button { flex: 1 1 0; }
  .detail-card.span-2 { grid-column: auto; }
  .field-value.editable::after { opacity: 1; }
  .inline-form > .autocomplete-wrap input { width: 100%; }
  .inline-form > button { flex: 1 1 auto; }
  .inline-form > label { flex: 1 1 100%; }
  .search-input { min-width: 0; width: 100%; }

  .toast-wrap { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; text-align: center; }

  .overlay-backdrop { align-items: flex-end; }
  .overlay-panel, .overlay-panel.wide {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 12px 12px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .overlay-actions { flex-wrap: wrap; }
  .overlay-actions > button { flex: 1 1 auto; }

  /* Toolbar */
  .dt-search { flex: 1 1 100%; max-width: none; }
  .dt-tools { flex: 1; }
  .dt-tool { flex: 1; justify-content: center; min-height: 38px; }
  .dt-count { width: 100%; margin-left: 0; order: 5; }
  .dt-desktop-only { display: none; }

  /* Panels become bottom sheets */
  .dt-panel {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 80vh;
    border-radius: 12px 12px 0 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    z-index: 210;
  }
  .dt-panel-foot {
    display: block;
    position: sticky;
    bottom: calc(-14px - env(safe-area-inset-bottom));
    margin: 10px -16px calc(-14px - env(safe-area-inset-bottom));
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .dt-panel-foot .btn-primary { width: 100%; }
  body.dt-sheet-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 205;
  }
  body.dt-sheet-open { overflow: hidden; }
  .dt-check { padding: 9px 2px; font-size: 15px; }
  .dt-check input { width: 18px; height: 18px; }
  .dt-facet-head { padding: 12px 2px; font-size: 15px; }
  .dt-facet-list { max-height: none; }
  .dt-icon { width: 36px; height: 36px; }

  /* Rows become cards */
  .dt-scroll { overflow: visible; }
  .dt-scroll-y { max-height: none; }
  .dt-cards, .dt-cards tbody { display: block; }
  .dt-cards thead { display: none; }
  .dt-cards tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .card .dt-cards tr { background: var(--surface2); }
  .dt-cards tr:hover { background: var(--surface); }
  .dt-cards td {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0;
    border: none;
    white-space: normal;
    word-break: break-word;
    min-width: 0;
    font-size: 14px;
  }
  .dt-cards td::before {
    content: attr(data-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
  }
  .dt-cards td.dt-empty { display: none; }
  .dt-cards td > .group-badge, .dt-cards td > select { align-self: flex-start; }
  .dt-cards td.dt-card-title {
    grid-column: 1 / -1;
    font-size: 15px;
    font-weight: 600;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
  }
  .dt-cards td.dt-card-title::before, .dt-cards td.dt-actions::before { display: none; }
  .dt-cards td.dt-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
  }
  .dt-cards td.dt-actions .btn-sm { margin: 0; flex: 1 1 auto; }
  .dt-cards td.dt-wide { grid-column: 1 / -1; }
  .dt-cards .dt-msg { display: block; }
  .dt-cards .dt-msg td::before { display: none; }
  .clamp { max-width: none; }

  .pagination { flex-wrap: wrap; justify-content: center; }
  .pagination button { min-height: 36px; padding: 6px 12px; }

  .detail-grid { grid-template-columns: 1fr; }
  .business-cities { gap: 10px; }
  .war-type-select { min-height: 36px; }
  .login-wrap { margin: 40px auto; padding: 0 16px; }
}
.check-row { gap: 10px; align-items: center; cursor: pointer; flex-wrap: nowrap !important; }
.check-row input { flex: none !important; width: 18px !important; height: 18px; min-height: 0 !important; }
.row-dead td:first-child a { color: var(--muted); }
.h2-with-control { flex-wrap: wrap; }
.h2-with-control > select, .h2-with-control > button { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; }
.h2-with-control > select { font-size: 13px; padding: 4px 8px; }
.subhead {
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted) !important;
}
.btn-icon-label { display: none; }
@media (max-width: 640px) {
  .dt-cards td.dt-actions .btn-icon-success,
  .dt-cards td.dt-actions .btn-icon-muted,
  .dt-cards td.dt-actions .btn-icon-accent,
  .dt-cards td.dt-actions .btn-icon-danger {
    border: 1px solid var(--border);
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
  }
  .btn-icon-label { display: inline; font-size: 13px; }
  .h2-with-control > select, .h2-with-control > button { margin-left: 0; }
}

/* =================================================================
   Redesign round 2
   ================================================================= */
:root { --nav-h: 48px; }

/* ---- Nav: admin menu, sync dot, global search ---- */
.top-nav { --nav-h: 48px; }
.nav-menu { position: relative; display: flex; }
.nav-menu-btn { background: none; border: none; cursor: pointer; font: inherit; font-size: 13px; }
.nav-menu-btn .caret { font-size: 10px; opacity: 0.7; }
.nav-menu-list {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) - 4px);
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 120;
  flex-direction: column;
}
.nav-menu.open .nav-menu-list { display: flex; }
.nav-menu-list .nav-link { display: block; }
.nav-menu-list .nav-link.current { color: var(--accent); }
.sync-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  flex: none;
  margin-left: -14px;
  cursor: help;
}
.sync-dot.sync-ok { background: var(--success); box-shadow: 0 0 0 3px rgba(58,158,95,0.2); }
.sync-dot.sync-warn { background: var(--accent); box-shadow: 0 0 0 3px rgba(200,168,75,0.2); }
.sync-dot.sync-bad { background: var(--red); box-shadow: 0 0 0 3px rgba(204,42,42,0.25); }
.nav-sync-text { font-size: 12px; }
.nav-search-wrap { margin-left: auto; min-width: 0; }
.nav-search-wrap + .nav-right { margin-left: 0; }
.nav-search { width: 220px; padding: 5px 10px !important; font-size: 13px !important; }
.nav-search-wrap .autocomplete-list { min-width: 280px; right: 0; left: auto; }
.ac-item .ac-meta { display: block; font-size: 11px; color: var(--muted); }

/* ---- Sticky page header ---- */
.page-header {
  position: sticky;
  top: var(--nav-h);
  z-index: 50;
  background: var(--bg);
  padding: 8px 0;
  margin-top: -8px;
  box-shadow: 0 0 0 100vmax var(--bg);
  clip-path: inset(0 -100vmax);
}

/* ---- Pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 8px; border-radius: 999px;
  background: var(--border); color: var(--text);
  white-space: nowrap; vertical-align: middle;
}
.pill-ok { background: rgba(58,158,95,0.18); color: #5cc985; }
.pill-bad { background: rgba(204,42,42,0.18); color: #ef6b6b; }
.pill-warn { background: rgba(200,168,75,0.18); color: var(--accent); }
.pill-muted { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* ---- Colour inputs (desktop had no styling) ---- */
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 40px; height: 32px; padding: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  vertical-align: middle;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }

/* ---- Row "…" menu ---- */
.btn-menu {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--muted); cursor: pointer;
}
.btn-menu:hover, .btn-menu:focus-visible { border-color: var(--border); color: var(--text); background: var(--surface2); }
.row-menu {
  position: absolute; z-index: 300;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  display: flex; flex-direction: column;
}
.row-menu-item {
  background: none; border: none; text-align: left;
  color: var(--text); font: inherit; font-size: 13px;
  padding: 8px 12px; border-radius: var(--radius); cursor: pointer;
}
.row-menu-item:hover, .row-menu-item:focus-visible { background: var(--surface2); outline: none; }
.row-menu-item.danger { color: #ef6b6b; }
.row-menu-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto;
  border-radius: 12px 12px 0 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.row-menu-sheet .row-menu-item { padding: 14px 16px; font-size: 16px; }
.row-menu-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 290; }

/* ---- API key with copy button ---- */
.api-key-result { display: flex; align-items: center; gap: 10px; }
.api-key-text { flex: 1; min-width: 0; word-break: break-all; font-family: ui-monospace, Consolas, monospace; }

/* ---- DataTable: saved views, bulk bar, select, quick filters, group rows ---- */
.dt-views { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.dt-views-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-right: 2px; }
.dt-view { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.dt-view.active { border-color: var(--accent); background: rgba(200,168,75,0.12); }
.dt-view-btn { background: none; border: none; color: var(--text); font: inherit; font-size: 12px; padding: 5px 12px; cursor: pointer; }
.dt-view.active .dt-view-btn { color: var(--accent); font-weight: 600; }
.dt-view-x { background: none; border: none; color: var(--muted); padding: 4px 8px 4px 0; cursor: pointer; display: inline-flex; }
.dt-view-x svg { width: 12px; height: 12px; }
.dt-view-x:hover { color: var(--text); }
.dt-quick.dt-quick-on { border: 1px solid var(--accent); }
.dt-caret-sm { font-size: 10px; opacity: 0.7; }
.dt-bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: rgba(200,168,75,0.1);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  position: sticky; top: calc(var(--nav-h) + 52px); z-index: 40;
}
.dt-bulk[hidden] { display: none; }
.dt-bulk-n { font-weight: 600; color: var(--accent); margin-right: 4px; }
.dt-bulk-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-bulk-clear { margin-left: auto; }
.dt-table .dt-selcell { width: 32px; padding-right: 0; }
.dt-selcell input { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
.dt-table tr.dt-selected td { background: rgba(200,168,75,0.07); }
.dt-table tr.dt-group td {
  background: var(--bg);
  color: var(--accent);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding-top: 12px;
}
.dt-table tr.dt-group:hover td { background: var(--bg); }

/* Row tints (dead players, war status) */
.dt-table tr.row-dead td { color: var(--muted); }
.dt-table tr.row-dead td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.dt-table tr.row-stale td { color: var(--muted); }
.dt-cards tr.row-stale { opacity: 0.6; }
.dt-table tr.row-open td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.dt-table tr.row-inwindow td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.dt-table tr.row-open td { background: rgba(58,158,95,0.06); }
.dt-table tr.row-inwindow td { background: rgba(200,168,75,0.06); }

/* ---- Section head with control ---- */
.section-head { display: flex; align-items: center; gap: 12px; margin: 22px 0 10px; flex-wrap: wrap; }
.section-head .section-title { margin: 0; }
.section-head > :last-child:not(:first-child) { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg-btn { background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; padding: 5px 12px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--border); color: var(--text); font-weight: 600; }

/* ---- Switch ---- */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.15s; }
.switch span::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text); transition: transform 0.15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); background: #111; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.field-select { padding: 4px 8px !important; font-size: 13px; max-width: 60%; }

/* ---- Player detail ---- */
.player-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-pic {
  position: relative; width: 64px; height: 64px; flex: none;
  border-radius: 50%; overflow: hidden;
  background: var(--border); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px;
}
.hero-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-main { flex: 1 1 240px; min-width: 0; }
.hero-name { font-size: 20px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-alias { color: var(--muted); font-size: 13px; margin-top: 2px; }
.hero-sub { margin-top: 4px; font-size: 14px; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.hero-actions { display: flex; gap: 8px; }
.pd-nav { display: inline-flex; align-items: center; gap: 4px; }
.pd-nav[hidden] { display: none; }
.pd-nav a, .pd-nav span.pd-dis {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px;
}
.pd-nav a:not([href]) { color: var(--muted); opacity: 0.5; pointer-events: none; }
.pd-pos { font-size: 12px; padding: 0 6px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; display: flex; gap: 14px; padding-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); border: 2px solid var(--surface); margin-top: 3px; flex: none; position: relative; }
.tl-current .tl-dot { background: var(--accent); }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-bar { max-width: 560px; display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.tl-bar span { height: 5px; border-radius: 3px; background: rgba(200,168,75,0.55); max-width: 70%; }
.tl-current .tl-bar span { background: var(--accent); }
.tl-bar em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.activity-grid .dt-scroll-y { max-height: 360px; }
.activity-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 640px) { .activity-grid { grid-template-columns: 1fr; } }

/* ---- Health cards (clients) ---- */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 14px; }
.health-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
}
.health-card.is-revoked { opacity: 0.55; }
.health-top { display: flex; align-items: center; gap: 8px; }
.health-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.health-dot.ok { background: var(--success); }
.health-dot.warn { background: var(--accent); }
.health-dot.bad { background: var(--red); }
.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.sparkline i { flex: 1; background: rgba(200,168,75,0.5); border-radius: 1px; min-height: 1px; }
.sparkline i.zero { background: var(--border); }

/* ---- Status strip / summary line ---- */
.status-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.stat-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.stat-group small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; min-width: 70px; }
.stat-group span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.stat-group b { font-size: 18px; color: var(--text); margin-right: 3px; font-variant-numeric: tabular-nums; }
.stat-group b.stat-ok { color: #5cc985; }
.stat-group b.stat-warn { color: var(--accent); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; min-width: 110px; display: flex; flex-direction: column;
}
.stat b { font-size: 20px; color: var(--text); line-height: 1.2; }
.stat small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat.stat-ok b { color: #5cc985; }
.stat.stat-warn b { color: var(--accent); }
.stat.stat-bad b { color: #ef6b6b; }
.stat-clock { margin-left: auto; }
.countdown { font-size: 11px; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.countdown.soon { color: var(--accent); font-weight: 600; }
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-bar .autocomplete-wrap { flex: 1 1 260px; }
.add-bar .autocomplete-wrap input { width: 100%; }

/* ---- Phone tabs ---- */
.phone-tabs { display: none; }
@media (max-width: 640px) {
  .phone-tabs {
    display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -12px 12px; padding: 0 12px;
    position: sticky; top: var(--nav-h); z-index: 45; background: var(--bg);
    padding-bottom: 6px;
  }
  .phone-tabs::-webkit-scrollbar { display: none; }
  .phone-tab {
    flex: none; background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer;
  }
  .phone-tab.active { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
  .phone-tab .n { opacity: 0.7; margin-left: 4px; font-size: 12px; }
  [data-tab-pane].tab-hidden { display: none !important; }
}

/* ---- Chip input (respect) ---- */
.chip-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 6px; min-height: 36px; flex: 1 1 320px; cursor: text;
}
.chip-input:focus-within { border-color: var(--accent); }
.chip-input .autocomplete-wrap { flex: 1 1 120px; }
.chip-input input { border: none !important; background: none !important; padding: 4px !important; width: 100%; min-height: 0 !important; }
.name-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px;
}
.name-chip button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.name-chip button:hover { color: var(--text); }
.delta-up { color: #5cc985; }
.delta-down { color: #ef6b6b; }
.summary-line { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.summary-line b { color: var(--text); }
.hist-bars { display: flex; align-items: flex-end; gap: 3px; height: 60px; margin: 6px 0 12px; }
.hist-bars i { flex: 1; background: rgba(200,168,75,0.55); border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---- Admin tables tiles + side panel ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; text-align: left; color: var(--text); font: inherit; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.tile:hover { border-color: var(--accent); }
.tile.active { border-color: var(--accent); background: rgba(200,168,75,0.1); }
.tile b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.tile small { color: var(--muted); font-size: 12px; }
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0,0,0,0.4);
  z-index: 260; display: flex; flex-direction: column;
}
.side-panel[hidden] { display: none; }
.side-panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.side-panel-head h3 { flex: 1; font-size: 14px; color: var(--accent); }
.side-panel-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.kv { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); word-break: break-word; }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.kv pre { margin: 0; font-size: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; overflow-x: auto; white-space: pre-wrap; }
.summary-box {
  background: var(--surface2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; font-size: 13px;
}
.summary-box[hidden] { display: none; }
.summary-box ul { margin: 6px 0 0 18px; }

/* ---- Steps (import) ---- */
.steps { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.step {
  flex: 1 1 140px; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 13px;
}
.step b {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text); font-size: 12px;
}
.step.active { border-color: var(--accent); color: var(--text); }
.step.active b { background: var(--accent); color: #111; }
.step.done b { background: var(--success); color: #fff; }
.count-table { width: auto; min-width: 320px; }
.count-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- Badges / misc ---- */
.you-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--accent); color: #111; border-radius: 3px; padding: 1px 5px; margin-left: 6px; }
.unsaved-n { color: var(--accent); font-size: 13px; }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 60px !important; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 4px 6px;
}
.pw-toggle:hover { color: var(--text); }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 4px 0 12px; cursor: pointer; }
.settings-section { margin-top: 28px; }

/* ---- Phone ---- */
@media (max-width: 768px) {
  .top-nav { --nav-h: 56px; }
  :root { --nav-h: 56px; }
  .top-nav { min-height: 56px; }
  .nav-brand { margin-right: 4px; font-size: 14px; }
  .sync-dot { margin-left: -2px; }
  .nav-search-wrap { order: 2; flex: 1 1 0; margin-left: 4px; }
  .nav-search { width: 100%; min-height: 36px !important; font-size: 16px !important; }
  .burger-btn { order: 3; margin-left: 0; }
  .nav-links { order: 4; }
  .nav-search-wrap .autocomplete-list { min-width: 0; left: 0; right: 0; position: fixed; top: 56px; }
  .nav-menu { flex-direction: column; }
  .nav-menu-btn { text-align: left; padding: 10px 12px; font-size: 14px; }
  .nav-menu-btn .caret { display: none; }
  .nav-menu-list { display: flex; position: static; box-shadow: none; border: none; padding: 0 0 0 12px; background: none; }
  .health-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .page-header { position: static; margin-top: 0; padding: 0; box-shadow: none; clip-path: none; }
  .player-hero { gap: 12px; }
  .hero-pic { width: 52px; height: 52px; font-size: 17px; }
  .hero-actions { width: 100%; }
  .hero-actions > * { flex: 1; }
  .hero-actions .btn-sm { min-height: 40px; }
  .pd-nav { width: 100%; justify-content: space-between; }
  .pd-nav a { padding: 8px 14px; font-size: 14px; }
  .btn-menu { width: 40px; height: 36px; }
  .dt-bulk { top: calc(var(--nav-h) + 4px); }
  .health-grid { grid-template-columns: 1fr; }
  .stat { min-width: 0; flex: 1 1 28%; padding: 6px 10px; }
  .stat b { font-size: 17px; }
  .stat-clock { margin-left: 0; }
  .status-strip { gap: 6px; }
  .stat-group { flex: 1 1 100%; padding: 6px 12px; gap: 10px; }
  .stat-group small { min-width: 74px; }
  .stat-group b { font-size: 16px; }
  .add-bar > button { flex: 1 1 40%; }
  .tile-grid { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .side-panel { top: auto; height: 85vh; width: 100%; border-left: none; border-top: 1px solid var(--border); border-radius: 12px 12px 0 0; }
  .count-table { min-width: 0; width: 100%; }

  /* Compact cards: one summary line per row, tap to expand */
  .dt-compact.dt-cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 12px; }
  .dt-compact.dt-cards tr::after { content: ''; order: 2; flex-basis: 100%; height: 0; }
  .dt-compact.dt-cards td.dt-selcell { order: -1; flex: none; }
  .dt-compact.dt-cards td.dt-selcell::before { display: none; }
  .dt-compact.dt-cards td.dt-card-title { order: 0; flex: 1 1 0; border: none; padding: 0; margin: 0; }
  .dt-compact.dt-cards td.dt-head { order: 1; flex: none; flex-direction: row; }
  .dt-compact.dt-cards td.dt-head::before, .dt-compact.dt-cards td.dt-sum::before { display: none; }
  .dt-compact.dt-cards td.dt-sum { order: 3; flex: none; flex-direction: row; font-size: 13px; color: var(--muted); }
  .dt-compact.dt-cards td.dt-sum:not(.dt-empty) ~ td.dt-sum:not(.dt-empty)::before {
    display: inline; content: '·'; font-size: 13px; text-transform: none; letter-spacing: 0; margin-right: 8px;
  }
  .dt-compact.dt-cards td:not(.dt-card-title):not(.dt-head):not(.dt-sum):not(.dt-selcell) {
    display: none; order: 5; flex: 1 1 calc(50% - 8px);
  }
  .dt-compact.dt-cards tr.dt-open td:not(.dt-card-title):not(.dt-head):not(.dt-sum):not(.dt-selcell):not(.dt-empty) { display: flex; }
  .dt-compact.dt-cards tr.dt-open { border-color: var(--accent); }
  .dt-compact.dt-cards td.dt-actions { flex-basis: 100% !important; }
  .dt-cards tr.dt-group { display: block; background: none; border: none; padding: 10px 2px 4px; margin: 0; }
  .dt-cards tr.dt-group td { display: block; background: none; padding: 0; }
  .dt-cards tr.dt-group td::before { display: none; }
  .dt-cards tr.row-dead { border-left: 3px solid var(--red); }
  .dt-cards tr.row-open { border-left: 3px solid var(--success); }
  .dt-cards tr.row-inwindow { border-left: 3px solid var(--accent); }
  .dt-cards tr.row-dead td:first-child, .dt-cards tr.row-open td:first-child, .dt-cards tr.row-inwindow td:first-child { box-shadow: none; }
  .dt-selcell input { width: 20px; height: 20px; }
}
.dt-mobile-only { display: none; }
@media (max-width: 640px) { .dt-mobile-only { display: inline; } }
@media (max-width: 640px) {
  .dt-cards tr.row-open td, .dt-cards tr.row-inwindow td, .dt-cards tr.dt-selected td { background: none; }
  .dt-cards tr.row-open { background: rgba(58,158,95,0.07); }
  .dt-cards tr.row-inwindow { background: rgba(200,168,75,0.07); }
}
.alert-route-row { flex-wrap: wrap; }
@media (max-width: 640px) {
  .alert-route-row select { flex: 1 1 100% !important; min-width: 0; }
  .alert-route-row button { flex: 1 1 auto; }
}
.overlay-panel input[type="color"] { width: 64px; height: 36px; }
.dt-bulk { background: linear-gradient(rgba(200,168,75,0.12), rgba(200,168,75,0.12)), var(--bg); }
@media (max-width: 640px) {
  .dt-cards td > .pill, .dt-cards td > .role-badge, .dt-cards td > .you-badge { align-self: flex-start; }
  .dt-cards td.dt-card-title { display: block; }
  .dt-cards td.dt-card-title .you-badge { vertical-align: middle; }
}
.login-wrap .remember-row input { width: 18px !important; height: 18px; min-height: 0 !important; flex: none; padding: 0; }

/* ---- War Mode: whack log and max HP ---- */
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.link-btn:hover { color: var(--accent-hover); }
.link-btn.muted { color: var(--muted); }
.link-btn.hp-hurt { color: var(--accent); font-weight: 600; }
.link-btn.hp-low { color: var(--red); font-weight: 600; }
.whack-legend { font-size: 12px; margin: -4px 0 10px; }
.link-btn.war-name { text-decoration: none; font-weight: inherit; color: inherit; text-align: left; }
.link-btn.war-name.war-name-open { color: var(--red); font-weight: 600; }
.link-btn.war-name.war-name-inwindow { color: #e8a020; font-weight: 600; }
.link-btn.war-name:hover { text-decoration: underline; }
.summary-h { margin: 16px 0 6px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.whack-people { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.whack-people li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.pill-btn { border: none; cursor: pointer; font: inherit; font-size: 11px; margin: 1px 0; }
.dt-table tr.row-unanswered td { background: rgba(204,42,42,0.08); }
.whack-unanswered { background: rgba(204,42,42,0.08); }
.known-hp { color: var(--success); }
.overlay-panel [hidden] { display: none !important; }

/* War Mode: result line under a pasted whack message */
#wk-msg { width: 100%; box-sizing: border-box; resize: vertical; }
#wk-msg-res { display: block; margin-top: 4px; }
#wk-msg-res.msg-parse-miss { color: var(--accent); }
/* War Mode: exact max health lost on friendly whacks */
.war-hp-input { width: 90px; min-height: 32px; padding: 4px 8px; }

/* Remote page */
.rm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.rm-users { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; margin: 10px 0 14px; }
.rm-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rm-share-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.rm-help { margin-bottom: 10px; }
.rm-toggle { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
#rm-code { text-transform: uppercase; letter-spacing: 2px; font-family: ui-monospace, monospace; width: 150px; }
.rm-audit { width: 100%; border-collapse: collapse; font-size: 12px; }
.rm-audit th, .rm-audit td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.rm-audit td:nth-child(3) { word-break: break-all; }
.rm-status { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.rm-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.rm-busy { font-size: 12px; color: var(--accent); }
.rm-status.is-stale > :not(.rm-sub) { opacity: 0.6; }
.rm-alert { background: rgba(204,42,42,0.15); color: #ef6b6b; border-radius: var(--radius); padding: 6px 8px; font-size: 12px; }
.rm-st-head { display: flex; align-items: center; gap: 8px; }
.rm-st-task { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-st-age { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.rm-st-name { color: var(--text); }
.rm-bar { position: relative; height: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rm-bar i { position: absolute; inset: 0 auto 0 0; background: rgba(200,168,75,0.35); }
.rm-bar span { position: relative; display: block; font-size: 11px; line-height: 14px; padding: 0 6px; color: var(--text); }
.rm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px 12px; }
.rm-kv { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; min-width: 0; }
.rm-kv span { color: var(--muted); }
.rm-kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.rm-kv small { color: var(--muted); font-weight: 400; }
.rm-cd.is-ready { color: #5cc985; }
.rm-details summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.rm-details[open] summary { margin-bottom: 6px; }
.rm-sub { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin: 8px 0 2px; }
.rm-skills { font-size: 12px; }
.rm-feed-head { display: flex; align-items: center; gap: 8px; }
.rm-feed-head h2 { flex: 1; }
.rm-feed-live { font-size: 11px; color: #5cc985; }
.rm-feed-live:not(:empty)::before { content: "● "; }
.rm-feed-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.rm-feed-filters select { flex: 1 1 140px; min-width: 0; }
.rm-feed { display: flex; flex-direction: column; max-height: 70vh; overflow-y: auto; }
.rm-feed-row { padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.rm-feed-top { display: flex; align-items: center; gap: 8px; }
.rm-feed-what { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-feed-when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.rm-feed-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; color: var(--muted); font-size: 12px; margin-top: 2px; }
.rm-feed-msg { color: var(--text); opacity: 0.8; font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }

/* Admin → Plugins and the Remote page's plugin list */
.pl-help { margin-bottom: 10px; }
.pl-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pl-upload input[type=text] { flex: 1; min-width: 160px; }
.pl-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.pl-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.pl-item.is-off { opacity: 0.6; }
.pl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-spacer { flex: 1; }
.pl-desc { font-size: 13px; }
.pl-sub { margin: 12px 0 6px; }
.pl-checks { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; }
.pl-state { font-size: 12px; }
.pl-state.bad { color: #ef6b6b; }
.pl-state.warn { color: var(--accent); }
