:root {
  --bg: #15181b;
  --panel: #1d2226;
  --panel-2: #23282d;
  --border: #2c3238;
  --text: #e9ecef;
  --text-muted: #8b939b;
  --accent: #f2a93b;
  --accent-dim: #7a5a20;
  --online: #46d18a;
  --offline: #f0554f;
  --unknown: #6b7480;
  --radius: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 48px;
}

button, input {
  font-family: inherit;
  color: inherit;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #241a05;
  border-color: var(--accent);
}
.btn.ghost {
  background: transparent;
}
.btn.danger-ghost {
  background: transparent;
  color: var(--offline);
  border-color: var(--offline);
}
.btn.small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ---------- main ---------- */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.panel-toggle .chev { transition: transform 0.15s ease; color: var(--text-muted); }
.panel-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.panel-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
}

.field-row { display: flex; gap: 10px; }
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}
label.narrow { flex: 0 0 90px; }
input[type="text"], input[type="number"], input[type="search"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 11px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--mono);
}
input:focus, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--mono);
  margin: 10px 0 0;
  word-break: break-all;
}
textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 11px;
  font-size: 12.5px;
  color: var(--text);
  font-family: var(--mono);
  resize: vertical;
  line-height: 1.5;
}
.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.field-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.msg {
  font-size: 12.5px;
  margin: 10px 0 0;
  min-height: 14px;
}
.msg.error { color: var(--offline); }
.msg.ok { color: var(--online); }

/* ---------- search ---------- */
.search-row {
  position: sticky;
  top: 61px;
  z-index: 15;
  background: var(--bg);
  padding: 4px 0 10px;
}
#searchInput {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
}
.filter-chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.chip {
  flex: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(242, 169, 59, 0.1);
}

/* ---------- list ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  background: var(--unknown);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.03);
}
.led.online { background: var(--online); box-shadow: 0 0 8px 1px rgba(70,209,138,0.55); }
.led.offline { background: var(--offline); box-shadow: 0 0 8px 1px rgba(240,85,79,0.5); }

.row-thumb {
  width: 42px;
  height: 42px;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.row-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
}

.row-main { flex: 1; min-width: 0; }
.row-asset {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-host {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:active { transform: translateY(1px); }

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 40px 20px;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.lightbox[hidden] {
  display: none;
}
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

@media (min-width: 560px) {
  .row-asset { font-size: 15px; }
}

/* ---------- upload queue: per-row badge + status toast ---------- */
.row-thumb-wrap {
  position: relative;
  flex: none;
}
.thumb-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  pointer-events: none;
  user-select: none;
}
.thumb-badge.up { background: var(--accent); color: #1a1206; border-color: transparent; }
.thumb-badge.retry { background: var(--accent); color: #1a1206; border-color: transparent; }
.thumb-badge.fail {
  background: var(--offline);
  color: #fff;
  border-color: transparent;
  pointer-events: auto;
  cursor: pointer;
}

.queue-badge {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  z-index: 40;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: 92vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-badge[hidden] { display: none; }
.queue-badge.busy { border-color: var(--accent-dim); }
.queue-badge.error {
  background: var(--offline);
  color: #fff;
  border-color: transparent;
  cursor: pointer;
}
.queue-badge.done {
  background: var(--online);
  color: #08221a;
  border-color: transparent;
}
@keyframes thumb-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.thumb-badge.up { animation: thumb-pulse 1.1s ease-in-out infinite; }
