:root {
  --bg: #f1f4f8;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;
  --line: rgba(148, 163, 184, 0.28);
  --text: #111827;
  --muted: #64748b;
  --primary: #0071e3;
  --primary-2: #0a84ff;
  --success: #047857;
  --danger: #b91c1c;
  --shadow-sm: 0 8px 22px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 22px 44px rgba(15, 23, 42, 0.14);
  --radius-lg: 22px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--text);
  background:
    radial-gradient(64rem 44rem at 8% -12%, #dfeeff 0%, transparent 50%),
    radial-gradient(56rem 38rem at 100% 0%, #eaf3ff 0%, transparent 48%),
    linear-gradient(180deg, #f7f9fc, var(--bg));
}

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: #f8fbff;
  backdrop-filter: blur(12px);
  background: linear-gradient(115deg, #0a1b32 0%, #114178 52%, #0a84ff 100%);
  box-shadow: 0 14px 26px rgba(7, 22, 42, 0.34);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.34);
}

.title-wrap h1 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.012em;
}

.title-wrap p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.topbar-meta { display: inline-flex; gap: 8px; }

.date-chip,
.env-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.74rem;
  font-weight: 700;
}

.date-chip {
  color: rgba(248, 251, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.env-chip {
  color: #d9fee8;
  border: 1px solid rgba(208, 255, 230, 0.4);
  background: rgba(22, 163, 74, 0.38);
}

.container {
  max-width: 1380px;
  margin: 20px auto;
  padding: 0 16px 26px;
}

.live-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #35506a;
  font-size: 0.8rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.refresh-note {
  color: var(--muted);
  font-size: 0.74rem;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.65);
}

.live-toggle {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.last-updated {
  margin-left: auto;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  padding: 13px 14px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 3px;
}

.stat-card strong {
  font-size: 1.62rem;
  letter-spacing: -0.02em;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  padding: 16px;
}

.card-main {
  min-height: 420px;
  position: relative;
  isolation: isolate;
}

.card-head {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.04rem;
  letter-spacing: -0.014em;
}

.card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.primary-cta {
  position: relative;
  z-index: 7;
  height: 38px;
  border-radius: 11px;
  border: none;
  color: #fff;
  font-weight: 700;
  padding: 0 14px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  box-shadow: 0 8px 18px rgba(0, 113, 227, 0.28);
  cursor: pointer;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 260px;
}

input,
select,
button {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 11px;
  font: inherit;
}

input,
select {
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
}

input:focus,
select:focus {
  outline: none;
  border-color: #7fb6ff;
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.16);
}

button {
  border: none;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  cursor: pointer;
}

button.secondary {
  background: linear-gradient(180deg, #7d8ea1, #647487);
}

button.issue {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
}

button.success {
  background: linear-gradient(180deg, #22c55e, #16a34a);
}

button.lost {
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

button.edit {
  background: linear-gradient(180deg, #8b5cf6, #7c3aed);
}

button.danger {
  background: linear-gradient(180deg, #ef4444, #dc2626);
}

button.small {
  height: 30px;
  min-width: 54px;
  font-size: 0.73rem;
  padding: 0 9px;
}

.table-headline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}

#logCount {
  font-size: 0.8rem;
  font-weight: 700;
  color: #35516c;
}

.table-wrap {
  position: relative;
  z-index: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.mobile-table-hint {
  display: none;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.table-wrap.is-refreshing tbody { opacity: 0.66; }

.table-wrap.is-refreshing::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, rgba(214, 226, 241, 0.42) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: sweep 1.2s linear infinite;
}

@keyframes sweep { to { transform: translateX(100%); } }

table {
  width: 100%;
  min-width: 930px;
  border-collapse: collapse;
  font-size: 0.79rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f7fd;
  color: #415a73;
  font-size: 0.73rem;
  text-transform: uppercase;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #e5edf7;
  text-align: left;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: #fbfdff; }
tbody tr:hover { background: #f3f8ff; }

th.sticky-col-left,
td.sticky-col-left {
  position: sticky;
  left: 0;
}

th.sticky-col-right,
td.sticky-col-right {
  position: sticky;
  right: 0;
}

th.sticky-col-left {
  z-index: 4;
  box-shadow: 1px 0 0 #dce7f4;
}

th.sticky-col-right {
  z-index: 4;
  box-shadow: -1px 0 0 #dce7f4;
}

td.sticky-col-left,
td.sticky-col-right {
  z-index: 2;
  background: #fff;
}

tbody tr:nth-child(even) td.sticky-col-left,
tbody tr:nth-child(even) td.sticky-col-right { background: #fbfdff; }

tbody tr:hover td.sticky-col-left,
tbody tr:hover td.sticky-col-right { background: #f3f8ff; }

td.sticky-col-left { box-shadow: 1px 0 0 #e5edf7; }
td.sticky-col-right { box-shadow: -1px 0 0 #e5edf7; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border: 1px solid transparent;
}

.badge.issued { background: #e7f8ff; color: #155f7f; border-color: #b9e8ff; }
.badge.returned { background: #e9fcef; color: #116b49; border-color: #b3efca; }
.badge.lost { background: #fff1f5; color: #9d2040; border-color: #ffc8d7; }
.badge.unknown { background: #f2f6fb; color: #43566b; border-color: #d0dbe7; }

.action-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 280px;
}

.table-state {
  margin: 8px 2px 0;
  min-height: 20px;
  font-size: 0.78rem;
  color: var(--muted);
}

.table-state.error { color: var(--danger); }
.table-state.empty { color: #4a5e73; }
.table-state.loading { color: #355b84; }

.active-filters {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.active-filters.has-filters { display: flex; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  border: 1px solid #cfe0f3;
  background: #eef5ff;
  color: #365372;
  font-size: 0.73rem;
  font-weight: 700;
}

.filter-chip-remove {
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #9cc3ed;
  background: rgba(255, 255, 255, 0.78);
  color: #1f4368;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.page-info {
  min-width: 110px;
  text-align: center;
  color: #4b6078;
  font-size: 0.8rem;
  font-weight: 700;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-jump input {
  width: 84px;
  height: 34px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
}

.modal-overlay.open { display: flex; }

.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 28px 54px rgba(15, 23, 42, 0.28);
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid #d3dfec;
  background: #fff;
  color: #475569;
  font-size: 1rem;
  cursor: pointer;
}

.modal-desc {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.79rem;
  color: #34506a;
}

.full { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; }

.result {
  margin-top: 10px;
  min-height: 18px;
  font-size: 0.82rem;
  color: var(--primary);
}

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

@media (max-width: 1240px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-actions {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-headline {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: auto 1fr;
    row-gap: 10px;
    padding: 12px 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.82rem;
  }

  .title-wrap h1 { font-size: 1rem; }
  .title-wrap p { font-size: 0.76rem; }

  .topbar-meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .container {
    margin-top: 12px;
    padding: 0 10px 18px;
  }

  .live-bar {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .last-updated {
    margin-left: 0;
    width: 100%;
  }

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

  .card { padding: 12px; }

  .card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-cta {
    width: 100%;
    height: 42px;
  }

  .filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-actions {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }

  input,
  select,
  button {
    height: 42px;
    font-size: 16px;
  }

  .action-cell {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }

  .action-cell .small {
    width: auto;
    min-width: 52px;
    height: 30px;
    font-size: 0.72rem;
    padding: 0 8px;
  }

  /* 모바일에서는 sticky 컬럼을 해제해 내용 가림 방지 */
  thead th:first-child,
  tbody td:first-child,
  thead th:last-child,
  tbody td:last-child {
    position: static;
    left: auto;
    right: auto;
    z-index: auto;
    background: inherit;
  }

  .mobile-table-hint { display: block; }

  table { min-width: 760px; }

  .pagination {
    justify-content: stretch;
  }

  .pagination > * {
    flex: 1 1 auto;
  }

  .page-jump {
    flex: 2 1 auto;
  }

  .page-jump input {
    width: 100%;
  }

  .modal {
    width: 100%;
    max-height: 100dvh;
    border-radius: 16px;
    padding: 14px;
  }

  .modal .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-actions { grid-template-columns: 1fr; }
  .pagination { gap: 6px; }
  .page-info { min-width: 0; }
}
