:root {
  --bg: #f5f7fc;
  --panel: #ffffff;
  --line: #edf1f7;
  --text: #263247;
  --muted: #7d8796;
  --brand: #0a4a8f;
  --brand-dark: #083a71;
  --brand-soft: #eef5fd;
  --header: #0a4a8f;
  --header-dark: #083a71;
  --badge: #eef5fd;
  --badge-text: #0a4a8f;
  --active-bg: #eef5fd;
  --active-text: #0a4a8f;
  --done-bg: #e8fff0;
  --done-text: #1ea35f;
  --fail-bg: #fff0f0;
  --fail-text: #e25a5a;
  --wait-bg: #f0f3f7;
  --wait-text: #708096;
  --danger: #de5d5d;
  --shadow: 0 18px 48px rgba(83, 96, 123, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  font-size: 15px;
  background: linear-gradient(180deg, #fbfcff 0%, #f2f5fb 100%);
}

.top-nav {
  border-bottom: 1px solid #dfe5ef;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.top-nav-inner {
  width: min(1760px, calc(100vw - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 86px;
}

.top-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--brand);
  font-size: 20px;
  font-weight: 900;
  justify-self: start;
}

.top-nav-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
  flex: 0 0 auto;
  display: block;
}

.top-nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-self: center;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 168px;
  padding: 0 22px;
  border: 1px solid #dde3ef;
  color: #5b6880;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}

.top-nav-link.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.top-nav-spacer {
  min-height: 1px;
}

/* ── 개선된 헤더 ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.site-header-inner {
  max-width: 1760px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #1e293b;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  flex-shrink: 0;
}
.site-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.site-brand-text {
  letter-spacing: -0.3px;
}
.site-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.site-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.site-nav-link:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.site-nav-link.is-active {
  background: #eff6ff;
  color: #1e66f5;
  font-weight: 600;
}
.site-nav-link.is-active svg {
  stroke: #1e66f5;
}
.site-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
}
.user-chip-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-chip-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.user-chip-name {
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
}
.user-chip-role {
  color: #64748b;
  font-size: 11px;
}
.logout-form {
  margin: 0;
}
.btn-logout, .btn-login, .btn-signup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-logout, .btn-login {
  background: #fff;
  color: #475569;
  border-color: #cbd5e1;
}
.btn-logout:hover, .btn-login:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}
.btn-signup {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.25);
}
.btn-signup:hover {
  background: linear-gradient(135deg, #15803d, #14532d);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(22, 163, 74, 0.3);
}

/* ── 햄버거 메뉴 (모바일 전용) ── */
.hamburger-btn {
  display: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 0px;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  position: relative;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.hamburger-btn:hover {
  background: transparent;
  border: 0px;
}
.hamburger-btn.is-open {
  background: transparent;
  border: 0px;
}
.hamburger-btn span {
  display: block;
  position: absolute;
  height: 2px;
  width: 22px;
  background: #1e293b;
  border-radius: 2px;
  transition: all 0.3s ease;
  left: 50%;
  margin-left: -11px;
}
.hamburger-btn span:nth-child(1) { top: 14px; }
.hamburger-btn span:nth-child(2) { top: 21px; }
.hamburger-btn span:nth-child(3) { top: 28px; }
.hamburger-btn.is-open span:nth-child(1) {
  top: 21px;
  transform: rotate(45deg);
}
.hamburger-btn.is-open span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.is-open span:nth-child(3) {
  top: 21px;
  transform: rotate(-45deg);
}

/* 모바일 사이드 메뉴 (드로어) */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: min(320px, 88vw);
  background: #fff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.1);
  overflow-y: auto;
  z-index: 99;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
}
.mobile-drawer.is-open {
  transform: translateX(0);
}
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.2s;
}
.mobile-drawer-overlay.is-open {
  opacity: 1;
}
.mobile-drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.mobile-drawer-section:last-child {
  border-bottom: 0;
}
.mobile-drawer-title {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-left: 6px;
}
.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 6px;
  color: #334155;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s;
}
.mobile-drawer-link:hover, .mobile-drawer-link.is-active {
  background: #eff6ff;
  color: #1e66f5;
  font-weight: 600;
}
.mobile-drawer-link .md-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}
.mobile-drawer-link .md-sub {
  margin-left: auto;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}
