:root {
  --page-bg: #f4efe6;
  --page-bg-soft: #fffaf2;
  --surface: rgba(255, 250, 242, 0.88);
  --surface-strong: #fffdf8;
  --surface-accent: #f4e3cc;
  --text: #2d241d;
  --muted: #786757;
  --border: rgba(123, 92, 61, 0.18);
  --border-strong: rgba(123, 92, 61, 0.3);
  --primary: #d06b2f;
  --primary-strong: #b84f17;
  --primary-soft: #f9dfc8;
  --danger: #bf3f34;
  --danger-soft: #f7d5d0;
  --link: #185a72;
  --shadow: 0 24px 60px rgba(120, 84, 48, 0.12);
  --shadow-soft: 0 12px 28px rgba(120, 84, 48, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--page-bg);
  font-family: "Space Grotesk", "Avenir Next", "PingFang SC", sans-serif;
}

.page {
  position: relative;
  padding: 36px 28px 48px;
  max-width: 1240px;
  margin: 0 auto;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 14%, rgba(243, 190, 107, 0.22), transparent 34%),
    radial-gradient(circle at 82% 16%, rgba(80, 141, 153, 0.18), transparent 32%),
    radial-gradient(circle at 48% 88%, rgba(208, 107, 47, 0.14), transparent 28%),
    linear-gradient(180deg, #fffaf2 0%, #f4efe6 52%, #efe5d7 100%);
  z-index: -1;
}

h1, h2 { margin: 0; letter-spacing: -0.04em; }
h1 { font-size: clamp(2rem, 4vw, 3.3rem); line-height: 0.96; }
h2 { font-size: 1.2rem; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--primary-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted { color: var(--muted); font-size: 0.95rem; line-height: 1.55; }

.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 248, 238, 0.88));
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.auth-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.auth-card-title { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.04em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 6px 4px 4px;
}

.hero-copy { display: grid; gap: 14px; max-width: 720px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.form { display: grid; gap: 14px; }

label { display: grid; gap: 8px; font-size: 0.92rem; font-weight: 600; color: var(--text); }

input[type="password"] {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input[type="date"] {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
}

input:focus {
  outline: none;
  border-color: rgba(208, 107, 47, 0.5);
  box-shadow: 0 0 0 4px rgba(208, 107, 47, 0.12);
}

button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff8f1;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  box-shadow: 0 10px 22px rgba(208, 107, 47, 0.24);
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.58; transform: none; box-shadow: none; }

button.ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}

.error {
  min-height: 20px;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: #9d2f25;
  background: rgba(247, 213, 208, 0.72);
}

.error:empty { display: none; }

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

/* Dashboard-specific */
.admin-login-card {
  max-width: 420px;
  margin: 80px auto;
  padding: 32px 30px 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 26px;
}

.stat-card { padding: 24px; text-align: center; }
.stat-label { color: var(--muted); font-size: 0.88rem; margin-bottom: 8px; }
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--primary-strong);
}

.chart-panel { margin-top: 22px; padding: 24px; }
.chart-container { position: relative; height: 320px; }
.user-list-panel { margin-top: 22px; padding: 24px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

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

.user-table th,
.user-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.user-table th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.user-table tbody tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center !important;
  color: var(--muted);
}

.link-email {
  color: var(--muted);
  white-space: nowrap;
}

.link-created-at {
  white-space: nowrap;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 90, 114, 0.1);
  color: var(--link);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.share-link:hover {
  text-decoration: underline;
}

.list-summary {
  margin-top: 16px;
}

select {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

@media (max-width: 940px) { .dashboard-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .table-wrap {
    overflow-x: visible;
    border: none;
    background: transparent;
  }

  .user-table {
    min-width: 0;
  }

  .user-table thead {
    display: none;
  }

  .user-table,
  .user-table tbody,
  .user-table tr,
  .user-table td {
    display: block;
    width: 100%;
  }

  .user-table tbody {
    display: grid;
    gap: 12px;
  }

  .user-table tr {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.48);
  }

  .user-table td {
    padding: 0;
    border-bottom: none;
  }

  .user-table td + td {
    margin-top: 10px;
  }

  .user-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .table-empty::before {
    content: none !important;
  }

  .link-email,
  .link-created-at,
  .share-link {
    white-space: normal;
    word-break: break-word;
  }
}

@media (max-width: 520px) { .dashboard-grid { grid-template-columns: 1fr; } }
