/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2d3148;
  --accent:    #6c63ff;
  --accent-h:  #5a52e0;
  --danger:    #e05252;
  --success:   #52c782;
  --warning:   #e0a852;
  --text:      #e8eaf0;
  --muted:     #8890a8;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-nav { flex: 1; padding: 0 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-footer {
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
}

/* ── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.topbar h2 { font-size: 1.3rem; font-weight: 700; }
.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .78rem;
}
.back-link { color: var(--muted); font-size: .9rem; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card h3 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Form ───────────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.flex-3 { flex: 3; min-width: 200px; }
.flex-2 { flex: 2; min-width: 140px; }
.flex-1 { flex: 1; min-width: 100px; }
.field-btn { flex-shrink: 0; }

input[type="text"],
input[type="url"],
input[type="password"],
input[type="email"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 12px;
  font-size: .88rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
input.disabled-input { opacity: .5; cursor: not-allowed; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); text-decoration: none; color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface2); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; text-decoration: none; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Table ──────────────────────────────────────────────────────────────── */
.links-table {
  width: 100%;
  border-collapse: collapse;
}
.links-table th {
  text-align: left;
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
}
.links-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.links-table tr:last-child td { border-bottom: none; }
.links-table tr:hover td { background: var(--surface2); }
.center { text-align: center; }

.code-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: .82rem;
  color: var(--accent);
}
.generated-link {
  font-size: .82rem;
  font-family: monospace;
  max-width: 260px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.link-cell { display: flex; align-items: center; gap: 6px; }
.target-url {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .82rem;
}
.clicks {
  background: var(--surface2);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: .8rem;
  font-weight: 600;
}
.action-btns { display: flex; gap: 6px; justify-content: center; }
.inline-form { display: inline; }
.form-inline-tight {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.quick-actions-wrap { display: inline-block; text-align: left; }
.mini-input {
  width: auto;
  min-width: 95px;
  padding: 5px 8px;
  font-size: .8rem;
}
.danger-text { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: .88rem;
}
.alert-success { background: rgba(82,199,130,.12); border: 1px solid rgba(82,199,130,.3); color: var(--success); }
.alert-error   { background: rgba(224, 82, 82,.12); border: 1px solid rgba(224,82,82,.3);  color: var(--danger);  }
.alert-warning { background: rgba(224,168,82,.12); border: 1px solid rgba(224,168,82,.3); color: var(--warning); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  gap: 16px;
  text-align: center;
}

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(108,99,255,.15) 0%, transparent 70%),
              var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  color: var(--accent);
  margin-bottom: 12px;
}
.login-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--muted); margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-block { margin-top: 8px; }

/* ── Refund pages ───────────────────────────────────────────────────────── */
.refund-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 100% 0%, rgba(108,99,255,.15) 0%, transparent 60%),
              radial-gradient(ellipse at 0% 100%, rgba(82,199,130,.10) 0%, transparent 60%),
              var(--bg);
}

.refund-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.refund-head h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.refund-head p {
  color: var(--muted);
  margin-bottom: 18px;
}

.refund-info {
  display: grid;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 18px;
}

.refund-form .field { margin-bottom: 14px; }

.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.refund-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main { padding: 20px 14px; }

  .links-table {
    display: block;
    overflow-x: auto;
  }

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

/* ── Unlock display ────────────────────────────────────────────────────────── */
.unlock-data {
  display: grid;
  gap: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.data-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.data-field label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
}

.data-value {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  color: var(--text);
  font-family: monospace;
  word-break: break-all;
}

/* ── Metadata grid ─────────────────────────────────────────────────────────── */
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metadata-item {
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.metadata-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
}

.metadata-item code {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px;
  border-radius: 4px;
  overflow-x: auto;
}

/* ── Card input ─────────────────────────────────────────────────────────── */
.card-input-wrap {
  position: relative;
}
.card-input-wrap input {
  padding-right: 44px;
  letter-spacing: 0.1em;
}
.card-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
