/* MaskingStudio 라이선스 발급 웹 — 디자인 시스템 */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e2e5ec;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --text-faint: #9aa1b1;

  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0fe;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fdeded;

  --success: #16a34a;
  --success-soft: #eafbf0;

  --warning: #d97706;
  --warning-soft: #fef6e7;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Apple SD Gothic Neo",
    "Noto Sans KR", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171923;
    --surface-2: #1e212c;
    --border: #2a2e3a;
    --text: #eceef2;
    --text-muted: #9ba1b0;
    --text-faint: #6b7280;

    --brand: #818cf8;
    --brand-hover: #a5b4fc;
    --brand-soft: rgba(129, 140, 248, 0.14);

    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: rgba(248, 113, 113, 0.12);

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);

    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: 1.05rem;
  margin: 2rem 0 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

/* ---------- 레이아웃 ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.4rem;
  gap: 1.25rem;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text) !important;
  text-decoration: none !important;
  font-size: 0.95rem;
  white-space: nowrap;
}
.brand img {
  height: 24px;
  width: 24px;
  object-fit: contain;
  border-radius: 5px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  row-gap: 0.3rem;
  gap: 0.25rem;
  flex: 1 1 auto;
}

.nav-links a {
  color: var(--text-muted) !important;
  text-decoration: none !important;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav-links a:hover {
  background: var(--surface-2);
  color: var(--text) !important;
}
.nav-links a.active {
  background: var(--brand-soft);
  color: var(--brand) !important;
}

.nav-divider {
  width: 1px;
  align-self: stretch;
  margin: 0.35rem 0.35rem;
  background: var(--border);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.user-menu .help-link {
  color: var(--text-muted) !important;
  text-decoration: none !important;
  font-size: 0.85rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
}
.user-menu .help-link:hover,
.user-menu .help-link[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text) !important;
}

.user-menu .username {
  font-size: 0.85rem;
  color: var(--text-muted);
}

main.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
}

.container-bare {
  max-width: none;
  padding: 0;
}
.container-bare .flash {
  max-width: 380px;
  margin: 1.5rem auto 0;
}

/* ---------- 카드 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.card + .card {
  margin-top: 1rem;
}

/* ---------- 인증 화면 ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2rem;
}

.auth-card .brand {
  display: flex;
  justify-content: center;
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
}
.auth-card .brand img {
  height: 32px;
  width: 32px;
}

.auth-card h1 {
  font-size: 1.15rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-card p.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin: -0.75rem 0 1.25rem;
}

/* ---------- 폼 ---------- */

form p {
  margin: 0 0 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 4.5rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input[type="checkbox"] {
  width: auto;
  margin-right: 0.4rem;
  accent-color: var(--brand);
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  color: var(--text);
  margin-right: 1.25rem;
}

/* 검색/필터 바 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar label {
  margin-bottom: 0.3rem;
}
.filter-bar input,
.filter-bar select {
  min-width: 140px;
}
.filter-bar > * {
  flex: 0 0 auto;
}

/* ---------- 버튼 ---------- */

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
  text-decoration: none !important;
}
button:hover,
.btn:hover {
  background: var(--brand-hover);
  color: #fff;
}
button:active,
.btn:active {
  transform: translateY(1px);
}
button:disabled,
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 0.15em solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.15em;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 17, 26, 0.55);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-box {
  background: var(--surface);
  border-radius: 0.6rem;
  padding: 1.5rem;
  width: min(480px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.modal-box h2 {
  margin-top: 0;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text) !important;
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

form.inline {
  display: inline;
}

/* ---------- 알림 ---------- */

.flash {
  padding: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.flash.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
.flash.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}
.flash.warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: var(--warning);
  font-weight: 600;
}

/* ---------- 테이블 ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  white-space: nowrap;
}

th, td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

/* 단순 정보 테이블(상세 페이지 key-value) */
table.kv td:first-child,
table.kv th {
  color: var(--text-muted);
  font-weight: 600;
  width: 160px;
  white-space: normal;
}
table.kv td {
  white-space: normal;
}

/* ---------- 상태 배지 ---------- */

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge-success {
  background: var(--success-soft);
  color: var(--success);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

/* ---------- 탭 ---------- */

.tab-nav {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 0;
  box-shadow: none;
}
.tab-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.tab-btn.is-active {
  color: var(--brand);
  border-bottom: 2px solid var(--brand);
}

.text-faint {
  color: var(--text-faint);
}

/* ---------- 빈 상태 ---------- */

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.section-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.helper-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}