/* ★ 도구 하위메뉴 (모바일 드로어) — PC 사이드바와 동일 비주얼 */
.mobile-drawer-submenu {
  margin: 6px 0 10px;
  padding: 0;
  /* 너비 명시 — 드로어 폭 따라가서 오버플로 방지 */
  max-width: 100%;
  overflow-x: hidden;
}
.mobile-drawer-subcat {
  padding: 10px 12px 4px 12px;
  color: #0a4a8f;             /* PC 사이드바와 동일 (브랜드 블루) */
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.mobile-drawer-sublink {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 14px;     /* 좌측 여백 살짝 → 카테고리 안에 들어간 느낌 */
  color: #475569;
  font-size: 13px;
  text-decoration: none;
  border-left: 3px solid transparent;  /* PC 와 동일 — active 시 왼쪽에 색 막대 */
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  /* 텍스트 잘림 방지 */
  min-width: 0;
}
.mobile-drawer-sublink:hover {
  background: #f1f5f9;
  color: #1e293b;
}
.mobile-drawer-sublink.is-active {
  background: #eff6ff;
  color: #1e66f5;
  border-left-color: #1e66f5;
  font-weight: 600;
}
.mobile-drawer-sublink .md-icon {
  width: 14px;
  text-align: center;
  color: #cbd5e1;
  font-size: 11px;
  flex-shrink: 0;
}
/* 도구명 텍스트 — 길면 ellipsis */
.mobile-drawer-sublink > span:not(.md-icon):not(.tool-badge) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 배지 (HOT/NEW) — 우측 고정 + 크기 축소 */
.mobile-drawer-sublink .tool-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 9px !important;
  font-weight: 700;
  padding: 1px 5px !important;
  letter-spacing: 0.3px;
}
.mobile-drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 10px;
}
.mobile-drawer-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.mobile-drawer-user-name {
  color: #1e293b;
  font-size: 14px;
  font-weight: 700;
}
.mobile-drawer-user-role {
  color: #64748b;
  font-size: 11px;
  margin-top: 1px;
}
.mobile-drawer-pending-badge {
  display: inline-flex;
  align-items: center;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
  margin-left: 6px;
}

@media (max-width: 900px) {
  .site-header-inner {
    padding: 0 14px;
    gap: 10px;
  }
  .site-brand-text {
    font-size: 16px;
  }
  /* 데스크탑 메뉴 + 액션 영역 숨김 */
  .site-nav,
  .site-actions {
    display: none !important;
  }
  /* 햄버거 노출 */
  .hamburger-btn {
    display: inline-flex !important;
  }
  /* 드로어 노출 (열렸을 때) */
  .mobile-drawer {
    display: block;
  }
  .mobile-drawer-overlay.is-open {
    display: block;
  }
}

