*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0b0f1a;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: #3b82f6;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  background: #0b0f1a;
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid #1e2a45;
  background: rgba(11, 15, 26, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #151d32;
  color: #8b9bb4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  opacity: 0.85;
}

.app-main {
  flex: 1;
  overflow: auto;
  padding: 14px 16px 90px;
}

.app-tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(6, 9, 19, 0.98);
  border-top: 1px solid #1e2a45;
  z-index: 30;
}

.tab-btn {
  border: 0;
  background: transparent;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn i {
  font-size: 18px;
}

.tab-btn.active {
  color: #3b82f6;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: #151d32;
  border: 1px solid #1e2a45;
}

.pill.ok {
  color: #22c55e;
}

.pill.bad {
  color: #ef4444;
}

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(145deg, #1e3a8a 0%, #060913 55%);
}

.login-card {
  width: min(420px, 100%);
  background: rgba(21, 29, 50, 0.95);
  border: 1px solid #1e2a45;
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.login-card img {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  object-fit: contain;
}

.login-card h1 {
  margin: 0 0 4px;
  text-align: center;
  font-size: 22px;
}

.login-card .sub {
  margin: 0 0 18px;
  text-align: center;
  color: #8b9bb4;
  font-size: 14px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #8b9bb4;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid #1e2a45;
  border-radius: 12px;
  background: #121a2e;
  color: #fff;
  padding: 12px 14px;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  border-color: #2563eb;
}

.pass-row {
  position: relative;
}

.pass-row input {
  padding-right: 44px;
}

.pass-row button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #8b9bb4;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}

.btn.primary {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}

.btn.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn.secondary {
  background: #151d32;
  color: #fff;
  border: 1px solid #1e2a45;
}

.btn.danger {
  background: #991b1b;
  color: #fff;
}

.btn.small {
  padding: 8px 12px;
  font-size: 13px;
}

.hint,
.muted {
  color: #5c6b82;
  font-size: 12px;
  line-height: 1.5;
}

.error-text {
  color: #ef4444;
  font-size: 13px;
  margin: 8px 0 0;
}

.welcome-card {
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
}

.welcome-card .online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.welcome-card .online i {
  font-size: 8px;
}

.welcome-card h2 {
  margin: 0;
  font-size: 18px;
}

.welcome-card .rank {
  margin-top: 4px;
  font-weight: 900;
  font-size: 14px;
}

.welcome-card img {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 72px;
  height: 72px;
  opacity: 0.85;
}

.section-title {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.1px;
  color: #8b9bb4;
}

.card {
  background: #151d32;
  border: 1px solid #1e2a45;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-box {
  background: #121a2e;
  border: 1px solid #1e2a45;
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}

.stat-box strong {
  display: block;
  font-size: 18px;
}

.stat-box span {
  color: #5c6b82;
  font-size: 11px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #151d32;
  border: 1px solid #1e2a45;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 13px;
}

.chip small {
  display: block;
  color: #8b9bb4;
  font-size: 11px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-tile {
  border: 1px solid #1e2a45;
  background: #151d32;
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  color: #fff;
  cursor: pointer;
}

.quick-tile i {
  display: block;
  font-size: 20px;
  color: #3b82f6;
  margin-bottom: 6px;
}

.quick-tile span {
  font-size: 11px;
  font-weight: 700;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  background: #151d32;
  border: 1px solid #1e2a45;
  border-radius: 12px;
  padding: 0 12px;
}

.search-row input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 12px 0;
}

.search-row input:focus {
  outline: none;
}

.tabs-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-chip {
  border: 1px solid #1e2a45;
  background: #151d32;
  color: #8b9bb4;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.tab-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #1e2a45;
  background: #151d32;
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}

.list-row:active {
  opacity: 0.92;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #121a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #3b82f6;
  flex-shrink: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-main strong {
  display: block;
  font-size: 15px;
}

.row-main span {
  color: #8b9bb4;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: #22c55e;
}

.status-dot.away {
  background: #f97316;
}

.status-dot.offline {
  background: #5c6b82;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-head .avatar {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

.badge {
  border: 1px solid;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #1e2a45;
  font-size: 13px;
}

.kv:last-child {
  border-bottom: 0;
}

.kv dt {
  color: #8b9bb4;
}

.kv dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100dvh - 240px);
  overflow: auto;
  margin-bottom: 12px;
}

.chat-bubble {
  max-width: 92%;
  background: #151d32;
  border: 1px solid #1e2a45;
  border-radius: 14px;
  padding: 10px 12px;
}

.chat-bubble.me {
  align-self: flex-end;
  background: #1d4ed8;
  border-color: #2563eb;
}

.chat-bubble strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.chat-bubble small {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 10px;
}

.chat-compose {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: #0b0f1a;
  padding-top: 8px;
}

.chat-compose input {
  flex: 1;
}

.empty {
  text-align: center;
  color: #5c6b82;
  padding: 28px 12px;
}

.install-banner {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid #2563eb;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.install-banner strong {
  display: block;
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: rgba(21, 29, 50, 0.98);
  border: 1px solid #1e2a45;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal {
  width: min(420px, 100%);
  background: #151d32;
  border: 1px solid #1e2a45;
  border-radius: 16px;
  padding: 16px;
}

.modal h3 {
  margin: 0 0 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

@media (min-width: 521px) {
  #app {
    border-left: 1px solid #1e2a45;
    border-right: 1px solid #1e2a45;
  }
}
