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

:root {
  --bg: #0b0d11;
  --panel: #12151b;
  --panel-2: #181c24;
  --panel-3: #1e232d;
  --text: #f4f7fb;
  --muted: #9098a8;
  --border: rgba(255,255,255,.08);
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  --primary: #6e7cff;
  --danger: #ff5d68;
  --success: #3bc98b;
  --warning: #f4ba52;
  --offline: #7d8594;
  --radius: 22px;
}

body.light {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --panel-3: #e7ebf2;
  --text: #11151c;
  --muted: #687181;
  --border: rgba(15,20,28,.10);
  --shadow: 0 18px 50px rgba(20,25,35,.10);
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  overscroll-behavior: none;
}

button, input, textarea, select {
  font: inherit;
}

button, .btn, .app-card, .tool-card {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: -.04em;
}

.eyebrow, .section-kicker {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.btn, .icon-btn, .text-btn {
  border: 0;
}

.btn {
  min-height: 44px;
  border-radius: 13px;
  padding: 0 16px;
  font-weight: 760;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: 1.25rem;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.6fr .8fr;
  gap: 20px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    radial-gradient(circle at 100% 0%, rgba(110,124,255,.18), transparent 42%),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-weight: 800;
}

.hero-card h2 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  line-height: .98;
  letter-spacing: -.05em;
}

.hero-card .muted {
  max-width: 700px;
  margin-top: 18px;
}

.muted {
  color: var(--muted);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-self: end;
}

.hero-stats div {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px;
}

.hero-stats span {
  display: block;
  font-size: 1.65rem;
  font-weight: 900;
}

.hero-stats small {
  color: var(--muted);
}

.controls {
  margin: 24px 0 10px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  min-height: 50px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 1px 4px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}

.filter-chip.active {
  color: #fff;
  background: var(--primary);
  border-color: transparent;
}

.dashboard-section {
  margin-top: 34px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 4px 0 0;
  font-size: 1.25rem;
}

.count-chip {
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .82rem;
  font-weight: 800;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.app-card {
  position: relative;
  min-height: 230px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .16s ease, border-color .16s ease;
}

.app-card:hover {
  transform: translateY(-3px);
}

.app-accent {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--card-accent, var(--primary));
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: color-mix(in srgb, var(--card-accent) 15%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--card-accent) 40%, transparent);
}

.card-menu {
  display: flex;
  gap: 6px;
}

.mini-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 11px;
}

.card-title {
  margin: 22px 0 6px;
  font-size: 1.28rem;
}

.card-desc {
  min-height: 44px;
  color: var(--muted);
  line-height: 1.45;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--panel-2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-live { background: var(--success); }
.status-development { background: var(--warning); }
.status-offline { background: var(--offline); }

.card-open {
  position: absolute;
  left: 20px;
  bottom: 18px;
  border: 0;
  background: transparent;
  color: var(--card-accent, var(--primary));
  font-weight: 900;
  padding: 0;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
}

.tool-card {
  position: relative;
  overflow: hidden;
  min-height: 118px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  padding: 16px;
}

.tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tool-card .card-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.tool-card h4 {
  margin: 0;
  font-size: 1rem;
}

.tool-card p {
  color: var(--muted);
  font-size: .82rem;
  margin: 4px 0 0;
}

.tool-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 42px;
  color: var(--muted);
}

.text-btn {
  background: transparent;
  color: var(--muted);
  padding: 8px;
}

.fab {
  display: none;
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 19px;
  background: var(--primary);
  color: white;
  font-size: 1.8rem;
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(12px);
}

.modal {
  width: min(680px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal.wide {
  width: min(920px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 15px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 4px 0 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

label.full {
  grid-column: 1 / -1;
}

input, textarea, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  outline: 0;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

.check-row {
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 44px;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.manager-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.file-btn input {
  display: none;
}

.manager-list {
  display: grid;
  gap: 9px;
}

.manager-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 15px;
  padding: 12px;
}

.manager-info strong {
  display: block;
}

.manager-info small {
  color: var(--muted);
}

.manager-actions {
  display: flex;
  gap: 6px;
}

.danger-zone {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.danger-zone h4 {
  margin-bottom: 6px;
}

.danger-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 70px 20px;
}

.empty-icon {
  font-size: 3rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hero-card { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .compact-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: 90px;
  }

  .top-actions .primary {
    display: none;
  }

  .hero-card {
    border-radius: 22px;
    padding: 22px;
  }

  .hero-card h2 {
    font-size: 2rem;
  }

  .hero-stats {
    grid-template-columns: repeat(3,1fr);
  }

  .hero-stats div {
    padding: 13px 10px;
  }

  .hero-stats span {
    font-size: 1.3rem;
  }

  .card-grid, .compact-grid {
    grid-template-columns: 1fr;
  }

  .app-card {
    min-height: 216px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  label.full {
    grid-column: auto;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }

  .fab {
    display: grid;
    place-items: center;
  }

  .footer {
    display: none;
  }

  .manager-item {
    grid-template-columns: auto 1fr;
  }

  .manager-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

.transfer-zone {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.transfer-zone h4 { margin-bottom: 6px; }
.text-hidden { display: none !important; }


#topSettings {
  flex: 0 0 auto;
}

@media (max-width: 620px) {
  #topSettings {
    display: grid;
  }
}