/* ── 도구 허브 레이아웃 ── */
.tool-hub-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
  background: #f8fafc;
}
.tool-hub-sidebar {
  background: #fff;
  border-right: 1px solid #e2e8f0;
  padding: 16px 0;
  overflow-y: auto;
}
.tool-hub-sidebar-head {
  padding: 6px 16px 12px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 8px;
}
.tool-cat { margin-bottom: 12px; }
.tool-cat-title {
  padding: 8px 16px 4px;
  color: #0a4a8f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.tool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px 7px 20px;
  color: #475569;
  font-size: 13px;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.1s;
}
.tool-item:hover { background: #f1f5f9; color: #1e293b; }
.tool-item.is-active {
  background: #eff6ff;
  color: #1e66f5;
  border-left-color: #1e66f5;
  font-weight: 600;
}
.tool-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  letter-spacing: 0.3px;
}
.tool-badge-hot { background: #fee2e2; color: #dc2626; }
.tool-badge-new { background: #dcfce7; color: #166534; }
.tool-badge-best { background: #dbeafe; color: #1e40af; }
.tool-soon { font-size: 10px; color: #94a3b8; }
.tool-hub-main {
  padding: 28px 32px;
}
.tool-hub-title {
  margin: 0 0 16px;
  color: #0f172a;
  font-size: 22px;
  font-weight: 700;
}
.tool-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 20px;
}
.tool-intro { color: #64748b; font-size: 14px; }
.tool-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.tool-quick-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 14px;
  text-decoration: none;
  color: #1e293b;
  transition: all 0.1s;
  position: relative;
}
.tool-quick-card:hover { border-color: #1e66f5; box-shadow: 0 2px 8px rgba(30, 102, 245, 0.12); }
.tool-quick-card strong { display: block; font-size: 14px; font-weight: 600; }
.tool-quick-card span { display: block; color: #94a3b8; font-size: 11px; margin-top: 2px; }
.tool-quick-card em { position: absolute; top: 10px; right: 10px; font-style: normal; }
.stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px 16px;
  text-align: center;
}
.stat-label { color: #64748b; font-size: 12px; margin-bottom: 4px; }
.stat-val { color: #0a4a8f; font-size: 20px; font-weight: 700; }

/* ── 관리자 드롭다운 메뉴 ── */
.admin-dropdown {
  position: relative;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid #e2e8f0;
}
.admin-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1px solid #dc2626;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.admin-dropdown-btn:hover, .admin-dropdown-btn.is-active {
  background: #dc2626;
  color: #fff;
}
.admin-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.15s;
  z-index: 100;
}
.admin-dropdown:hover .admin-dropdown-menu,
.admin-dropdown:focus-within .admin-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.admin-dropdown-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 4px;
  padding: 10px 14px;
  color: #1e293b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
}
.admin-dropdown-item:last-child { border-bottom: 0; }
.admin-dropdown-item:hover { background: #f8fafc; }
.admin-dropdown-item.is-active { background: #eff6ff; color: #1e66f5; }
.admin-icon { font-size: 16px; text-align: center; grid-column: 1; }
.admin-dropdown-item > span:nth-child(2) { grid-column: 2; }
.admin-sub {
  grid-column: 2 / 4;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
  margin-top: 1px;
}

@media (max-width: 900px) {
  .site-header-inner { padding: 0 14px; gap: 12px; }
  .user-chip-meta { display: none; }
  .site-nav-link { padding: 6px 10px; font-size: 13px; }
  .site-nav-link svg { display: none; }
  .admin-dropdown { margin-left: 0; padding-left: 6px; }
}

body.modal-open {
  overflow: hidden;
}

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

.page-shell {
  width: min(1720px, calc(100vw - 48px));
  margin: 22px auto 38px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--header);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar h1,
.modal-head h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1.05;
}

.toolbar-actions,
.modal-actions {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--header), var(--header-dark));
}

.btn-secondary {
  color: var(--text);
  background: #edf1f8;
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #d65555, #ee7d7d);
}

.table-panel {
  overflow: hidden;
  border: 1px solid #dde3ef;
  border-radius: 0;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.table-toolbar,
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
}

.table-toolbar {
  border-bottom: 1px solid #e7edf5;
}

.table-toolbar-form,
.table-toolbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.table-toolbar-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.page-size-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.page-size-field select {
  min-width: 90px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #dde3ef;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 90px minmax(200px, 1.4fr) minmax(140px, 1fr) 70px 80px 95px 95px 85px 90px 90px minmax(160px, 1fr) 48px;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
}

.table-head {
  color: #fff;
  background: linear-gradient(135deg, var(--header), var(--header-dark));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.table-head span {
  white-space: nowrap;
}

.table-head em,
.table-head i {
  font-style: normal;
  opacity: 0.85;
  margin-left: 3px;
  font-size: 10px;
}

.table-head i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #ff4747;
  vertical-align: middle;
}

.table-row {
  min-height: 52px;
  border-top: 1px solid #eef2f7;
  background: #fff;
  font-size: 13px;
  transition: background 0.15s;
}

.table-row:hover {
  background: #f8fafc;
}

.table-row:nth-child(odd) {
  background: #fbfcff;
}
.table-row:nth-child(odd):hover {
  background: #f1f5f9;
}

.live-status-row {
  display: none;
  padding: 8px 16px !important;
  background: #f1f5f9 !important;
  border-top: 1px solid #dbe3ef !important;
  font-size: 12px !important;
}

.cell {
  min-width: 0;
}

.cell strong,
.cell span {
  display: block;
}

.product-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 0;
  background: var(--badge);
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.url-cell strong,
.small-cell strong,
.date-cell strong,
.count-cell strong,
.amount-cell strong,
.memo-cell strong {
  font-size: 13px;
  font-weight: 600;
}

.url-cell span,
.cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.small-cell,
.date-cell,
.count-cell,
.amount-cell,
.status-cell {
  white-space: nowrap;
}

.url-cell strong,
.memo-cell strong {
  word-break: break-word;
  line-height: 1.4;
  font-size: 12px;
}

.keyword-cell span {
  margin-top: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.keyword-cell span + span {
  margin-top: 2px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.status-running,
.status-starting {
  color: var(--active-text);
  background: var(--active-bg);
}

.status-completed {
  color: var(--done-text);
  background: var(--done-bg);
}

.status-queued {
  color: #8a5b00;
  background: #fff1c7;
}

.status-error {
  color: var(--fail-text);
  background: var(--fail-bg);
}

.status-idle,
.status-stopped,
.status-stopping {
  color: var(--wait-text);
  background: var(--wait-bg);
}

.action-cell {
  display: flex;
  justify-content: center;
}

.row-menu {
  position: relative;
}

.row-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0;
  color: #5c6879;
  list-style: none;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  user-select: none;
}

.row-menu summary::-webkit-details-marker {
  display: none;
}

.row-menu[open] summary {
  background: #eef2f8;
}

.row-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: grid;
  gap: 8px;
  min-width: 120px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  box-shadow: 0 12px 32px rgba(48, 57, 77, 0.16);
}

.menu-action {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: #eef2f8;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.table-pagination {
  border-top: 1px solid var(--line);
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #dde3ef;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.pager-btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pager-current {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.menu-action.danger {
  color: var(--danger);
  background: #fff0f0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(26, 31, 42, 0.42);
  backdrop-filter: blur(5px);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(1060px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 24px;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 24px 72px rgba(54, 66, 91, 0.2);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}

.order-modal {
  width: min(1320px, 100%);
}

.order-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.9fr);
  gap: 24px;
}

.order-modal-grid > * {
  min-width: 0;
}

.order-form-panel,
.order-info-panel {
  border: 1px solid var(--line);
  background: #fff;
}

.order-form-panel {
  padding: 24px;
}

.order-info-panel {
  padding: 20px;
}

.order-section {
  display: grid;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.order-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.section-head {
  display: grid;
  gap: 6px;
}

.section-head h3 {
  margin: 0;
  color: #12325f;
  font-size: 20px;
  font-weight: 800;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

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

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

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-full {
  grid-column: 1 / -1;
}

.field span {
  color: #5a667a;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #dde3ef;
  border-radius: 0;
  background: #fff;
  padding: 14px 16px;
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 110px;
}

.slot-check-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

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

.choice-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 6px 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid #dde3ef;
  background: #fff;
  cursor: pointer;
  min-width: 0;
}

.choice-card input {
  margin: 0;
  grid-row: 1 / span 2;
}

.choice-title {
  color: #12325f;
  font-size: 16px;
  font-weight: 800;
  min-width: 0;
}

.choice-copy {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.slot-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #dde3ef;
  background: #fff;
  cursor: pointer;
  min-width: 0;
}

.slot-check input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.slot-check span {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 0;
  background: #eef2f8;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.info-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.info-tab {
  min-height: 44px;
  border: 1px solid #d9e1f0;
  background: #fff;
  color: #225cb5;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.info-tab.is-active {
  border-color: #0f53c9;
  background: #0f53c9;
  color: #fff;
}

.info-sheet {
  display: grid;
  gap: 18px;
}

.info-sheet[hidden] {
  display: none !important;
}

.info-table {
  border: 1px solid #dfe5ef;
  background: #fff;
}

.info-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid #eef2f7;
}

.info-row:first-child {
  border-top: 0;
}

.info-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.summary-box {
  display: grid;
  gap: 8px;
  padding: 18px 16px;
  border: 1px solid #dfe5ef;
  background: #f8fbff;
}

.summary-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-amount {
  color: #0f53c9;
  font-size: 30px;
  font-weight: 900;
}

.description-copy,
.notice-list {
  display: grid;
  gap: 12px;
  color: #7d8ea8;
  font-size: 14px;
  line-height: 1.8;
}

.description-copy p,
.notice-list p {
  margin: 0;
}

.qna-board {
  border: 1px solid #dfe5ef;
  background: #fff;
}

.qna-head,
.qna-row summary {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 90px 96px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.qna-head {
  border-bottom: 1px solid #eef2f7;
  color: #6f7d93;
  font-size: 13px;
  font-weight: 800;
}

.qna-row {
  border-top: 1px solid #eef2f7;
}

.qna-row:first-of-type {
  border-top: 0;
}

.qna-row summary {
  list-style: none;
  cursor: pointer;
}

.qna-row summary::-webkit-details-marker {
  display: none;
}

.qna-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.qna-row span {
  color: var(--muted);
  font-size: 13px;
}

.qna-answer {
  padding: 16px;
  border-top: 1px solid #eef2f7;
  background: #f8fbff;
  color: #53627a;
  font-size: 14px;
  line-height: 1.8;
}

.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;
}

.rank-search-page {
  display: grid;
  gap: 20px;
}

.rank-hero-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid #d9e5f4;
  background: linear-gradient(135deg, #edf4fb 0%, #f8fbff 46%, #edf4fb 100%);
}

.rank-hero-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.82) 10%, transparent 10.5%, transparent 28%, rgba(255, 255, 255, 0.6) 28.5%, transparent 29%) 0 0 / 320px 320px,
    linear-gradient(125deg, rgba(10, 74, 143, 0.05) 12%, transparent 12.5%, transparent 34%, rgba(255, 255, 255, 0.4) 34.5%, transparent 35%) 140px 40px / 360px 360px;
  pointer-events: none;
}

