:root {
  --bg: #f4f6ef;
  --panel: rgba(255, 255, 255, 0.82);
  --ink: #1f2532;
  --ink-muted: #63708a;
  --accent: #0f766e;
  --line: #d7decc;
  --shadow: 0 14px 35px rgba(31, 37, 50, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #edf5f3 0%, transparent 45%),
    linear-gradient(160deg, #fdf4f0 0%, #f4f6ef 55%, #eef4f8 100%);
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(30px);
  z-index: -1;
  opacity: 0.5;
}

.bg-shape-1 {
  width: 280px;
  height: 280px;
  background: #99f6e4;
  top: -50px;
  left: -80px;
}

.bg-shape-2 {
  width: 340px;
  height: 340px;
  background: #fecdd3;
  right: -140px;
  bottom: -90px;
}

.app-shell {
  width: min(1220px, 94vw);
  margin: 32px auto;
  display: grid;
  gap: 16px;
}
.top-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.6vw, 2.7rem);
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.72rem;
}

.subtitle { margin: 8px 0 0; color: var(--ink-muted); }
.summary-panel {
  display: grid;
  gap: 10px;
}
.summary-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.summary-head h2 { margin: 0; font-size: 1rem; }
.summary-head p { margin: 0; color: var(--ink-muted); font-size: 0.84rem; }

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.topbar-kpis {
  width: 100%;
  margin-top: 4px;
}

.kpi-card {
  background: #fbfcf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.kpi-card p { margin: 0; color: var(--ink-muted); font-size: 0.88rem; }
.kpi-card strong { display: block; margin-top: 8px; font-size: 1.4rem; }
.kpi-danger {
  background: #fff1f2;
  border-color: #fecdd3;
}

.kpi-warn {
  background: #fff7ed;
  border-color: #fdba74;
}

.controls-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 10px;
}
.controls-row-secondary {
  grid-template-columns: minmax(180px, 1fr) minmax(300px, 1.25fr) minmax(220px, 1fr);
  margin-top: 10px;
}
.control { display: grid; gap: 4px; font-size: 0.86rem; color: var(--ink-muted); }
.role-control { min-width: 180px; }

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-control input {
  width: auto;
  margin: 0;
}

input, select, button { font: inherit; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: white;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.table-meta h2 { margin: 0; font-size: 1.04rem; }
#tableCount { margin: 0; color: var(--ink-muted); font-size: 0.88rem; }

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
  table-layout: fixed;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid #e8edde;
  text-align: left;
  font-size: 0.9rem;
}

th { color: var(--ink-muted); font-weight: 500; }
.th-sub { font-size: 0.78rem; font-weight: 500; }

.col-vendor { width: 13%; }
.col-product { width: 21%; }
.col-type { width: 9%; }
.col-qty { width: 11%; }
.col-renewal { width: 11%; }
.col-status { width: 12%; }
.col-risk { width: 13%; }
.col-account { width: 11%; }
.col-action { width: 10%; }

td { word-break: break-word; }
.col-risk-wrap { white-space: normal; }

.archive-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #b8c4d6;
}

.archive-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.archive-head h3 {
  margin: 0;
  font-size: 0.98rem;
  color: #475569;
}

.archive-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #334155;
  background: #e2e8f0;
}

.archive-policy-help {
  margin: 10px 0 0;
  color: #475569;
  font-size: 0.82rem;
}
.security-controls {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
}
.refresh-controls {
  border: 1px solid var(--line);
  background: #f8faf7;
  border-radius: 12px;
  padding: 10px;
}
.refresh-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.refresh-meta {
  margin: 8px 0 2px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
}
.refresh-help {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}
.sensitive-status {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}
.sensitive-status.is-locked { color: #9f1239; }
.sensitive-status.is-unlocked { color: #166534; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, #0f766e 0%, #be185d 100%);
}

.btn-ghost { background: #eef2e7; }
.btn-mini { padding: 5px 9px; font-size: 0.78rem; background: #eef2e7; }
.btn-security {
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 600;
}
.btn-danger {
  background: #be123c;
  color: #fff;
}
.btn-warn-soft {
  background: #fff1dc;
  border: 1px solid #f3c37f;
  color: #9a3412;
}

.license-dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(980px, 96vw);
  padding: 18px;
  max-height: 88vh;
  overflow: auto;
}

.license-dialog::backdrop { background: rgba(31, 37, 50, 0.48); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.dialog-head h3 { margin: 0; }

#licenseForm {
  display: grid;
  gap: 12px;
}

.form-layout {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr;
  gap: 12px;
}

.form-section {
  border: 1px solid #d9e1d0;
  border-radius: 12px;
  background: #fbfcf8;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.form-section h4 {
  margin: 0;
  font-size: 0.92rem;
}

.form-section-danger {
  background: #fff8ef;
  border-color: #f6d7a9;
}
.danger-help {
  margin: -2px 0 0;
  color: #9a3412;
  font-size: 0.78rem;
}
.dialog-danger-zone {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.form-grid label {
  display: grid;
  gap: 5px;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.form-check { align-self: end; color: var(--ink); }

.form-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dialog-actions {
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 24%);
  padding-top: 10px;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-active { background: #dcfce7; color: #166534; }
.status-watch { background: #fff7cc; color: #854d0e; }
.status-warning { background: #ffedd5; color: #9a3412; }
.status-expired { background: #fee2e2; color: #991b1b; }
.flag-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 4px;
  margin-bottom: 4px;
}

.flag-badge.flag-renewal_missing {
  background: #ffedd5;
  color: #9a3412;
}

.flag-badge.flag-credential_missing {
  background: #fee2e2;
  color: #991b1b;
}

.flag-badge.flag-other {
  background: #e2e8f0;
  color: #334155;
}

.account-cell {
  min-width: 140px;
}

.account-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px dashed #fca5a5;
  border-radius: 8px;
  background: #fff1f2;
  color: #9f1239;
  font-size: 0.78rem;
  font-weight: 600;
}

.account-open {
  color: #334155;
  font-family: "Noto Sans KR", sans-serif;
  font-size: 0.84rem;
}

.security-note {
  width: min(1220px, 94vw);
  margin: -6px auto 20px;
  color: #475569;
  font-size: 0.82rem;
}
.security-dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(460px, 94vw);
  padding: 16px;
}
.security-dialog::backdrop { background: rgba(31, 37, 50, 0.48); }
.security-dialog h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.security-warning {
  margin: 0 0 12px;
  font-size: 0.84rem;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 8px 10px;
}
.security-error {
  margin: 8px 0 0;
  color: #b91c1c;
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .top-overview { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .controls-row { grid-template-columns: 1fr; }
  .controls-row-secondary { grid-template-columns: 1fr; }
  .security-controls { align-items: start; flex-direction: column; }
  .refresh-controls-head { flex-wrap: wrap; }
  .refresh-controls .btn-mini { width: 100%; }
  .summary-head { flex-direction: column; align-items: flex-start; }
  .license-dialog { padding: 12px; max-height: 92vh; }
  .form-layout { grid-template-columns: 1fr; gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-inline-actions { flex-direction: column; align-items: stretch; }
  .form-inline-actions .btn { width: 100%; }
  .dialog-danger-zone { flex-direction: column; }
  .dialog-head { align-items: flex-start; }
  .dialog-head .btn { padding: 8px 12px; }
  .dialog-actions .btn { width: 100%; }
  .security-note { margin-top: 0; }
  table { min-width: 760px; }
}
