:root {
  color-scheme: light;
  --ink: #14231e;
  --ink-soft: #5d6d66;
  --paper: #f4f1e9;
  --surface: #fffdf7;
  --surface-strong: #ebe8df;
  --line: rgba(20, 35, 30, 0.13);
  --green: #0d6b4d;
  --green-soft: #dcebe2;
  --blue: #1d5c91;
  --amber: #a86516;
  --red: #b23d36;
  --shadow: 0 24px 80px rgba(24, 41, 34, 0.11);
  font-family: "Bahnschrift", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(13, 107, 77, 0.1), transparent 28rem),
    linear-gradient(135deg, #edf2ee 0%, var(--paper) 48%, #eef1eb 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(20, 35, 30, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 30, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px clamp(18px, 3vw, 48px) 42px;
}

.login-view {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
}

.login-card {
  width: min(520px, 100%);
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid rgba(20, 35, 30, 0.12);
  border-radius: 34px 34px 34px 12px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
  animation: rise-in 480ms ease both;
}

.brand-lockup,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 17px;
}

.brand-icon {
  width: 74px;
  height: 74px;
  border-radius: 23px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(29, 92, 145, 0.17);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 4vw, 2.55rem);
  letter-spacing: -0.045em;
}

.login-card h1 span {
  display: inline-block;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.28rem, 2.4vw, 1.9rem);
  letter-spacing: -0.035em;
}

.login-copy {
  margin: 34px 0 28px;
  color: var(--ink-soft);
  line-height: 1.75;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input {
  min-height: 52px;
  padding: 0 16px;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(13, 107, 77, 0.11);
}

.primary-button,
.ghost-button,
.text-button,
.tab-button {
  border: 0;
}

.primary-button {
  min-height: 54px;
  margin-top: 7px;
  border-radius: 14px 14px 14px 5px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: var(--green);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.88rem;
}

.security-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 23px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: #26a875;
  box-shadow: 0 0 0 5px rgba(38, 168, 117, 0.12);
}

.dashboard-view {
  animation: fade-in 320ms ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar-icon {
  width: 54px;
  height: 54px;
  border-radius: 17px;
  object-fit: cover;
}

.topbar h1 {
  font-size: 1.55rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated-at {
  margin-right: 8px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.ghost-button,
.text-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 0.83rem;
  font-weight: 800;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
}

.text-button {
  background: transparent;
  color: var(--ink-soft);
}

.hero-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border-radius: 12px 38px 38px 38px;
  color: #fff;
  background:
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.15), transparent 18rem),
    linear-gradient(118deg, #102820, #0d6b4d 68%, #208264);
  box-shadow: var(--shadow);
}

.hero-panel .eyebrow {
  color: #9ee0c4;
}

.hero-panel h2 {
  max-width: 670px;
  line-height: 1.35;
}

.service-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 440px;
}

.service-chip {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.service-chip.off {
  color: #ffd0c8;
  border-color: rgba(255, 150, 130, 0.35);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 13px;
  margin: 18px 0 30px;
}

.metric-card {
  min-height: 132px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px 22px 22px 7px;
  background: rgba(255, 253, 247, 0.82);
  animation: rise-in 430ms ease both;
}

.metric-card:nth-child(2) { animation-delay: 40ms; }
.metric-card:nth-child(3) { animation-delay: 80ms; }
.metric-card:nth-child(4) { animation-delay: 120ms; }
.metric-card:nth-child(5) { animation-delay: 160ms; }
.metric-card:nth-child(6) { animation-delay: 200ms; }

.metric-label {
  display: block;
  min-height: 34px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.45;
}

.metric-value {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.75rem, 3vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.055em;
}

.metric-caption {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.panel-tabs {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin-bottom: 13px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.5);
}

.tab-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.tab-button.active {
  background: var(--ink);
  color: #fff;
}

.tab-badge {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 5px;
  place-items: center;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
}

.content-panel {
  min-height: 390px;
  padding: clamp(21px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px 28px 28px 28px;
  background: rgba(255, 253, 247, 0.88);
  box-shadow: 0 14px 50px rgba(24, 41, 34, 0.07);
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.search-field input {
  min-width: 250px;
  min-height: 42px;
  padding: 0 14px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 15px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--ink-soft);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(13, 107, 77, 0.045);
}

.user-cell {
  display: grid;
  gap: 3px;
}

.user-cell strong {
  font-size: 0.9rem;
}

.user-cell small,
.muted {
  color: var(--ink-soft);
}

.state-pill,
.part-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 99px;
  font-size: 0.71rem;
  font-weight: 800;
}

.state-pill.online {
  color: var(--green);
  background: var(--green-soft);
}

.state-pill.offline {
  color: var(--ink-soft);
  background: var(--surface-strong);
}

.state-pill.withdrawn {
  color: var(--red);
  background: #f6dedb;
}

.relationship-list,
.anomaly-list {
  display: grid;
  gap: 10px;
}

.relationship-row,
.anomaly-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 5px;
  background: #fff;
}

.relationship-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
}

.relationship-person {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relationship-link {
  color: var(--green);
  font-size: 1.15rem;
}

.relationship-status {
  padding: 6px 9px;
  border-radius: 99px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.relationship-status.pending {
  color: var(--amber);
  background: #f8ead3;
}

.anomaly-row {
  grid-template-columns: 11px 1fr auto;
}

.anomaly-mark {
  width: 11px;
  height: 38px;
  border-radius: 99px;
  background: var(--amber);
}

.anomaly-row.critical .anomaly-mark {
  background: var(--red);
}

.anomaly-row.notice .anomaly-mark {
  background: var(--blue);
}

.anomaly-code {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
}

.empty-state {
  padding: 70px 10px;
  color: var(--ink-soft);
  text-align: center;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 25px 10px 0;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 760px) {
  .page-shell { padding: 18px 12px 28px; }
  .topbar,
  .hero-panel,
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .updated-at { width: 100%; }
  .service-status { justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-tabs { width: 100%; overflow-x: auto; }
  .tab-button { flex: 1; white-space: nowrap; }
  .search-field,
  .search-field input { width: 100%; min-width: 0; }
  .relationship-row { grid-template-columns: 1fr auto 1fr; }
  .relationship-status { grid-column: 1 / -1; width: fit-content; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 118px; padding: 17px; }
  .topbar-actions .ghost-button,
  .topbar-actions .text-button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
