:root {
  --bg: #07111a;
  --panel: #0d1b27;
  --card: #122433;
  --line: #1e3648;
  --text: #e8f1f6;
  --muted: #8aa0b3;
  --teal: #14b8a6;
  --teal-2: #0f766e;
  --gold: #f5c16c;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; }
a { color: var(--teal); }
button, input, select {
  font: inherit; color: inherit;
}
button {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.9rem; cursor: pointer;
}
button.primary { background: var(--teal-2); border-color: transparent; color: #ecfdf5; }
button.ghost { background: transparent; }
button.active { background: #134e4a; border-color: var(--teal); }
input, select {
  background: #0b1822; border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem; width: 100%;
}
.auth {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1000px 500px at 20% -10%, #134e4a 0%, transparent 50%), var(--bg);
}
.auth-card {
  width: min(420px, 92vw); background: var(--panel); padding: 2rem; border-radius: 20px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.brand { display: flex; gap: 0.85rem; align-items: center; margin-bottom: 1.4rem; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(160deg, #14b8a6, #0f766e); font-weight: 800;
}
.auth-card h1 { margin: 0; font-size: 1.15rem; }
.auth-card p, .muted { color: var(--muted); margin: 0.2rem 0 0; }
label { display: grid; gap: 0.35rem; margin: 0.8rem 0; font-size: 0.9rem; color: var(--muted); }
.auth-card button { width: 100%; margin-top: 0.6rem; background: var(--teal-2); border: 0; color: white; font-weight: 600; }
.login-download { margin-top: 0.75rem; display: grid; gap: 0.45rem; }
.login-download .apk-hint { text-align: center; }
.alert { background: #3f1d1d; color: #fecaca; padding: 0.7rem 0.85rem; border-radius: 10px; }

aside {
  width: 250px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem; min-height: 100vh;
}
aside nav { display: grid; gap: 0.4rem; }
aside nav button { text-align: left; }
.aside-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem;
  width: 100%; text-align: left; display: block; transition: border-color 0.15s, background 0.15s;
}
.aside-box:hover { border-color: var(--teal); background: #152b3d; }
.aside-box.active { border-color: var(--teal); background: #134e4a; }
.aside-box-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.aside-arrow { font-size: 0.75rem; color: var(--teal); font-weight: 600; }
.aside-box p, .apk-hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
.aside-box strong { display: block; font-size: 1.6rem; margin: 0.2rem 0; }
.aside-box #online-count { font-size: 0.82rem; color: var(--muted); }
.apk-btn {
  display: block; text-align: center; background: var(--gold); color: #1a1204; text-decoration: none;
  font-weight: 700; border-radius: 12px; padding: 0.75rem; transition: filter 0.15s;
}
.apk-btn:hover { filter: brightness(1.06); }
.main { flex: 1; padding: 1.3rem 1.6rem 2.5rem; min-width: 0; }
header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
header h1 { margin: 0; font-size: 1.45rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.header-actions input { width: 260px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 1.1rem 0; }
.stats article {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem;
  min-width: 0;
}
.stats span { color: var(--muted); font-size: 0.8rem; }
.stats strong { display: block; margin-top: 0.3rem; font-size: 1.15rem; }
.stat-transfer { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-transfer-head { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.stat-transfer-filters { display: flex; gap: 0.3rem; align-items: center; }
.stat-transfer-filters select {
  width: auto; padding: 0.2rem 0.45rem; font-size: 0.74rem; border-radius: 8px;
  background: #0a1620; border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.stat-transfer strong.amt-in { color: var(--ok); }
.stat-transfer strong.amt-out { color: var(--danger); }
.stat-transfer small { font-size: 0.73rem; }
.toolbar { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input[type="date"] { width: auto; }
.error-note { color: var(--danger); font-size: 0.8rem; margin-top: 0.25rem; }
.list { display: grid; gap: 0.65rem; }
.item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem;
  display: grid; grid-template-columns: 92px 1fr auto; gap: 0.8rem; align-items: start;
}
.item.bank { border-color: #1d6b62; }
.badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; padding: 0.28rem 0.5rem;
  border-radius: 999px; background: #16313f; color: #9fd7d0; display: inline-block;
}
.badge.bank { background: #134e4a; color: #99f6e4; }
.badge.chat { background: #1e3a5f; color: #93c5fd; }
.badge.email { background: #3b2f14; color: #fcd34d; }
.item.chat { border-color: #1e4a7b; }
.item.email { border-color: #6b5420; }
.item .sender { margin: 0 0 0.2rem; color: #cbd5e1; font-size: 0.8rem; }
.item h3 { margin: 0 0 0.25rem; font-size: 0.98rem; }
.item p { margin: 0; color: var(--muted); font-size: 0.9rem; white-space: pre-wrap; }
.meta { color: var(--muted); font-size: 0.75rem; margin-top: 0.4rem; }
.amount { font-weight: 800; color: var(--ok); white-space: nowrap; }
.amount.out { color: var(--danger); }
.actions { display: flex; gap: 0.35rem; justify-content: flex-end; margin-top: 0.4rem; }
.actions button { padding: 0.35rem 0.55rem; font-size: 0.78rem; }
.empty { color: var(--muted); padding: 2rem 0.5rem; }
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.2rem; width: min(480px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,0.55); }
.pair-code {
  font-size: 2.4rem; letter-spacing: 0.35rem; font-weight: 800; text-align: center;
  background: #0b1822; border-radius: 12px; padding: 0.8rem; margin: 0.8rem 0;
}
.row { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.device-row {
  display: flex; justify-content: space-between; gap: 0.6rem; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem; margin: 0.45rem 0;
  flex-wrap: wrap;
}
dialog.wide { width: min(720px, 94vw); }
.shot {
  width: 110px; height: 110px; object-fit: cover; border-radius: 10px; background: #0b1822;
}
.item.viol { grid-template-columns: 100px 1fr 110px; }
.item.viol.pending { border-color: #b45309; }
.item.viol.confirmed { border-color: #1d6b62; }
.device-row .actions { flex-wrap: wrap; }
.device-row select { width: auto; min-width: 140px; }
.capture-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.8rem; align-items: center; }
.dur-box { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; padding: 0.35rem 0; }
.dur-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.dur-box label { margin: 0; display: inline-flex; align-items: center; gap: 0.4rem; }
button.warn { background: #451a03; border-color: #b45309; color: #fde68a; }
button.danger { background: #3f1d1d; border-color: #991b1b; color: #fecaca; }
.badge.ok { background: #134e4a; color: #6ee7b7; }
.badge.off { background: #3f1d1d; color: #fca5a5; }
.badge.muted-b { background: #1e293b; color: #94a3b8; }

.devices-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0.85rem 1rem;
  margin-bottom: 0.9rem;
}
.devices-toolbar .staff-add { display: flex; gap: 0.5rem; flex: 1; min-width: 240px; max-width: 420px; }
.devices-toolbar .staff-add input { flex: 1; min-width: 0; }
.devices-toolbar .staff-add button { white-space: nowrap; }

.device-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem;
  display: grid; gap: 0.85rem;
}
.device-card.is-disabled { border-color: #7c2d12; opacity: 0.88; }
.device-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap;
}
.device-title-wrap { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.device-title-wrap h3 { margin: 0; font-size: 1.05rem; }
.device-meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; word-break: break-word; }
.device-head-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }

.device-edit-row {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1fr) auto; gap: 0.6rem;
  align-items: end; background: #0a1620; border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem;
}
.device-edit-row label { margin: 0; }
.device-edit-row button { white-space: nowrap; height: fit-content; }

.device-quick-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding-top: 0.2rem; border-top: 1px solid var(--line);
}
.device-quick-actions button { font-size: 0.84rem; padding: 0.48rem 0.75rem; }
.device-audio-inline {
  display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  background: #0a1620; border: 1px solid var(--line); border-radius: 10px; padding: 0.3rem 0.5rem;
}
.device-audio-inline input { width: 4.6rem; padding: 0.35rem 0.5rem; }

.timer-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem;
  padding-top: 0.2rem; border-top: 1px solid var(--line);
}
.timer-card {
  background: #0a1620; border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem;
  display: flex; flex-direction: column; gap: 0.55rem; min-width: 0;
}
.timer-card.active { border-color: var(--teal); }
.timer-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; }
.timer-card-head strong { font-size: 0.88rem; }
.timer-fields { display: grid; gap: 0.45rem; }
.timer-row-2col { display: grid; grid-template-columns: minmax(76px, 0.75fr) minmax(110px, 1.25fr); gap: 0.45rem; }
.timer-fields label { margin: 0; font-size: 0.78rem; }
.timer-fields input, .timer-fields select { padding: 0.45rem 0.6rem; font-size: 0.84rem; min-width: 0; }
.timer-card button { width: 100%; margin-top: auto; font-size: 0.84rem; padding: 0.5rem; }

.table-wrap {
  width: 100%; overflow-x: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px;
}
table.grid, table.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; line-height: 1.25; }
table.grid th, table.grid td, table.data-table th, table.data-table td {
  border: 1px solid var(--line); padding: 0.38rem 0.55rem; text-align: left; vertical-align: middle;
}
table.data-table thead th {
  color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; background: #0a1620; white-space: nowrap; padding: 0.42rem 0.55rem;
}
table.data-table .badge { padding: 0.15rem 0.42rem; font-size: 0.7rem; }
tr.data-row { cursor: pointer; transition: background 0.12s; }
tr.data-row:hover { background: #122433; }
tr.data-row.open { background: #132838; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-one-line {
  max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-sub {
  color: var(--muted); font-size: 0.76rem; margin-left: 0.35rem; font-weight: 400;
}
.cell-addr {
  max-width: 240px; color: var(--text); font-size: 0.8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-nowrap { white-space: nowrap; }
.expand-caret { display: inline-block; width: 0.9rem; color: var(--muted); font-size: 0.68rem; transition: transform 0.15s; }
tr.data-row.open .expand-caret { transform: rotate(90deg); color: var(--teal); }
tr.detail-row { background: #09141e; }
tr.detail-row td { padding: 0.65rem 0.8rem; border: 1px solid var(--line); }
.detail-box { display: grid; gap: 0.45rem; }
.detail-text {
  margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--text);
  background: #0d1b27; border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem;
  font-size: 0.84rem; line-height: 1.4;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; color: var(--muted); font-size: 0.76rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.detail-actions button { padding: 0.34rem 0.62rem; font-size: 0.78rem; }

.audio-cell { min-width: 210px; }
.clip-inline { width: 100%; max-width: 240px; height: 28px; display: block; }
.boost-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
  margin-bottom: 0.65rem; font-size: 0.8rem; color: var(--muted);
}
.boost-bar button { padding: 0.28rem 0.58rem; font-size: 0.78rem; }

.thumb-btn {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.14rem 0.45rem 0.14rem 0.16rem;
  background: #0b1822; border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
  font-size: 0.75rem; line-height: 1;
}
.thumb-btn:hover { border-color: var(--teal); }
.thumb-mini { width: 24px; height: 24px; object-fit: cover; border-radius: 4px; display: block; background: #07111a; }

.pagination-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  margin-top: 0.8rem; padding: 0.55rem 0.75rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; font-size: 0.82rem;
}
.pagination-btns { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.pagination-btns button { padding: 0.36rem 0.68rem; font-size: 0.8rem; }
.pagination-btns button:disabled { opacity: 0.45; cursor: not-allowed; }

.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed; inset: 0; z-index: 999; display: grid; place-items: center;
}
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(4, 10, 16, 0.84); backdrop-filter: blur(4px); }
.lightbox-dialog {
  position: relative; z-index: 1; width: min(920px, 94vw); max-height: 92vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.lightbox-top {
  display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--line);
}
.lightbox-caption { font-weight: 600; font-size: 0.92rem; }
.lightbox-top-actions { display: flex; align-items: center; gap: 0.6rem; }
.ghost-link {
  padding: 0.38rem 0.68rem; border: 1px solid var(--line); border-radius: 9px;
  text-decoration: none; font-size: 0.8rem; color: var(--teal);
}
.lightbox-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  background: #060e15; min-height: 360px; max-height: 78vh; padding: 1rem 3.5rem;
}
.lightbox-stage img {
  max-width: 100%; max-height: 74vh; object-fit: contain; border-radius: 10px;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px;
  border-radius: 999px; font-size: 1.5rem; line-height: 1; padding: 0;
  display: grid; place-items: center; background: rgba(13, 27, 39, 0.85);
}
.lb-prev { left: 0.75rem; }
.lb-next { right: 0.75rem; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .timer-grid { grid-template-columns: 1fr; }
  .device-edit-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body { flex-direction: column; }
  aside { width: auto; min-height: auto; }
  .stats { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; }
  .header-actions input { width: 100%; }
  .lightbox-stage { padding: 0.75rem 2.75rem; }
}
