:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f3f7f6;
  --ink: #171a1f;
  --muted: #68717d;
  --line: #e1e6ea;
  --line-strong: #cdd6dd;
  --accent: #0f8b72;
  --accent-dark: #096b58;
  --accent-soft: #e5f6f2;
  --cyan: #147c96;
  --cyan-soft: #e5f5f8;
  --danger: #c7353f;
  --danger-soft: #fdecee;
  --warn-bg: #fff7df;
  --warn-line: #e2b94d;
  --shadow: 0 12px 30px rgba(20, 34, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(15, 139, 114, 0.10), transparent 32%),
    linear-gradient(180deg, #fbfcfd 0%, var(--bg) 260px);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
  word-break: break-word;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

.button.secondary,
button.secondary {
  border-color: var(--line);
  background: #f4f7f8;
  color: var(--ink);
}

.button.secondary:hover,
button.secondary:hover {
  background: #e8eef1;
}

.button.danger-button,
button.danger-button {
  background: var(--danger);
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 8px 10px;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 114, 0.14);
  outline: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
  line-height: 1.35;
}

form {
  margin: 0;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.header-copy p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 0 13px;
  font-weight: 700;
}

.page-shell,
.login-shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.page-shell {
  display: grid;
  gap: 18px;
  padding-bottom: 44px;
}

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

.login-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 26px;
}

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

.surface,
.metric-card,
.watch-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.surface {
  padding: 20px;
}

.notice,
.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
}

.notice {
  border: 1px solid #9ed8cb;
  background: var(--accent-soft);
}

.alert {
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
}

.eyebrow,
.metric-label,
.subtle,
.muted,
.empty-text {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.subtle,
.muted,
.empty-text {
  font-size: 13px;
}

.error {
  color: var(--danger);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 18px;
}

.metric-card strong {
  font-size: 32px;
  line-height: 1;
}

.metric-card p {
  margin: 0;
  color: var(--muted);
}

.metric-card.danger-soft {
  background: var(--danger-soft);
  border-color: #f3c7cc;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 180px;
}

.bar-column {
  display: grid;
  gap: 8px;
  align-items: end;
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: flex-end;
  height: 118px;
  border-radius: var(--radius);
  background: #eef3f5;
  overflow: hidden;
}

.bar-track span {
  display: block;
  width: 100%;
  height: var(--bar);
  min-height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(180deg, var(--cyan), var(--accent));
}

.bar-column strong {
  font-size: 14px;
}

.bar-column em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.meter-list {
  display: grid;
  gap: 16px;
}

.meter-row {
  display: grid;
  gap: 8px;
}

.meter-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  background: #edf2f4;
  overflow: hidden;
}

.meter-track span {
  display: block;
  width: var(--bar);
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(280px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.store-form,
.target-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.store-form button,
.target-form button {
  align-self: end;
}

.store-list {
  display: grid;
  gap: 12px;
}

.store-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.store-item p {
  margin-bottom: 4px;
}

.store-edit-form,
.target-edit-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

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

.config-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.config-list p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

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

.button-stack {
  display: grid;
  gap: 10px;
}

.button-stack button {
  width: 100%;
}

.watch-section {
  display: grid;
  gap: 14px;
}

.watch-list {
  display: grid;
  gap: 14px;
}

.watch-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.watch-card.paused {
  background: #fbfcfc;
}

.watch-main {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, auto);
  gap: 14px;
  align-items: start;
}

.watch-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.watch-title h3 {
  margin: 0;
  font-size: 18px;
}

.watch-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.watch-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.watch-meta-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.watch-meta-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.watch-meta-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.watch-url {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.watch-url a,
.watch-url span {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f9fa;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.chip.success {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.chip.neutral {
  background: #eef2f4;
  color: var(--muted);
}

.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.foldout-grid {
  display: grid;
  gap: 10px;
}

.foldout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.foldout.slim {
  padding: 10px;
}

.foldout summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.target-product-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.target-product-grid {
  margin-top: 12px;
}

.product-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  min-height: 124px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

.product-card img,
.no-image {
  width: 92px;
  height: 92px;
  border-radius: var(--radius);
  object-fit: cover;
  background: #e9edf0;
}

.no-image {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.product-card h3,
.product-card p {
  margin-bottom: 6px;
}

.product-actions {
  margin-top: 10px;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, auto);
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.event-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.event-item p {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .metric-grid,
  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-grid,
  .watch-main {
    grid-template-columns: 1fr;
  }

  .watch-actions {
    justify-content: flex-start;
  }
}

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

  .header-actions {
    justify-content: flex-start;
  }

  .metric-grid,
  .setup-grid,
  .store-form,
  .target-form,
  .target-edit-form,
  .watch-meta-grid,
  .event-item {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    gap: 8px;
  }
}
