:root {
  --daewool-primary: #2f6d4f;
  --daewool-primary-dark: #173f30;
  --daewool-accent: #d5a748;
  --daewool-surface: #f4f7f5;
  --daewool-line: #dfe8e2;
  --tblr-primary: #2f6d4f;
  --tblr-primary-rgb: 47, 109, 79;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  color: #26352d;
  background: var(--daewool-surface);
}

.admin-shell .navbar-vertical {
  background: linear-gradient(170deg, #173f30 0%, #102f24 70%, #0d261d 100%);
  border: 0;
  box-shadow: 8px 0 30px rgba(23, 63, 48, .08);
}

.navbar-brand a,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 12px 4px 12px 4px;
  background: linear-gradient(135deg, #e8c568, var(--daewool-accent));
  box-shadow: 0 8px 18px rgba(213, 167, 72, .22);
  color: #173f30;
  font-size: 19px;
  font-weight: 900;
}

.admin-shell .navbar-brand {
  height: auto;
  padding-block: 23px 14px;
  font-size: 18px;
  letter-spacing: -.02em;
}

.admin-shell .navbar-nav {
  gap: 4px;
}

.admin-shell .nav-link {
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255, 255, 255, .72);
  font-weight: 650;
}

.admin-shell .nav-item.active .nav-link,
.admin-shell .nav-link:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.admin-shell .nav-item.active .nav-link {
  box-shadow: inset 3px 0 var(--daewool-accent);
}

.nav-link-icon {
  display: grid;
  place-items: center;
}

.menu-icon,
.metric-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: center / contain no-repeat;
}