.rank-hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 44px 20px 40px;
}

.rank-hero-inner h1 {
  margin: 0;
  color: #0f172a;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  letter-spacing: -0.5px;
}

.rank-hero-inner p {
  margin: 0 0 16px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
  max-width: 720px;
  line-height: 1.55;
}

.rank-search-row {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.rank-input-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 50px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
}

.rank-input-shell input {
  width: 100%;
  height: 100%;
  border: 0 !important;
  outline: none;
  box-shadow: none;
  background: transparent;
  padding: 0 16px;
  color: #1e293b;
  font: inherit;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
}

.rank-input-shell input::placeholder {
  color: #94a3b8;
}

.rank-input-shell input:focus,
.rank-input-shell input:active,
.rank-input-shell input:focus-visible {
  outline: none;
  box-shadow: none;
}

.rank-input-shell:focus-within {
  border-color: #0a4a8f;
  box-shadow: 0 0 0 3px rgba(10, 74, 143, 0.12);
}

.rank-input-with-button input {
  padding-right: 80px;
}

.rank-search-submit {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  min-width: 66px;
  height: 38px;
  padding: 0 16px;
  border: 0;
  background: #0a4a8f;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.rank-search-submit:hover {
  background: #083a72;
}

.rank-notice,
.rank-alert {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 10px 16px;
  border: 1px solid #dbe8fb;
  background: #f4f9ff;
  color: #1e40af;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.rank-alert {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.rank-result-panel {
  display: grid;
  gap: 20px;
}

