:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --line: #e2e8f0;
  --muted: #64748b;
  --text: #0f172a;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #087f5b;
  --green-soft: #e8f6ef;
  --rose: #b42318;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Pretendard",
    "Noto Sans KR",
    "Apple SD Gothic Neo",
    "Malgun Gothic",
    Arial,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-login-page {
  min-height: 100vh;
  background: var(--bg);
}

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

.login-panel {
  width: min(100%, 390px);
}

.login-heading {
  margin-bottom: 24px;
  text-align: center;
}

.eyebrow,
.sidebar-brand p,
.metric-card p,
.section-title span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-heading h1 {
  margin: 8px 0;
  font-size: 28px;
  line-height: 1.2;
}

.login-heading p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form,
.form-panel,
.section-block,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 10px;
  padding: 24px;
}

label span,
.login-form label {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid #cfd6e3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(39, 93, 232, 0.14);
}

.form-error {
  margin: 2px 0 0;
  color: var(--rose);
  font-size: 13px;
  font-weight: 700;
}

.primary-button,
.outline-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.outline-button {
  border-color: var(--line);
  background: #fff;
  color: #2d3648;
}

.outline-button:hover {
  background: #eef2f8;
}

.small {
  min-height: 38px;
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  padding: 16px;
}

.sidebar-brand {
  display: grid;
  gap: 3px;
  padding: 0 8px;
}

.sidebar-brand span {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-brand small {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-nav a {
  border-radius: 6px;
  color: #334155;
  display: block;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
}

.sidebar-nav a span {
  margin-right: 8px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: #e2e8f0;
  color: #0f172a;
}

#logout-button {
  margin-top: auto;
}

.admin-main {
  min-width: 0;
  overflow-x: hidden;
  padding: 32px;
}

.loading-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 24px;
  color: var(--muted);
  font-weight: 800;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  color: #0f172a;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.25;
}

.page-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.metric-card {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.metric-card strong {
  display: inline-block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric-card span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 16px;
}

.section-block {
  min-width: 0;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}

.section-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.inline-link {
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
}

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

.table-panel {
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
  background: #fff;
}

.admin-table-full .col-status {
  width: 10%;
}

.admin-table-full .col-name {
  width: 15%;
}

.admin-table-full .col-phone {
  width: 17%;
}

.admin-table-full .col-source {
  width: 18%;
}

.admin-table-full .col-date {
  width: 18%;
}

.admin-table-full .col-referrer {
  width: 22%;
}

.admin-table-compact .col-name {
  width: 18%;
}

.admin-table-compact .col-phone {
  width: 20%;
}

.admin-table-compact .col-source {
  width: 20%;
}

.admin-table-compact .col-date {
  width: 25%;
}

.admin-table-compact .col-status {
  width: 17%;
}

.admin-table th {
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 20px;
  text-align: left;
}

.admin-table td {
  border-bottom: 1px solid #e5e7eb;
  color: #334155;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  padding: 12px 20px;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.name-cell {
  color: #1e293b;
  font-weight: 700;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.phone-cell,
.date-cell {
  white-space: nowrap;
}

.date-cell,
.muted-cell {
  color: #64748b;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  padding: 4px 8px;
}

.empty-cell,
.empty-panel {
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 16px;
  padding: 16px;
}

.filter-bar label,
.utm-form label {
  display: grid;
  gap: 6px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.bar-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebf3;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #0f9f78);
}

.daily-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(28px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 210px;
  padding: 22px 18px 18px;
}

.daily-column {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.daily-bar {
  width: 100%;
  max-width: 26px;
  border-radius: 4px 4px 0 0;
  background: var(--blue);
}

.form-panel {
  padding: 18px;
}

.utm-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
}

.utm-form label:first-child,
.utm-form .full {
  grid-column: 1 / -1;
}

.url-output {
  min-height: 44px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
  font-size: 13px;
}

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

.settings-item {
  display: grid;
  gap: 8px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.settings-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.settings-item strong {
  color: #1f2937;
  font-size: 15px;
  overflow-wrap: anywhere;
}

@media (max-width: 920px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .sidebar-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  #logout-button {
    margin-top: 0;
  }

  .admin-main {
    padding: 18px;
  }

  .kpi-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar,
  .utm-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .table-panel {
    border-radius: 12px;
  }

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

  .admin-table colgroup,
  .admin-table thead {
    display: none;
  }

  .admin-table tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .admin-table tr:last-child {
    border-bottom: 0;
  }

  .admin-table td {
    align-items: center;
    border-bottom: 0;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 6px 0;
    text-align: right;
  }

  .admin-table td::before {
    color: #64748b;
    content: attr(data-label);
    flex: 0 0 86px;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
  }

  .phone-cell,
  .date-cell {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .page-header {
    display: grid;
  }

  .metric-card strong {
    font-size: 26px;
  }
}
