/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  font-size: 14px;
  background: #f4f6f9;
  color: #1e2533;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ────────────────────────────────────────────── */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Header ────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e3e8ef;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.header__title {
  font-size: 17px;
  font-weight: 700;
  color: #1e2533;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__title span.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: #f97316;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.header__meta {
  font-size: 12px;
  color: #6b7280;
}

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

.nav-link {
  font-size: 13px;
  color: #6b7280;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background .15s;
}
.nav-link:hover { background: #f1f5f9; color: #1e2533; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: #3b82f6; color: #fff; }
.btn-danger   { background: #ef4444; color: #fff; }
.btn-success  { background: #22c55e; color: #fff; }
.btn-outline  { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f9fafb; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e3e8ef;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  overflow: hidden;
  margin-bottom: 20px;
}

.card__header {
  padding: 14px 20px;
  border-bottom: 1px solid #e3e8ef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #fafbfc;
}
.card__header:hover { background: #f1f5f9; }

.card__title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__toggle {
  font-size: 12px;
  color: #9ca3af;
  transition: transform .2s;
}
.card.collapsed .card__toggle { transform: rotate(-90deg); }
.card.collapsed .card__body { display: none; }

.card__body { padding: 0; }

/* ── Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  background: #f8fafc;
  border-bottom: 1px solid #e3e8ef;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody tr.below-threshold { background: #fff5f5; }
tbody tr.below-threshold:hover { background: #fee2e2; }

td {
  padding: 10px 16px;
  vertical-align: middle;
}

/* ── User Cell ─────────────────────────────────────────── */
.user-cell { min-width: 160px; }
.user-name { font-weight: 500; }
.user-email { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* ── Lines Cell ────────────────────────────────────────── */
.lines-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lines-value { font-size: 15px; font-weight: 600; }
.lines-ok   { color: #1e2533; }
.lines-warn { color: #ef4444; }
.badge-warn {
  display: inline-block;
  background: #fef2f2;
  color: #ef4444;
  border: 1px solid #fca5a5;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

/* ── Sparkline ─────────────────────────────────────────── */
.sparkline-cell { min-width: 140px; }
.sparkline-wrap { display: flex; align-items: flex-end; gap: 4px; }
.sparkline-container { position: relative; }

/* ── Low Usage Section ─────────────────────────────────── */
.section-alert {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #fca5a5;
  box-shadow: 0 1px 3px rgba(239,68,68,.1);
  overflow: hidden;
  margin-bottom: 20px;
}

.section-alert__header {
  padding: 14px 20px;
  background: #fef2f2;
  border-bottom: 1px solid #fca5a5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-alert__title {
  font-size: 14px;
  font-weight: 700;
  color: #dc2626;
}

.section-alert__body { padding: 0; }

/* ── Toast / Status ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e2533;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  z-index: 9999;
  display: none;
  max-width: 320px;
}
.toast.show { display: block; animation: slideIn .2s ease; }
.toast.error { background: #dc2626; }
.toast.success { background: #16a34a; }

@keyframes slideIn {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Loading Spinner ───────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Badge / Tag ───────────────────────────────────────── */
.team-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

.company-badge {
  display: inline-block;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

.badge-active {
  display: inline-block;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

.badge-inactive {
  display: inline-block;
  background: #f3f4f6;
  color: #9ca3af;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
}

.user-inactive td {
  opacity: 0.55;
}

/* ── Company Section ───────────────────────────────────────── */
.company-section {
  margin-bottom: 28px;
}

.company-header {
  font-size: 15px;
  font-weight: 700;
  color: #1e2533;
  padding: 8px 4px 10px;
  border-bottom: 2px solid #3b82f6;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-header::before {
  content: '🏢';
  font-size: 14px;
}

.company-header--alert {
  border-bottom-color: #ef4444;
  margin-top: 8px;
}

.company-header--alert::before {
  content: '🚨';
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  background: #fee2e2;
  color: #dc2626;
}

/* ── Form ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ── Admin Layout ──────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

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

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 400px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal__title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Empty State ───────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 13px;
}

/* ── Status dot ────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.status-dot.ok     { background: #22c55e; }
.status-dot.error  { background: #ef4444; }
.status-dot.unknown{ background: #9ca3af; }