.rank-list-summary {
  color: #183153;
  font-size: 15px;
  font-weight: 800;
}

.rank-result-table {
  overflow: hidden;
  border: 1px solid #d9e5f4;
  background: #fff;
}

.rank-result-head,
.rank-result-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 0.8fr;
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
}

.rank-result-head {
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.rank-result-row {
  border-top: 1px solid #f2f4f8;
  color: #1f2937;
  font-size: 16px;
  font-weight: 600;
}

.rank-result-row:first-of-type {
  border-top: 0;
}

.rank-result-row span:last-child {
  color: var(--brand);
  font-weight: 800;
}

.rank-result-empty {
  padding: 64px 24px;
  color: #1f2937;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.website-result-list {
  display: grid;
  gap: 16px;
}

.place-result-list {
  display: grid;
  gap: 16px;
}

.website-result-card,
.place-result-card {
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.website-result-card:hover,
.place-result-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.website-result-card.is-site {
  border-left: 3px solid #60a5fa;
}

.website-result-card.is-exact {
  border-left: 3px solid #0a4a8f;
  background: linear-gradient(90deg, #f4f9ff 0%, #fff 30%);
}

.website-result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.place-result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.website-result-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.website-rank-badge,
.website-match-badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.website-rank-badge {
  background: #0a4a8f;
  color: #fff;
}

.website-match-badge {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.website-result-meta-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
}

.website-result-meta-inline span {
  padding: 2px 8px;
  background: #f1f5f9;
}

.website-result-body {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.place-result-body {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.website-result-body h2 {
  margin: 0;
  color: #0f172a;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.place-result-body h2 {
  margin: 0;
  color: #0f172a;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.website-site-name,
.website-display-url {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.website-result-link {
  color: #0a4a8f;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
  text-decoration: none;
  margin-top: 2px;
}

.website-result-link:hover {
  text-decoration: underline;
}

.website-result-description {
  margin: 6px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.rank-result-table {
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.rank-result-head,
.rank-result-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr 0.8fr;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
}

.rank-result-head {
  background: #0a4a8f;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.rank-result-row {
  border-top: 1px solid #f1f5f9;
  color: #1e293b;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.rank-result-row:hover {
  background: #f8fafc;
}

.rank-result-row span:last-child {
  color: #0a4a8f;
  font-weight: 700;
}

.rank-result-empty {
  padding: 56px 24px;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.rank-list-summary {
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  padding: 0 4px;
}

.rank-result-controls {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.rank-pager {
  display: flex;
  align-items: center;
  gap: 18px;
}

.rank-page-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: #a3acb9;
  font-size: 32px;
  line-height: 1;
}

.rank-page-arrow.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.rank-page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #dbe7f4;
  background: #f7fbff;
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
}

.rank-page-size-form select {
  min-width: 92px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d8dee7;
  background: #fff;
  color: #445166;
  font: inherit;
  font-size: 16px;
}

.rank-meta-text {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #6b7789;
  font-size: 14px;
  font-weight: 700;
}

.rank-detail-card {
  width: min(760px, 100%);
  padding: 20px;
  border: 1px solid #d9e5f4;
  background:
    linear-gradient(135deg, rgba(248, 251, 255, 0.96) 0%, rgba(241, 246, 252, 0.98) 52%, rgba(250, 252, 255, 0.96) 100%);
}

.rank-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.rank-detail-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 36px;
  padding: 0 14px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 18px;
  font-weight: 900;
}

.rank-detail-card.is-missing .rank-detail-badge {
  background: #fff4df;
  color: #b27600;
}

.rank-detail-card.is-error .rank-detail-badge {
  background: #fff1f1;
  color: #cc4a4a;
}

.rank-detail-card h2 {
  margin: 0;
  color: #152437;
  font-size: 28px;
  line-height: 1.2;
}

.rank-detail-subtitle {
  margin: 10px 0 0;
  color: #617083;
  font-size: 14px;
  line-height: 1.6;
}

.rank-detail-lines {
  display: grid;
  gap: 0;
  margin-top: 24px;
  border-top: 1px solid #e1eaf4;
}

.rank-detail-line {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #e1eaf4;
}

.rank-detail-line strong {
  color: #5b6880;
  font-size: 14px;
  font-weight: 800;
}

.rank-detail-line span {
  color: #1c2a3d;
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
  line-height: 1.6;
}

.rank-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.rank-detail-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  background: #ffffff;
  border: 1px solid #d9e5f4;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.flash-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
}

.flash {
  padding: 14px 16px;
  border-radius: 0;
  box-shadow: 0 14px 28px rgba(47, 61, 88, 0.14);
  font-size: 14px;
  font-weight: 700;
}

.flash-success {
  background: #eff9f2;
  color: #1e8c52;
}

.flash-error {
  background: #fff1f1;
  color: #d44d4d;
}

@media (max-width: 1680px) {
  .table-panel {
    overflow-x: auto;
  }

  .table-head,
  .table-row {
    min-width: 1715px;
  }
}

@media (max-width: 1024px) {
  .toolbar {
    flex-direction: column;
  }

  .form-grid-4,
  .form-grid-3,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

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

  .choice-grid,
  .order-modal-grid,
  .info-tabs {
    grid-template-columns: 1fr;
  }

  .table-toolbar,
  .table-pagination,
  .table-toolbar-form,
  .table-toolbar-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .top-nav-inner {
    width: min(100vw - 18px, 100%);
    min-height: auto;
    padding: 12px 0;
    flex-direction: column;
    align-items: stretch;
  }

  .rank-hero-inner h1 {
    font-size: 40px;
  }

  .rank-search-row {
    grid-template-columns: 1fr;
  }

  .rank-result-head,
  .rank-result-row {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
  }

  .rank-result-table {
    overflow-x: auto;
  }

  .rank-result-head,
  .rank-result-row {
    min-width: 760px;
  }

  .website-result-top {
    flex-direction: column;
  }

  .place-result-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .rank-meta-text {
    flex-direction: column;
    gap: 6px;
  }

  .rank-detail-card {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 12px auto 24px;
  }

  .toolbar h1,
  .modal-head h2 {
    font-size: 26px;
  }

  .modal-card {
    padding: 18px;
  }

  .slot-check-grid {
    grid-template-columns: 1fr;
  }

  .rank-hero-inner {
    padding: 36px 16px 48px;
  }

  .rank-hero-inner h1 {
    font-size: 32px;
  }

  .rank-input-shell,
  .rank-search-submit {
    min-height: 54px;
  }

  .rank-result-head,
  .rank-result-row {
    min-width: 680px;
    padding: 16px 18px;
    font-size: 15px;
  }

  .rank-page-current {
    width: 36px;
    height: 36px;
  }

  .rank-detail-card {
    padding: 18px;
  }

  .website-result-card {
    padding: 18px;
  }

  .place-result-card {
    padding: 18px;
  }

  .website-result-body h2 {
    font-size: 22px;
  }

  .place-result-body h2 {
    font-size: 20px;
  }

  .rank-detail-card h2 {
    font-size: 24px;
  }

  .rank-detail-line {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* ═══════════════════════════════════════════════════════
   ★ 전역 모바일 대응 (모든 페이지에 적용)
   레퍼런스: 플레이스 순위 트래커 (tool_hub.html)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── 1. 페이지 자체 가로 스크롤 절대 차단 ── */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* ── 2. 메인 컨테이너 패딩 축소 ── */
  main, .container, .page-shell {
    padding-left: 12px !important;
    padding-right: 12px !important;
    max-width: 100% !important;
  }
  /* 인라인 패딩이 큰 경우도 강제 축소 */
  main[style*="padding:24px"],
  main[style*="padding: 24px"],
  div[style*="padding:24px"][class*="container"] {
    padding: 14px 12px !important;
  }

  /* ── 3. 표 — 페이지 안 모든 표 자체 가로 스크롤 (셀 정렬 유지) ── */
  /* 부모 div 가 자체 wrapper 역할: overflow-x:auto + 표는 그 안에서 자연스럽게 */
  .table-wrap, [class*="table-wrap"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }
  /* 페이지 내 모든 table 의 부모 div 에 overflow 보장 (raw 표 wrap 안 된 경우 대비) */
  table { max-width: 100%; }

  /* ── 4. 그리드 패턴 자동 분기 ── */
  /* 4-5 칼럼 그리드 → 모바일에서 칼럼당 최소폭 + 자체 가로 스크롤 */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"] {
    grid-template-columns: repeat(4, minmax(110px, 1fr)) !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  [style*="grid-template-columns:repeat(5,1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(5, minmax(100px, 1fr)) !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  /* 3 칼럼 그리드 (입력 폼 등) → 모바일에서 1칼럼 */
  [style*="grid-template-columns:1.5fr 1fr 1fr"],
  [style*="grid-template-columns: 1.5fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  /* 2 칼럼 그리드 (1fr 1fr / 1.3fr 1.3fr 등) → 모바일에서 1칼럼 */
  [style*="grid-template-columns:1fr 1fr"]:not([style*="auto"]),
  [style*="grid-template-columns: 1fr 1fr"]:not([style*="auto"]),
  [style*="grid-template-columns:1.3fr 1.3fr"]:not([style*="auto"]),
  [style*="grid-template-columns: 1.3fr 1.3fr"]:not([style*="auto"]) {
    grid-template-columns: 1fr !important;
  }
  /* minmax(>=200px,..) 큰 그리드 → 1칼럼 */
  [style*="minmax(280px"],
  [style*="minmax(260px"],
  [style*="minmax(240px"],
  [style*="minmax(220px"],
  [style*="minmax(200px"],
  [style*="minmax(320px"],
  [style*="minmax(360px"],
  [style*="minmax(400px"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* repeat(6+,...) 6칼럼 이상 그리드 (필터 row 등) → 1칼럼 */
  [style*="grid-template-columns:repeat(6,"],
  [style*="grid-template-columns: repeat(6,"],
  [style*="grid-template-columns:repeat(7,"],
  [style*="grid-template-columns: repeat(7,"],
  [style*="grid-template-columns:repeat(8,"],
  [style*="grid-template-columns: repeat(8,"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 정밀 픽셀 그리드 (60px 1fr 100px 80px 200px 같은 패턴) → 1칼럼 */
  [style*="60px 1fr 100px"],
  [style*="grid-template-columns:60px"],
  [style*="grid-template-columns: 60px"],
  [style*="grid-template-columns:90px 1fr 50px"],
  [style*="1fr 160px 160px auto"],
  [style*="1fr 2fr 120px auto"],
  [style*="2fr 1fr 1fr 1fr 1fr auto"],
  [style*="repeat(2,1fr)"],
  [style*="repeat(2, 1fr)"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* repeat(auto-fill,minmax(160-260px,..)) — 모바일에서 1칼럼 */
  [style*="auto-fill,minmax(160px"],
  [style*="auto-fill, minmax(160px"],
  [style*="auto-fill,minmax(180px"],
  [style*="auto-fill,minmax(220px"],
  [style*="auto-fill, minmax(220px"],
  [style*="auto-fill,minmax(260px"],
  [style*="auto-fit,minmax(280px"],
  [style*="auto-fit, minmax(280px"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* auto 1fr (도넛/아이콘 + 콘텐츠) → 모바일에서 1칼럼 세로 정렬 */
  [style*="grid-template-columns:auto 1fr"],
  [style*="grid-template-columns: auto 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* grid-column: span 6 같은 큰 span → 모바일에선 1칼럼 자동 따라감 */
  [style*="grid-column:span 6"],
  [style*="grid-column: span 6"],
  [style*="grid-column:span 5"],
  [style*="grid-column: span 5"] {
    grid-column: 1 / -1 !important;
  }
  /* justify-content: space-between 헤더 — 좁으면 wrap */
  [style*="justify-content:space-between"],
  [style*="justify-content: space-between"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* ── 5. 패널/카드 — min-width 0 으로 자식 강제 확장 방지 ── */
  .tool-panel, .panel, [class*="panel"] {
    min-width: 0;
    max-width: 100%;
  }

  /* ── 6. 폼 인풋 너비 보장 ── */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], input[type="url"],
  input[type="date"], input[type="datetime-local"], input[type="time"],
  textarea, select {
    max-width: 100%;
  }

  /* ── 7. 모달 모바일 패딩 축소 ── */
  [id$="-modal"] > div, [class*="modal"] > div {
    padding: 14px !important;
  }

  /* ── 8. 버튼 그룹 (flex 가로) — 좁으면 wrap ── */
  [style*="display:flex"][style*="justify-content:flex-end"],
  [style*="display: flex"][style*="justify-content: flex-end"] {
    flex-wrap: wrap !important;
  }

  /* ── 9. 큰 폰트 사이즈 모바일 축소 ── */
  h1[style*="font-size:24px"], h1[style*="font-size: 24px"] {
    font-size: 18px !important;
  }
  h1[style*="font-size:22px"], h1[style*="font-size: 22px"] {
    font-size: 17px !important;
  }
}

/* ★ 480px 이하 (작은 모바일) — 추가 축소 */
@media (max-width: 480px) {
  main, .container, .page-shell {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  /* 4칼럼은 2칼럼으로 (너무 좁아서 가로 스크롤 보다 wrap 이 나음) */
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    overflow-x: visible !important;
  }
}

/* ═══════════════════════════════════════════════════════
   ★ 순위 체크 페이지 모바일 강화
   - 플레이스 / 통합웹 (rank_lookup.html)
   - 블로그 / 카페 / 지식인 (tool_hub.html document_rank)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  /* ★ 도구 사이드바 모바일에서 완전 숨김 (이전엔 tool_hub.html 의 <style> 에만 있어서
     rank_lookup.html (플레이스/통합웹) 에선 안 먹었음) */
  .tool-hub-sidebar {
    display: none !important;
  }
  .tool-hub-shell {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  /* tool-hub-main 인라인 padding 강제 축소 */
  .tool-hub-main,
  section.tool-hub-main[style*="padding"] {
    padding: 14px 10px !important;
  }

  /* rank_lookup 페이지 자체 — 가로 오버플로 차단 */
  .rank-search-page {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* 히어로 패널 폰트 축소 */
  .rank-hero-inner h1 {
    font-size: 22px !important;
  }
  .rank-hero-inner p {
    font-size: 13px !important;
  }
  .rank-hero-inner {
    padding: 24px 12px !important;
  }

  /* 검색폼 1칼럼 + 버튼 내부 → 외부로 */
  .rank-search-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .rank-input-shell {
    min-height: 44px !important;
  }
  .rank-input-with-button input {
    padding-right: 80px !important;
  }

  /* 결과 카드 (website/place) — 헤더 행 좁으면 wrap */
  .website-result-top,
  .place-result-top {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .website-result-meta-inline {
    flex-wrap: wrap !important;
    gap: 8px !important;
    font-size: 11px !important;
  }
  .website-result-body h2,
  .place-result-body h2 {
    font-size: 14px !important;
    word-break: break-word;
  }
  .website-result-link {
    word-break: break-all;
    font-size: 11px !important;
  }
  .website-result-description {
    font-size: 11px !important;
  }
  .website-result-card,
  .place-result-card {
    padding: 12px !important;
  }

  /* 페이지네이션 컨트롤 */
  .rank-result-controls {
    flex-direction: column !important;
    gap: 12px !important;
  }
  .rank-pager {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  /* 결과표 (rank-result-table) — 가로 스크롤 wrap */
  .rank-result-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .rank-result-head,
  .rank-result-row {
    min-width: 600px !important;
    font-size: 13px !important;
    padding: 10px 12px !important;
  }

  /* document_rank (블로그/카페/지식인) 결과 카드 — 모바일에서 세로 정렬 */
  /* 상위 결과 행 — flex 가 너무 좁으면 깨짐 */
  #dr-result [style*="display:flex"][style*="gap:16px"] {
    flex-direction: column !important;
    text-align: left !important;
    gap: 8px !important;
  }
  #dr-result [style*="display:flex"][style*="gap:12px"] {
    gap: 8px !important;
  }
  /* 순위 배지 영역 폭 자동 */
  #dr-result [style*="flex-shrink:0"][style*="width:40px"] {
    width: auto !important;
    text-align: left !important;
  }

  /* 상세 카드 — 모바일에서 패딩 축소 */
  .rank-detail-card {
    padding: 14px !important;
    margin: 12px 0 !important;
  }
  .rank-detail-card h2 {
    font-size: 16px !important;
    word-break: break-word;
  }
  .rank-detail-line {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }
}

/* 더 작은 모바일 (≤ 480px) */
@media (max-width: 480px) {
  .rank-hero-inner h1 {
    font-size: 18px !important;
  }
  .website-result-meta-inline span {
    font-size: 10px !important;
  }
  .website-result-body h2,
  .place-result-body h2 {
    font-size: 13px !important;
  }
}

/* ═══════════════════════════════════════════════════════
   ★ 쇼핑 종합 분석 (#sa-result) 모바일 강화
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* 상품 헤더 (이미지 + 정보 가로 flex) → 세로 정렬 */
  #sa-result .tool-panel[style*="display:flex"][style*="gap:16px"] {
    flex-direction: column !important;
  }
  /* 상품 이미지 축소 */
  #sa-result [style*="width:120px"][style*="height:120px"] {
    width: 80px !important;
    height: 80px !important;
  }
  /* 가격 분포 차트 라벨 영역 (justify-content:space-between 3분할) */
  #sa-result [style*="justify-content:space-between"] {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  /* 브랜드/몰 점유율 항목 — 점유율 텍스트 너무 작아져도 가독성 유지 */
  #sa-result [style*="justify-content:space-between"][style*="font-size:11px"] {
    font-size: 11px !important;
  }
  /* 차트 컨테이너 (canvas) 너비 보장 */
  #sa-result canvas {
    max-width: 100% !important;
  }
}

/* ═══════════════════════════════════════════════════════
   ★ 모든 도구 페이지의 결과 영역에 적용되는 공통 모바일 보강
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* tool-panel 의 fix 패딩 인라인 강제 축소 */
  .tool-panel[style*="padding:20px"],
  .tool-panel[style*="padding: 20px"] {
    padding: 14px !important;
  }
  /* 모든 inline display:grid 의 자식이 너무 좁으면 자동 줄바꿈 */
  [style*="display:grid"] {
    min-width: 0;
  }
}