.menu-icon-home { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 11l9-8 9 8v9a1 1 0 01-1 1h-5v-7H9v7H4a1 1 0 01-1-1z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.menu-icon-notice { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 5h14v14H5zM8 9h8M8 13h6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.menu-icon-media { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M8 13l2-2 3 3 2-2 3 3M8 9h.01' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.menu-icon-send { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22 2L11 13M22 2l-7 20-4-9-9-4z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.menu-icon-users { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='9' cy='8' r='3' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M3 20v-2a5 5 0 0110 0v2M16 4a3 3 0 010 6M15 13a5 5 0 016 5v2' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.menu-icon-chart { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 19V9M10 19V5M16 19v-7M22 19H2' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.menu-icon-key { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='15' r='4' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M11 12l9-9M17 6l3 3M14 9l3 3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  padding: 20px 8px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .92);
}

.sidebar-account-copy {
  display: grid;
  min-width: 0;
}

.sidebar-account-copy small {
  overflow: hidden;
  color: rgba(255, 255, 255, .55);
  text-overflow: ellipsis;
}

.admin-toolbar {
  min-height: 73px;
  border-bottom: 1px solid var(--daewool-line);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
}

.admin-toolbar .container-xl,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-body {
  margin-top: 0;
  padding-block: 31px 42px;
}

.page-body > .container-xl > h1 {
  margin: 0 0 24px;
  color: #193328;
  font-size: clamp(25px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -.04em;
}

.panel {
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--daewool-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(33, 67, 50, .055);
}

.panel > h1,
.panel > h2,
.panel-heading h2 {
  margin-top: 0;
  color: #203a2e;
  letter-spacing: -.025em;
}

.panel-heading {
  margin: -2px 0 16px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

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

.metrics article {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
  padding: 21px;
  border: 1px solid var(--daewool-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(33, 67, 50, .05);
}

.metrics article:nth-child(2) .metric-icon { color: #bc7d24; background-color: #bc7d24; }
.metrics article:nth-child(3) .metric-icon { color: #4674a5; background-color: #4674a5; }
.metrics article:nth-child(4) .metric-icon { color: #7255a6; background-color: #7255a6; }

.metric-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  padding: 11px;
  border-radius: 12px;
  color: var(--daewool-primary);
  background-color: var(--daewool-primary);
}

.metrics article > div {
  display: grid;
}

.metrics strong {
  color: #183a2a;
  font-size: 28px;
  line-height: 1.15;
}

.metrics span:not(.metric-icon) {
  color: #718078;
  font-size: 13px;
  font-weight: 650;
}

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

.stack label,
.filter label {
  display: grid;
  gap: 6px;
  color: #3b4d43;
  font-weight: 650;
}

input,
textarea,
select,
button {
  font: inherit;
}

input:not([type="checkbox"]):not([type="hidden"]),
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #cfdad3;
  border-radius: 8px;
  background: #fff;
  color: #26352d;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #72a78c;
  outline: 3px solid rgba(47, 109, 79, .1);
}

textarea {
  resize: vertical;
}

button:not(.navbar-toggler):not(.btn):not(.link-button) {
  min-height: 40px;
  padding: 9px 15px;
  border: 0;
  border-radius: 8px;
  background: var(--daewool-primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

button.danger {
  background: #b54742;
}

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

.check {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #edf1ee;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #718078;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .035em;
  text-align: center;
  text-transform: uppercase;
}

.users-table {
  min-width: 1080px;
  table-layout: fixed;
}

.users-table th:nth-child(1) { width: 16%; }
.users-table th:nth-child(2) { width: 8%; }
.users-table th:nth-child(3) { width: 37%; }
.users-table th:nth-child(4),
.users-table th:nth-child(5) { width: 19.5%; }

tbody tr:hover {
  background: #f8faf9;
}

.provider-badge,
.state-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f0;
  color: #53645a;
  font-size: 12px;
  font-weight: 700;
}

.state-active {
  background: #e6f5eb;
  color: #267444;
}

.state-blocked,
.state-withdrawn {
  background: #faeceb;
  color: #a33d38;
}

.empty-row {
  padding-block: 34px;
  color: #839088;
  text-align: center;
}

.member-link {
  display: grid;
  color: var(--daewool-primary);
  text-decoration: none;
}

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

.member-link span {
  color: #718078;
  font-size: 13px;
  font-weight: 400;
}

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

.detail-grid div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 10px;
  background: #f7f9f8;
}

.detail-grid dt {
  color: #718078;
  font-size: 12px;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.location-panel { margin-top: 24px; }
.pairing-code-panel { margin-top: 24px; }
.pairing-code-actions { display: flex; align-items: center; gap: 18px; }
.pairing-code-result { display: grid; grid-template-columns: auto auto; align-items: center; gap: 2px 12px; padding: 12px 16px; border-radius: 10px; background: #f1f7f3; }
.pairing-code-qr { grid-row: 1 / 4; width: 180px; height: 180px; border-radius: 8px; background: #fff; }
.pairing-code-result span { color: #718078; font-size: 12px; font-weight: 650; }
.pairing-code-result strong { color: #173f30; font-size: 24px; letter-spacing: .12em; }
.pairing-code-result small { grid-column: 1 / -1; color: #718078; }
.location-devices { display: grid; gap: 16px; }
.location-device { padding: 16px; border: 1px solid var(--daewool-line); border-radius: 12px; }
.location-device-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.location-device-head small { display: block; margin-top: 4px; color: #718078; overflow-wrap: anywhere; }
.location-status { min-height: 24px; margin: 12px 0; color: #718078; }
.location-status[data-status="completed"] { color: #16794b; }
.location-status[data-status="send_failed"],
.location-status[data-status="expired"],
.location-status[data-status="permission_denied"] { color: #b42318; }
.location-map { width: 100%; min-height: 360px; overflow: hidden; border-radius: 10px; background: #eef1f4; }
.location-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 0; }
.location-meta div { padding: 10px 12px; border-radius: 8px; background: #f7f9f8; }
.location-meta dt { color: #718078; font-size: 12px; }
.location-meta dd { margin: 3px 0 0; font-weight: 600; }

.inline-form,
.filter {
  display: flex;
  align-items: end;
  gap: 9px;
}

.inline-form input,
.inline-form select {
  flex: 1 1 0;
  min-width: 105px;
}

.inline-form button {
  flex: 0 0 auto;
  min-width: 68px;
  white-space: nowrap;
}

.filter label {
  min-width: 150px;
}

.filter label:has(select) {
  flex: 1;
}

.error,
.warning {
  padding: 13px 15px;
  border: 1px solid #f1d5bf;
  border-radius: 9px;
  background: #fff6ee;
  color: #7c4227;
}

.status {
  font-size: 12px;
  color: #a33d38;
}

.status.ok {
  color: #267444;
}

.logout {
  margin: 0;
}

.login-shell {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 10%, #fff 0, #f1f6f3 42%, #e6eee9 100%);
}

.login-main {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-brand {
  justify-content: center;
  margin-bottom: 20px;
  color: #193f2f;
  font-size: 21px;
}

.login-panel {
  margin: 0 auto;
  padding: 30px;
  box-shadow: 0 22px 60px rgba(33, 67, 50, .12);
}

.login-panel h1 {
  margin-bottom: 8px;
  text-align: center;
}

.login-panel > p:not(.error) {
  margin-bottom: 24px;
  color: #718078;
  text-align: center;
}

@media (min-width: 992px) {
  .admin-shell .navbar-vertical .navbar-collapse {
    min-height: calc(100vh - 75px);
  }
}

@media (max-width: 991.98px) {
  .admin-shell .navbar-vertical {
    background: #173f30;
  }

  .admin-shell .navbar-brand {
    padding-block: 10px;
  }

  .admin-shell .navbar-brand .brand-mark {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 16px;
  }

  .sidebar-account {
    margin-top: 12px;
  }
}

@media (max-width: 800px) {
  .page-body {
    padding-top: 22px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .filter {
    align-items: stretch;
    flex-direction: column;
  }

  .pairing-code-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .pairing-code-result {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .pairing-code-qr,
  .pairing-code-result small {
    grid-column: 1;
  }
}

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

  .panel {
    padding: 18px;
  }
}
