:root {
  --bg: #202830;
  --card: #0f141c;
  --card-2: #111821;
  --line: rgba(255, 255, 255, .08);
  --text: #eef2f7;
  --muted: #8b929d;
  --accent: #2e9cff;
  --danger: #ef4444;
  --success: #22c55e;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

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

/* Doar pagina publică fără scroll pe fundal */
body:not(.admin-body) {
  height: 100dvh;
  overflow: hidden;
}

.page-shell {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 90px 32px;
  overflow: hidden;
  background-color: #202830;
  background-image:
    linear-gradient(rgba(255, 255, 255, .04) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, .04) 2px, transparent 2px),
    radial-gradient(circle at 20% 18%, transparent 0 20px, rgba(255, 255, 255, .08) 21px 22px, transparent 23px),
    radial-gradient(circle at 72% 28%, transparent 0 30px, rgba(255, 255, 255, .07) 31px 32px, transparent 33px),
    radial-gradient(circle at 38% 68%, transparent 0 25px, rgba(255, 255, 255, .06) 26px 27px, transparent 28px);
  background-size: 240px 240px, 240px 240px, 410px 330px, 520px 380px, 470px 420px;
  background-position: center;
}

.page-shell.with-image {
  background-image: linear-gradient(rgba(18, 23, 31, .58), rgba(18, 23, 31, .58)), var(--page-bg);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.profile-card {
  width: min(460px, 100%);
  max-height: calc(100dvh - 180px);
  background: rgba(13, 18, 26, .96);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-head {
  text-align: center;
  padding: 28px 28px 18px;
  flex-shrink: 0;
}

.avatar {
  width: 108px;
  height: 108px;
  border-radius: 999px;
  object-fit: cover;
  display: block;
  margin: 0 auto 26px;
  background: #151b24;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -.03em;
}

.profile-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.tab-btn {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 16px 22px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 620;
}

.tab-btn.active {
  color: var(--text);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
}

.links-list {
  padding: 28px 34px 34px;
  display: grid;
  gap: 30px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.link-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  border-radius: 14px;
  transition: transform .16s ease, background .16s ease;
}

.link-item:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .025);
}

.icon-box {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #172133;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.icon-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-box svg {
  width: 25px;
  height: 25px;
}

.link-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 18px;
  line-height: 1.2;
}

.verified {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #22a7ff;
  color: #fff;
  font-size: 12px;
  flex: 0 0 auto;
}

.link-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

