*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #0f0f13;
  color: #e8e8f0;
  min-height: 100vh;
}

/* ── Login ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.card {
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .5rem;
  letter-spacing: -.01em;
}

h1 span { color: #6495ED; }

.login-desc {
  font-size: .85rem;
  color: #666;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .4rem;
}

input[type="password"] {
  width: 100%;
  padding: .65rem 1rem;
  background: #111118;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  color: #e8e8f0;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}

input[type="password"]:focus { border-color: #6495ED; }

.error {
  color: #f87171;
  font-size: .83rem;
  margin-top: .5rem;
  display: none;
}

button {
  margin-top: 1.25rem;
  width: 100%;
  padding: .8rem;
  background: #6495ED;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

button:hover { background: #4a7add; }
button:active { transform: scale(.98); }

/* ── Dashboard layout ── */
.dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #1a1a24;
  border-bottom: 1px solid #2a2a3a;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-left h1 { font-size: 1.2rem; margin-bottom: 0; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  font-size: .85rem;
  color: #888;
  text-decoration: none;
  transition: color .2s;
}
.back-link:hover { color: #e8e8f0; }

.logout-btn {
  margin-top: 0;
  width: auto;
  padding: .4rem .9rem;
  font-size: .82rem;
  background: #2a2a3a;
}
.logout-btn:hover { background: #3a3a4f; }

.main {
  flex: 1;
  padding: 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #6495ED;
  line-height: 1;
  margin-bottom: .4rem;
}

.stat-label {
  font-size: .78rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Section ── */
.section {
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #2a2a3a;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.refresh-btn {
  margin-top: 0;
  width: auto;
  padding: .4rem .9rem;
  font-size: .82rem;
  background: #2a2a3a;
}
.refresh-btn:hover { background: #3a3a4f; }

.loading, .empty {
  padding: 2rem;
  text-align: center;
  color: #555;
  font-size: .9rem;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

thead tr {
  border-bottom: 1px solid #2a2a3a;
}

th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

td {
  padding: .85rem 1rem;
  border-bottom: 1px solid #1e1e2a;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #1e1e2a; }

.code-badge {
  font-family: monospace;
  font-size: .82rem;
  background: #111118;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  padding: .2rem .5rem;
  color: #8ab3f3;
}

.link-label {
  font-weight: 600;
  color: #e8e8f0;
  margin-bottom: .2rem;
}

.link-url {
  font-size: .78rem;
  color: #555;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-count {
  font-weight: 700;
  color: #6495ED;
}

.date-text {
  font-size: .82rem;
  color: #666;
  white-space: nowrap;
}

.action-btns {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

.btn-detail {
  margin-top: 0;
  width: auto;
  padding: .3rem .7rem;
  font-size: .78rem;
  background: #2a2a3a;
}
.btn-detail:hover { background: #3a3a4f; }

.btn-delete {
  margin-top: 0;
  width: auto;
  padding: .3rem .7rem;
  font-size: .78rem;
  background: #3d1f1f;
  color: #f87171;
}
.btn-delete:hover { background: #521a1a; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal-overlay.is-open { display: flex; }

.modal {
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 60px rgba(0,0,0,.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #2a2a3a;
  flex-shrink: 0;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  margin-top: 0;
  width: auto;
  padding: .25rem .5rem;
  font-size: .9rem;
  background: #2a2a3a;
  line-height: 1;
}
.modal-close:hover { background: #3a3a4f; }

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-link-info {
  background: #111118;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .83rem;
}

.modal-link-info .info-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .3rem;
}
.modal-link-info .info-row:last-child { margin-bottom: 0; }
.modal-link-info .info-key {
  color: #555;
  min-width: 60px;
  flex-shrink: 0;
}
.modal-link-info .info-val {
  color: #aaa;
  word-break: break-all;
}

/* ── Chart ── */
.chart-wrap {
  background: #111118;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: .85rem 1rem .5rem;
  margin-bottom: 1rem;
}

.chart-label {
  font-size: .75rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .6rem;
}

.scan-chart {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Scans list ── */
.scans-list { display: flex; flex-direction: column; gap: .5rem; }

.scan-item {
  background: #111118;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: .65rem .85rem;
  font-size: .8rem;
}

.scan-item-date {
  color: #8ab3f3;
  font-weight: 600;
  margin-bottom: .2rem;
}

.scan-item-meta {
  color: #555;
  word-break: break-word;
}

.no-scans {
  text-align: center;
  color: #555;
  font-size: .88rem;
  padding: 1rem 0;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .topbar { padding: 1rem; }
  .main { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr; }
  .link-url { max-width: 160px; }
}
