:root {
  --bg-start: #0f172a;
  --bg-end: #0b1021;
  --panel: rgba(15, 23, 42, 0.72);
  --panel-strong: rgba(15, 23, 42, 0.9);
  --line: rgba(148, 163, 184, 0.25);
  --text: #e2e8f0;
  --muted: #a0aec0;
  --accent: #22c55e;
  --accent-soft: #86efac;
  --danger: #fb7185;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", sans-serif;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  background: radial-gradient(circle at 10% 20%, #0b2447 0%, transparent 40%),
              radial-gradient(circle at 90% 10%, #12355b 0%, transparent 42%),
              linear-gradient(160deg, var(--bg-start), var(--bg-end));
}

.backdrop {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}

.color-overlay {
  position: fixed;
  inset: 0;
  background: var(--user-overlay-color, #22c55e);
  opacity: var(--user-overlay-opacity, 0.16);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.6rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: "Sora", sans-serif;
  letter-spacing: 0.03em;
}

.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(145deg, #34d399, #10b981);
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.9);
}

nav a {
  color: var(--text);
  text-decoration: none;
  margin-left: 1rem;
  font-weight: 500;
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 1rem;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  border: 1px solid rgba(134, 239, 172, 0.35);
  background: rgba(34, 197, 94, 0.14);
  color: #dcfce7;
  font-size: 0.85rem;
}

nav a:hover {
  color: var(--accent-soft);
}

.container {
  width: min(1100px, 94vw);
  margin: 2rem auto 3rem;
  position: relative;
  z-index: 1;
}

.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  margin-bottom: 1.4rem;
}

.tabs-shell {
  border-radius: var(--radius);
}

.tabs-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-width: 100%;
}

.tab-btn {
  background: rgba(51, 65, 85, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.32);
  white-space: nowrap;
}

.tab-btn.is-active {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: rgba(134, 239, 172, 0.5);
}

.tab-panel[hidden] {
  display: none;
}

h1,
h2,
h3 {
  margin: 0 0 0.55rem;
  font-family: "Sora", sans-serif;
}

p {
  color: var(--muted);
  margin-top: 0;
}

.card-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

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

.portal-content .card-grid {
  grid-template-columns: repeat(var(--portal-cols, 2), minmax(0, 1fr));
}

.portal-content[data-view="list"] .card-grid {
  display: none;
}

.portal-content[data-view="tiles"] .portal-list-wrap {
  display: none;
}

.portal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-box {
  display: grid;
  gap: 0.35rem;
  flex: 1;
  max-width: 520px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.9rem;
}

.search-box input {
  margin-top: 0;
}

.view-toggle {
  display: inline-flex;
  gap: 0.45rem;
}

.view-toggle button {
  background: rgba(51, 65, 85, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.32);
}

.view-toggle button.active {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: rgba(134, 239, 172, 0.5);
}

.portal-list td .login-btn {
  margin-top: 0;
}

.portal-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.portal-list tbody tr {
  background: var(--panel);
}

.admin-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.service-card,
.panel,
.auth-card,
.empty-state {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1.2rem;
  box-shadow: 0 16px 30px rgba(2, 6, 23, 0.25);
}

.service-card p {
  min-height: 42px;
}

.service-url {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  word-break: break-all;
}

.service-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.service-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.service-head h2 {
  margin: 0;
}

.service-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(134, 239, 172, 0.35);
}

.service-icon svg {
  width: 21px;
  height: 21px;
}

.service-icon path {
  fill: none;
  stroke: #86efac;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  width: fit-content;
  margin-top: auto;
}

.login-btn svg {
  width: 16px;
  height: 16px;
}

.login-btn path {
  fill: none;
  stroke: #ecfeff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button,
.launch-link {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ecfeff;
  font-family: "Outfit", sans-serif;
  font-size: 0.95rem;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
.launch-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 16px rgba(21, 128, 61, 0.35);
}

input,
textarea {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font-family: "Outfit", sans-serif;
}

input[type="color"] {
  height: 46px;
  padding: 0.2rem;
}

select {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font-family: "Outfit", sans-serif;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.auth-wrap {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(450px, 95vw);
}

.hint {
  color: var(--muted);
  display: block;
  margin-top: 0.7rem;
}

.alerts {
  margin-bottom: 1rem;
}

.alert {
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
  border: 1px solid;
}

.alert.success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.45);
}

.alert.error {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.45);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(500px, 96vw);
  border-radius: var(--radius);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  padding: 1.6rem;
  position: relative;
}