/* ADMIN */
.admin-body {
  background: #0b1118;
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

.hidden {
  display: none !important;
}

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-wrap {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 50px;
}

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

.admin-header p,
.admin-panel p {
  color: var(--muted);
  margin: 8px 0;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-actions a,
button,
.file-label {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button.ghost,
.ghost {
  background: rgba(255, 255, 255, .08);
}

button.danger {
  background: var(--danger);
}

button.small-btn {
  padding: 8px 10px;
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 410px 1fr;
  gap: 18px;
  align-items: start;
}

.admin-panel {
  background: rgba(15, 20, 28, .98);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.admin-panel.small {
  width: min(420px, 100%);
}

.admin-panel h2,
.admin-panel h3 {
  margin: 0 0 16px;
}

.admin-panel label {
  display: block;
  margin: 14px 0 7px;
  color: #c7ced8;
  font-weight: 650;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #0a1017;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
  font-size: 16px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.upload-row {
  display: grid;
  gap: 8px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.editor-list {
  display: grid;
  gap: 14px;
}

.tab-editor,
.link-editor {
  border: 1px solid rgba(255, 255, 255, .08);
  background: #0a1017;
  border-radius: 14px;
  padding: 14px;
}

.tab-editor-head,
.link-editor-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.link-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
}

.checkbox-row input {
  width: auto;
}

.stats-panel {
  margin-top: 18px;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.stat-card {
  background: #0a1017;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 14px;
}

.stat-card strong {
  display: block;
  font-size: 26px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.table {
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  margin-bottom: 22px;
}

.table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  text-align: left;
  font-size: 14px;
}

th {
  color: #cbd5e1;
  background: #0a1017;
}

td {
  color: #aab3bf;
}

.error {
  color: #fb7185;
  display: block;
  margin-top: 10px;
}

/* MOBILE PUBLIC + ADMIN */
@media (max-width: 800px) {
  .page-shell {
    height: 100dvh;
    min-height: 100dvh;
    padding: 20px 20px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .profile-card {
    width: 100%;
    max-width: 420px;
    max-height: calc(100dvh - 38px);
    margin: 0 auto;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .profile-head {
    padding-top: 28px;
    flex-shrink: 0;
  }

  .avatar {
    width: 96px;
    height: 96px;
    margin-bottom: 23px;
  }

  h1 {
    font-size: 24px;
  }

  .tabs {
    overflow-x: auto;
    justify-content: center;
    padding: 0 18px;
    flex-shrink: 0;
  }

  .tab-btn {
    white-space: nowrap;
    padding: 16px 18px;
  }

  .links-list {
    padding: 26px 28px 34px;
    gap: 30px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .link-item {
    grid-template-columns: 50px 1fr;
    gap: 8px;
  }

  .link-title {
    font-size: 17px;
  }

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

  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .stats-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .link-edit-grid {
    grid-template-columns: 1fr;
  }
}

/* Admin improvements */
button,
.header-actions a,
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-actions,
.form-actions,
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-actions {
  margin-top: 14px;
}

.form-actions {
  margin-top: 18px;
}

.action-row {
  justify-content: flex-end;
}

.wrap-row {
  align-items: flex-start;
  flex-wrap: wrap;
}

.top-panel {
  margin-bottom: 18px;
}

.bottom-grid {
  margin-top: 0;
}

.mini-note {
  font-size: 13px;
}

.inner-title {
  margin-top: 10px;
  margin-bottom: 10px;
}

.header-actions {
  gap: 12px;
}

.admin-panel button+button,
.admin-panel a+button,
.admin-panel button+a {
  margin-left: 0;
}

.tabs-compact-panel {
  min-height: 260px;
}

.tabs-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.preview-pill {
  background: #0a1017;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 5px;
}

.preview-pill span,
.empty-admin {
  color: var(--muted);
  font-size: 14px;
}

.empty-admin {
  padding: 14px;
}

button.wide {
  width: 100%;
  margin-top: 4px;
}

.toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  background: #101823;
  border: 1px solid rgba(255, 255, 255, .12);
  border-left: 4px solid var(--success);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 15px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, .35);
  transform: translateY(-8px);
  opacity: 0;
  transition: .22s ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(1120px, 100%);
  max-height: min(86vh, 900px);
  background: #0f141c;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 18px;
  box-shadow: 0 28px 100px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.modal-head h2 {
  margin: 0;
}

.modal-body {
  padding: 20px;
  overflow: auto;
}

.popup-editor {
  gap: 18px;
}

.modal-table {
  max-height: 62vh;
}

.stat-card.clickable {
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease;
}

.stat-card.clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(46, 156, 255, .5);
}

.live-card {
  background: linear-gradient(135deg, rgba(46, 156, 255, .14), rgba(34, 197, 94, .08));
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  padding: 15px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.live-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.live-card span,
.live-card small {
  color: var(--muted);
}

@media (min-width: 801px) {
  .stats-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Spacing inside the tab/link popup */
.popup-editor .tab-editor,
.popup-editor .link-editor {
  padding: 18px;
}

.popup-editor .link-edit-grid {
  gap: 16px;
}

.popup-editor label {
  margin-top: 10px;
  margin-bottom: 9px;
}

.popup-editor .link-edit-grid>div {
  display: grid;
  gap: 6px;
}

@media (max-width: 800px) {
  .admin-wrap {
    width: min(100% - 22px, 1280px);
    padding-top: 18px;
  }

  .header-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .admin-header {
    gap: 14px;
  }

  .action-row {
    justify-content: flex-start;
  }

  .tabs-compact-panel .action-row {
    justify-content: flex-start;
  }

  .modal {
    padding: 10px;
    align-items: end;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }

  .modal-head {
    padding: 15px;
  }

  .modal-body {
    padding: 15px;
  }

  .tab-editor-head,
  .link-editor-head {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-actions {
    justify-content: flex-end;
    width: 100%;
  }

  .compact-actions button {
    flex: 0 0 auto;
  }

  .toast-root {
    top: 12px;
    right: 12px;
  }
}