.modal-card h3 {
  margin-bottom: 0.9rem;
  padding-right: 2.5rem;
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.3);
}

.credential-row {
  margin-bottom: 1.1rem;
}

.credential-row label {
  display: inline-block;
  margin-bottom: 0.35rem;
  color: #cbd5e1;
}

.copy-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.copy-wrap button {
  min-width: 94px;
}

#service-username,
#service-password {
  margin-top: 0;
}

.copy-feedback {
  min-height: 1.2rem;
  margin: 0 0 0.7rem;
  color: var(--accent-soft);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.copy-feedback.show {
  opacity: 1;
}

.launch-link {
  margin-top: 0.3rem;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.reveal {
  animation: reveal-up 0.45s ease both;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.7rem;
}

.panel-head small {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

.filter-row {
  margin-top: 0.75rem;
  max-width: 340px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.account-service-list {
  display: grid;
  gap: 0.9rem;
}

.service-divider {
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.24);
  margin: 0.9rem 0 1rem;
}

.own-service-form {
  margin: 0;
  padding-top: 0.6rem;
}

.own-service-item {
  padding: 0.7rem 1rem;
  cursor: grab;
}

.own-service-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.own-service-item[open] {
  cursor: default;
}

.own-service-item.dragging {
  opacity: 0.55;
  border-color: rgba(134, 239, 172, 0.8);
}

.own-service-item.drag-over {
  box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.55) inset;
}

.service-summary-main {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.service-order-index {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #cbd5e1;
}

.own-service-item summary::-webkit-details-marker {
  display: none;
}

.own-service-item summary span {
  font-family: "Sora", sans-serif;
}

.own-service-item summary small {
  color: var(--muted);
  font-size: 0.82rem;
  word-break: break-all;
}

.own-service-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  vertical-align: middle;
}

.table td {
  word-break: break-word;
}

.table th {
  font-family: "Sora", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inline-form {
  margin: 0;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.action-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 500;
}

.secondary-btn {
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: #e2e8f0;
}

.secondary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 16px rgba(15, 23, 42, 0.25);
}

.danger-btn {
  background: linear-gradient(135deg, #dc2626, #be123c);
}

.danger-btn:hover {
  box-shadow: 0 10px 16px rgba(190, 18, 60, 0.3);
}

.muted-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.edit-inline-row td {
  background: rgba(15, 23, 42, 0.38);
}

.inline-form-stack {
  display: grid;
  gap: 0.55rem;
}

.inline-edit-form {
  padding: 0.6rem 0.35rem;
}

.inline-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

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

.inline-span-2 {
  grid-column: 1 / -1;
}

.inline-edit-grid input,
.inline-edit-grid select,
.inline-edit-grid textarea {
  margin-top: 0.3rem;
}

.inline-edit-actions {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.95rem 1rem;
  }

  .container {
    width: min(1100px, 96vw);
    margin: 1rem auto 2rem;
  }

  .hero,
  .panel,
  .service-card,
  .auth-card,
  .empty-state,
  .modal-card {
    padding: 1rem;
  }

  .brand {
    font-size: 0.95rem;
  }

  nav {
    width: 100%;
    gap: 0.45rem;
  }

  nav a {
    margin: 0;
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
  }

  .user-chip {
    margin: 0;
  }

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

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

  .portal-content .card-grid {
    grid-template-columns: 1fr;
  }

  .portal-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs-nav {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }

  .tab-btn {
    flex: 0 0 auto;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }

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

  .table {
    font-size: 0.9rem;
  }

  .table th,
  .table td {
    padding: 0.55rem 0.45rem;
  }

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

  .action-group {
    flex-wrap: wrap;
  }

  .action-link,
  .danger-btn,
  .secondary-btn,
  button {
    font-size: 0.88rem;
    padding: 0.55rem 0.8rem;
  }

  .own-service-item summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .own-service-actions {
    flex-wrap: wrap;
  }

  .copy-wrap {
    grid-template-columns: 1fr;
  }

  .copy-wrap button {
    width: 100%;
  }

  .modal-close {
    top: 0.45rem;
    right: 0.45rem;
  }

  .service-url {
    display: none;
  }

  .portal-list th:nth-child(3),
  .portal-list td:nth-child(3) {
    display: none;
  }

  .login-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    justify-content: center;
  }

  .login-btn span {
    display: none;
  }

  .login-btn svg {
    width: 18px;
    height: 18px;
    margin: 0;
  }
}
