/* ──────────────────────────────────────────────
   T-ARCH 통합 관제 플랫폼 디자인 시스템
   2026-05 리뉴얼: 모든 색은 tokens.css의 변수만 사용.
   하드코딩 hex 금지. 새 클래스 추가 시도 토큰만.
   ────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
section[id], [id="priority-section"] { scroll-margin-top: 24px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: var(--text-small);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss03', 'cv10';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── 로그인 ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  background: var(--brand-secondary);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18vh var(--space-5) var(--space-5);
}
.login-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 400px;
  padding: 40px 40px 36px;
  border-radius: var(--radius-lg);
  box-shadow:
    0 8px 32px rgba(28, 27, 26, 0.12),
    0 2px 8px rgba(28, 27, 26, 0.06);
}
.login-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}
.login-logo-img {
  display: block;
  margin: 0 auto var(--space-2);
  height: 52px;
  width: auto;
  max-width: 240px;
}
.login-subtitle {
  text-align: center;
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-top: 4px;
}
.login-title {
  font-size: var(--text-h3);
  margin: 0 0 var(--space-5);
  text-align: center;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block;
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--status-a-bg);
}
.btn-primary {
  width: 100%;
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: none;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: var(--text-body);
  font-weight: 600;
  margin-top: var(--space-2);
  transition: background 0.15s, transform 0.06s;
}
.btn-primary:hover { background: var(--brand-secondary); }
.btn-primary:active { transform: translateY(1px); }

.alert-error {
  background: var(--status-f-bg);
  color: var(--status-f);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  margin-bottom: var(--space-4);
  border: 1px solid var(--status-f-border);
}

/* ── 공통 레이아웃 ─────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

/* 사이드바 헤더 lockup (partial _sidebar_header.html) */
.sidebar-header {
  padding: var(--space-5) 20px var(--space-4);
  border-bottom: 1px solid var(--border-inverse);
  background: var(--bg-sidebar);
}
.sidebar-header .tekton-logo {
  display: block;
  width: 62%;                       /* 헤더 가용 폭의 황금비(≈62%) — 로고가 주인공 */
  height: auto;                     /* 종횡비 유지(벡터 SVG라 확대해도 선명) */
  max-width: none;
  margin: var(--space-2) 0 var(--space-3);  /* 위/아래 균형 여백 */
}
.sidebar-header .platform-label {
  margin-top: var(--space-1);
  font-size: 11px;                  /* 부제는 로고보다 한 단계 작게 */
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-inverse-muted);
}
.sidebar-header .status-pill {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
}
.sidebar-header .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-accent);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}

/* ── 사이드바 메뉴 ─────────────────────────────────────── */
.sidebar .menu {
  flex: 1;
  padding: var(--space-3) 0;
}
.sidebar .menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  min-height: var(--tap-min);
  color: var(--text-inverse-muted);
  font-size: var(--text-small);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sidebar .menu a:hover {
  background: rgba(250, 248, 243, 0.05);
  color: var(--text-inverse);
}
.sidebar .menu a.active {
  background: rgba(74, 222, 128, 0.08);
  color: var(--text-inverse);
  border-left-color: var(--brand-accent);
}
.sidebar .menu a .icon { font-size: var(--text-body); line-height: 1; width: 18px; text-align: center; }
.sidebar .menu a .text { flex: 1; }
.sidebar .menu a .count {
  background: var(--status-f);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.sidebar .footer {
  padding: var(--space-4) 20px;
  border-top: 1px solid var(--border-inverse);
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
}
.sidebar .footer .user {
  color: var(--text-inverse);
  font-weight: 600;
  font-size: var(--text-small);
}

/* 사이드바 v1 호환: brand-box (admin/_sidebar.html에서 직접 인라인 사용 중) */
.sidebar .brand-box {
  padding: var(--space-5) 20px var(--space-4);
  border-bottom: 1px solid var(--border-inverse);
  background: var(--bg-sidebar-gradient);
}
.sidebar .brand-box .brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-inverse);
}
.sidebar .brand-box .subtitle {
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
  margin-top: 4px;
}

/* ── 메인 영역 ─────────────────────────────────────────── */
.main {
  flex: 1;
  padding: var(--space-6) var(--space-6);
  overflow-y: auto;
  max-width: 1400px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--space-5);
}
.page-header h1 {
  font-size: var(--text-h1);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-header .updated {
  font-size: var(--text-caption);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── KPI 카드 ─────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.kpi-row.three  { grid-template-columns: repeat(3, 1fr); }
.kpi-row.two    { grid-template-columns: repeat(2, 1fr); }
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.kpi .label {
  color: var(--text-secondary);
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kpi .value {
  font-size: var(--text-kpi);
  font-weight: 700;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi .value.small  { font-size: var(--text-kpi-sm); }
.kpi .value.alarm  { color: var(--status-f); }
/* 통신 상태 KPI: 점 + 텍스트 inline (다른 KPI 숫자와 같은 위계) */
.kpi .value.comm-value {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-kpi-sm);
  font-weight: 500;
}
.comm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.comm-dot--normal   { background: var(--status-a); box-shadow: 0 0 0 3px var(--status-a-bg); }
.comm-dot--warning  { background: var(--status-c); box-shadow: 0 0 0 3px var(--status-c-bg); }
.comm-dot--critical { background: var(--status-f); box-shadow: 0 0 0 3px var(--status-f-bg); }
.kpi .sublabel {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ── 현장 카드 그리드 (관리자 v1) ─────────────────────── */
.site-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-card);
}
.site-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.site-card .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.site-card .site-name { font-size: var(--text-h3); font-weight: 700; }
.site-card .info {
  color: var(--text-secondary);
  font-size: var(--text-caption);
  margin-top: 4px;
}

/* ── 배지 / 등급 pill ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  font-weight: 600;
}
.badge.green  { background: var(--status-a-bg); color: var(--status-a); }
.badge.yellow { background: var(--status-c-bg); color: var(--status-c); }
.badge.blue   { background: rgba(30, 90, 142, 0.08); color: var(--color-info); }
.badge.red    { background: var(--status-f-bg); color: var(--status-f); }
.badge.gray   { background: var(--bg-section); color: var(--text-secondary); }

.grade-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-small);
  font-weight: 700;
  letter-spacing: 0.02em;
}
/* 등급별 (a/b/c/d/f) — admin/site.html JS의 gradeClass()와 일치 */
.grade-pill.a       { background: var(--status-a-bg); color: var(--status-a); }
.grade-pill.b       { background: var(--status-b-bg); color: var(--status-b); }
.grade-pill.c       { background: var(--status-c-bg); color: var(--status-c); }
.grade-pill.d       { background: var(--status-d-bg); color: var(--status-d); }
.grade-pill.f       { background: var(--status-f-bg); color: var(--status-f); }
/* 의미 클래스 — admin/dashboard.html JS의 grade_class와 일치 (danger/warning/normal) */
.grade-pill.danger  { background: var(--status-f-bg); color: var(--status-f); }
.grade-pill.warning { background: var(--status-c-bg); color: var(--status-c); }
.grade-pill.normal  { background: var(--status-a-bg); color: var(--status-a); }

/* ── 메트릭 / 알람 점 ─────────────────────────────────── */
.metric-row { display: flex; gap: 16px; margin: 12px 0; }
.metric {
  flex: 1;
  background: var(--bg-section);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.metric .l { color: var(--text-secondary); font-size: var(--text-caption); }
.metric .v {
  font-weight: 700;
  font-size: var(--text-h3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.metric .v.alarm { color: var(--status-f); }

.alarm-list { margin: 12px 0 6px; }
.alarm-list .alarm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-caption);
  padding: 6px 0;
  border-top: 1px dashed var(--border-subtle);
}
.alarm-list .alarm-item:first-child { border-top: 0; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot.danger  { background: var(--status-f); }
.dot.warning { background: var(--status-c); }
.dot.normal  { background: var(--status-a); }

.alarm-time { color: var(--text-secondary); font-size: var(--text-caption); margin-left: auto; }
.alarm-empty { color: var(--text-secondary); font-size: var(--text-caption); padding: 8px 0; }

.waste-line {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-caption);
}
.waste-line .v {
  color: var(--status-f);
  font-weight: 700;
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
}

/* ── 계정 관리 ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.btn-outline {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 8px 16px;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}
.btn-outline:hover { background: var(--bg-section); border-color: var(--border-strong); }
.btn-accent {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: none;
  padding: 10px 20px;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-small);
  transition: background 0.12s;
}
.btn-accent:hover { background: var(--brand-secondary); }
.btn-gold {
  background: var(--color-cta);
  color: var(--text-inverse);
  border: none;
  padding: 10px 20px;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-small);
}
.btn-gold:hover { filter: brightness(0.95); }
.btn-danger {
  background: var(--bg-card);
  color: var(--status-f);
  border: 1px solid var(--status-f-border);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: var(--text-caption);
}

table.users {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
table.users th,
table.users td {
  padding: 12px 16px;
  text-align: left;
  font-size: var(--text-small);
  border-bottom: 1px solid var(--border-subtle);
}
table.users th {
  background: var(--bg-section);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
table.users tr:last-child td { border-bottom: 0; }
table.users td .actions { display: flex; gap: 6px; }

/* ── 모달 ─────────────────────────────────────────────── */
.modal-back {
  display: none;
  position: fixed; inset: 0;
  background: rgba(28, 27, 26, 0.45);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 460px;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-modal);
}
.modal h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-h3);
  font-weight: 700;
}
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: var(--space-4);
}
.modal .actions button { padding: 9px 16px; border-radius: var(--radius-sm); font-size: var(--text-small); }

/* ── 사용자 대시보드 ───────────────────────────────────── */
.user-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--space-5);
}
.user-head .left h1 {
  margin: 0 0 6px;
  font-size: var(--text-h1);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.user-head .left .greeting {
  font-size: var(--text-body);
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
}
.user-head .meta { color: var(--text-secondary); font-size: var(--text-caption); }

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}
.section-card h3 {
  margin: 0 0 14px;
  font-size: var(--text-h3);
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-card .section-sub {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: auto;
}

/* ── Top 3 우선 점검 카드 ─────────────────────────────── */
.priority-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
.priority-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s, transform 0.18s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.priority-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}
.priority-card[data-severity="high"] {
  border-left: 3px solid var(--status-f);
  background: var(--status-f-bg);
}
.priority-card[data-severity="medium"] {
  border-left: 3px solid var(--status-c);
  background: var(--status-c-bg);
}
.priority-card[data-severity="low"] {
  border-left: 3px solid var(--status-a);
  background: var(--status-a-bg);
}
.priority-card .pc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.priority-card .pc-rank {
  font-size: var(--text-caption);
  font-weight: 700;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.priority-card .pc-cat {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-section);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
}
.priority-card .pc-title {
  font-size: var(--text-h3);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.priority-card .pc-desc {
  font-size: var(--text-small);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}
.priority-card .pc-impact {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-caption);
}
.priority-card .pc-impact-label {
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.priority-card .pc-impact-value {
  font-weight: 700;
  color: var(--status-a);
  font-variant-numeric: tabular-nums;
}
.priority-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--text-small);
}

/* ── 장비별 헬스 카드 그리드 ───────────────────────────── */
.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}
.eq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: box-shadow 0.18s, transform 0.12s;
  cursor: pointer;
}
.eq-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}
.eq-card .eq-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.eq-card .eq-name {
  font-size: var(--text-body);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.eq-card .eq-score {
  font-size: var(--text-kpi-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.eq-card .eq-score-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 2px;
}
.eq-card .eq-score.s-a, .eq-card .eq-score.s-b { color: var(--status-a); }
.eq-card .eq-score.s-c { color: var(--status-c); }
.eq-card .eq-score.s-d { color: var(--status-d); }
.eq-card .eq-score.s-f { color: var(--status-f); }
.eq-card .eq-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  color: var(--text-secondary);
}
.eq-card .eq-next {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
  font-size: var(--text-caption);
  color: var(--text-secondary);
}

/* ── 알람 테이블 (사용자/관리자 공용) ──────────────────── */
table.alarms {
  width: 100%;
  border-collapse: collapse;
}
table.alarms th,
table.alarms td {
  padding: 10px 12px;
  font-size: var(--text-small);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
table.alarms th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-caption);
  background: var(--bg-section);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.alarms tr:last-child td { border-bottom: 0; }

/* ── 정비 캘린더 (간소화 리스트) ───────────────────────── */
.maint-list { display: flex; flex-direction: column; gap: 8px; }
.maint-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 10px 12px;
  background: var(--bg-section);
  border-radius: var(--radius-sm);
}
.maint-item .date {
  font-size: var(--text-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  min-width: 72px;
}
.maint-item .target {
  flex: 1;
  font-size: var(--text-small);
  color: var(--text-primary);
}
.maint-item .d-days {
  font-size: var(--text-caption);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ── 챗봇/문의 플로팅 버튼 ─────────────────────────────── */
.fab-group {
  position: fixed;
  bottom: 90px; right: 22px;   /* STEP 4b: 피드백 FAB(bottom:22px) 위로 — 겹침 방지 */
  display: flex; flex-direction: column;
  gap: 12px;
  z-index: 50;
}
.fab {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: none;
  font-size: 22px;
  box-shadow: var(--shadow-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab.contact { background: var(--brand-secondary); }
.fab:hover { transform: scale(1.06); box-shadow: var(--shadow-card-hover), 0 16px 32px rgba(45, 122, 95, 0.30); }

/* 챗봇 패널 */
.chat-panel {
  position: fixed;
  bottom: 0; right: 0;
  width: 380px;
  height: 540px;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-elevated);
  display: none;
  flex-direction: column;
  z-index: 60;
  margin: 0 22px 22px 0;
}
.chat-panel.open { display: flex; }
.chat-head {
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  padding: 14px 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-head .t { font-weight: 700; font-size: var(--text-small); }
.chat-head .x {
  background: none; border: 0;
  color: var(--text-inverse);
  font-size: 20px;
}
.chat-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: var(--bg-section);
}
.chat-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: var(--text-small);
  line-height: var(--leading-normal);
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user {
  background: var(--brand-primary);
  color: var(--text-inverse);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
}
.chat-msg.err { background: var(--status-f-bg); color: var(--status-f); }
.chat-input {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.chat-input input {
  flex: 1;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: var(--text-small);
  font-family: inherit;
}
.chat-input button {
  background: var(--brand-primary);
  color: var(--text-inverse);
  border: 0;
  border-radius: 20px;
  padding: 0 16px;
  font-size: var(--text-small);
  font-weight: 600;
}

/* ── 사이드바 v2 — admin/_sidebar.html 확장 영역 ─────── */
.sb-search {
  margin: 14px 16px 0;
  position: relative;
}
.sb-search input {
  width: 100%;
  background: rgba(250, 248, 243, 0.06);
  border: 1px solid var(--border-inverse);
  border-radius: var(--radius-sm);
  padding: 9px 42px 9px 12px;
  color: var(--text-inverse);
  font-size: var(--text-small);
  font-family: inherit;
  outline: none;
}
.sb-search input::placeholder { color: var(--text-inverse-subtle); }
.sb-search input:focus { border-color: rgba(74, 222, 128, 0.4); }
.sb-search .kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-inverse-muted);
  background: rgba(250, 248, 243, 0.08);
  border: 1px solid var(--border-inverse);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}

.sb-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-inverse);
}
.sb-section-title {
  padding: 0 20px;
  font-size: var(--text-caption);
  color: var(--text-inverse-subtle);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.sb-item {
  display: block;
  padding: 6px 28px;
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item:hover {
  background: rgba(250, 248, 243, 0.05);
  color: var(--text-inverse);
}
.sb-empty {
  padding: 6px 28px;
  font-size: var(--text-caption);
  color: var(--text-inverse-subtle);
}

/* 토스트 */
#sb-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-elevated);
  font-size: var(--text-small);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  max-width: 320px;
}
#sb-toast.show { opacity: 1; transform: translateY(0); }

.sb-profile {
  padding: 14px 16px;
  border-top: 1px solid var(--border-inverse);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-profile .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-size: var(--text-small);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-profile .info { flex: 1; min-width: 0; }
.sb-profile .info .name {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-profile .info .role {
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
}
.sb-profile .logout-btn {
  background: none;
  border: none;
  color: var(--text-inverse-muted);
  font-size: var(--text-h3);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}
.sb-profile .logout-btn:hover {
  background: rgba(250, 248, 243, 0.08);
  color: var(--text-inverse);
}

/* 사용자 사이드바 정보 카드 스택 (활성 알람 / 다음 정비) */
.sb-info-stack {
  margin: 10px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-info-card {
  padding: 10px 14px;
  background: rgba(250, 248, 243, 0.06);
  border: 1px solid var(--border-inverse);
  border-radius: var(--radius-md);
}
.sb-info-label {
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
  margin-bottom: 2px;
  letter-spacing: 0.04em;
}
.sb-info-value {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--text-inverse);
  font-variant-numeric: tabular-nums;
}

.sb-status {
  margin: 10px 16px 0;
  padding: 9px 12px;
  background: rgba(250, 248, 243, 0.04);
  border: 1px solid var(--border-inverse);
  border-radius: var(--radius-sm);
}
.sb-status .row { display: flex; align-items: center; gap: 8px; }
.sb-status .row .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}
.sb-status .row .label {
  font-size: var(--text-caption);
  color: var(--text-inverse-muted);
}
.sb-status .meta {
  margin-top: 4px;
  font-size: var(--text-caption);
  color: var(--text-inverse-subtle);
  font-variant-numeric: tabular-nums;
}

/* 알람 패널 */
.alert-panel-back {
  display: none;
  position: fixed; inset: 0;
  background: rgba(28, 27, 26, 0.45);
  backdrop-filter: blur(2px);
  z-index: 80;
}
.alert-panel-back.open { display: block; }
.alert-panel {
  position: fixed;
  top: 0; right: 0;
  width: 380px;
  height: 100vh;
  background: var(--bg-card);
  z-index: 90;
  box-shadow: var(--shadow-elevated);
  transform: translateX(100%);
  transition: transform 0.2s ease-out;
  display: flex;
  flex-direction: column;
}
.alert-panel.open { transform: translateX(0); }
.alert-panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alert-panel-head h3 { margin: 0; font-size: var(--text-h3); font-weight: 700; }
.alert-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.alert-close:hover { color: var(--text-primary); }
.alert-panel-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.alert-panel-body .alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
}
.alert-panel-body .alert-item:hover { background: var(--bg-section); }
.alert-panel-body .alert-text { flex: 1; min-width: 0; }
.alert-panel-body .alert-site {
  font-size: var(--text-caption);
  color: var(--text-secondary);
}
.alert-panel-body .alert-name {
  font-size: var(--text-small);
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-panel-body .alert-time {
  font-size: var(--text-caption);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.alert-panel-body .empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: var(--text-small);
}

/* ── KPI 프로그레스 바 (헬스 점수 현재값 시각화) ───────── */
.kpi-bar {
  height: 6px;
  background: var(--bg-section);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}
.kpi-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--status-a);
  transition: width 0.4s ease, background 0.3s;
}

/* ── 장비 카드 스파크라인 (예시 추이) ──────────────────── */
.eq-card .eq-spark { width: 100%; height: 28px; display: block; margin: 10px 0 2px; }
.eq-card .eq-spark-cap { font-size: 10px; color: var(--text-tertiary); letter-spacing: 0.02em; }

/* 카드 내 미니 버튼 (Top3 상세보기 등) */
.mini-btn {
  margin-top: 6px;
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: var(--text-caption);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.mini-btn:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-strong); }

/* ── 슬라이드인 상세 패널 (이상/장비 클릭) ─────────────── */
.detail-panel-back {
  display: none;
  position: fixed; inset: 0;
  background: rgba(28, 27, 26, 0.45);
  backdrop-filter: blur(2px);
  z-index: 110;
}
.detail-panel-back.open { display: block; }
.detail-panel {
  position: fixed;
  top: 0; right: 0;
  width: 460px;
  max-width: 100%;
  height: 100vh;
  background: var(--bg-card);
  z-index: 120;
  box-shadow: var(--shadow-modal);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.detail-panel.open { transform: translateX(0); }
.detail-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.detail-panel-title { font-size: var(--text-h3); font-weight: 700; letter-spacing: -0.01em; }
.detail-panel-sub { font-size: var(--text-small); color: var(--text-secondary); margin-top: 4px; }
.detail-close {
  background: none; border: none; font-size: 24px; line-height: 1;
  color: var(--text-secondary); cursor: pointer; padding: 2px 8px; border-radius: 6px; flex-shrink: 0;
}
.detail-close:hover { background: var(--bg-section); color: var(--text-primary); }
.detail-panel-body { flex: 1; overflow-y: auto; padding: 20px 24px; }

.panel-section { margin-bottom: 22px; }
.panel-section-title {
  font-size: var(--text-caption); font-weight: 600; color: var(--text-tertiary);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 10px;
}
.panel-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-stat { background: var(--bg-section); border-radius: var(--radius-sm); padding: 12px 14px; }
.panel-stat .l { font-size: var(--text-caption); color: var(--text-secondary); margin-bottom: 4px; }
.panel-stat .v {
  font-size: var(--text-h2); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.panel-stat .v.danger, .panel-stat .v.warning, .panel-stat .v.ok, .panel-stat .v.normal { }
.panel-stat .v.danger  { color: var(--status-f); }
.panel-stat .v.warning { color: var(--status-c); }
.panel-stat .v.ok, .panel-stat .v.normal { color: var(--status-a); }
.panel-desc {
  font-size: var(--text-small); color: var(--text-secondary); line-height: var(--leading-relaxed);
  background: var(--bg-section); padding: 12px 16px; border-radius: var(--radius-sm);
}
.panel-note { font-size: var(--text-caption); color: var(--text-tertiary); line-height: var(--leading-normal); }

/* ── 반응형 ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .priority-grid { grid-template-columns: 1fr; }
  .site-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* 사이드바 → 화면 하단 고정 탭바 (메뉴만 노출) */
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: 60px;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border-inverse);
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar .sidebar-header,
  .sidebar .sb-search,
  .sidebar .sb-section,
  .sidebar .sb-info-stack,
  .sidebar .sb-status,
  .sidebar .sb-profile,
  .sidebar .footer { display: none; }
  .sidebar .menu { flex: 1; display: flex; flex-direction: row; padding: 0; }
  .sidebar .menu a {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 64px;
    min-height: 60px;
    padding: 8px 6px;
    border-left: none;
    border-top: 3px solid transparent;
    font-size: 11px;
    justify-content: center;
    text-align: center;
  }
  .sidebar .menu a.active { border-left: none; border-top-color: var(--brand-accent); }
  .sidebar .menu a .icon { font-size: 20px; width: auto; }
  .sidebar .menu a .text {
    flex: none;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 본문: 탭바 높이만큼 하단 여백 */
  .main { padding: var(--space-5) var(--space-4) 84px; max-width: none; }

  /* 그리드 축소 */
  .kpi-row, .kpi-row.three, .kpi-row.two { grid-template-columns: 1fr 1fr; }
  .priority-grid { grid-template-columns: 1fr; }
  .equipment-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr !important; }

  /* 상세/챗봇 패널 전체폭 */
  .detail-panel { width: 100%; }
  .chat-panel { width: 100%; height: 80vh; margin: 0; right: 0; }
  .fab-group { bottom: 152px; }   /* STEP 4b: 모바일 피드백 FAB(bottom:84px) 위로 */

  /* 관리자: 테이블 숨기고 카드 리스트 */
  table.sites { display: none; }
  .site-cards-mobile { display: flex; flex-direction: column; gap: 12px; }
}

/* ══════════════════════════════════════════════════════════════
   STEP 4b — 피드백 플로팅 버튼(E안 펼침형) + 다크 패널
   · 공유 파셜 _feedback_fab.html에서 사용. 순수 CSS, transform/opacity만.
   · 색은 전부 변수(다크=--bg-sidebar, 라임=--brand-lime, 글자=--text-inverse).
   ══════════════════════════════════════════════════════════════ */
.fb-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  height: 56px; width: 56px;                 /* 평소: 동그라미 */
  padding: 0; border-radius: 28px;
  display: flex; align-items: center; overflow: hidden;
  background: var(--bg-sidebar); border: 1px solid var(--border-inverse);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
/* 아이콘 칸: 왼쪽 56px에 고정 — 펼쳐도 안 밀림(E안 버그수정 포인트) */
.fb-fab-ic {
  flex: 0 0 56px; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-lime);
}
.fb-fab-ic svg { width: 24px; height: 24px; display: block; }
.fb-fab-label {
  white-space: nowrap; opacity: 0; padding-right: 20px;
  font-size: var(--text-small); font-weight: 600; color: var(--text-inverse);
  transition: opacity 0.2s ease;
}
.fb-fab:hover { width: 168px; }
.fb-fab:hover .fb-fab-label { opacity: 1; }
/* 라임 링 펄스 — 동그라미 상태일 때만, opacity만 애니(2.8s) */
.fb-fab::after {
  content: ""; position: absolute; left: 0; top: 0; width: 54px; height: 54px;
  border-radius: 50%; border: 2px solid var(--brand-lime);
  opacity: 0; pointer-events: none;
  animation: fb-ring-pulse 2.8s ease-in-out infinite;
}
.fb-fab:hover::after { animation: none; opacity: 0; }   /* 펼치면 링 끔 */
@keyframes fb-ring-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.5; } }

/* 다크 패널 — 우하단, FAB 위 */
.fb-panel {
  position: fixed; right: 22px; bottom: 90px; z-index: 61;
  width: 300px; max-width: calc(100vw - 44px);
  padding: 16px; border-radius: var(--radius-md);
  background: var(--bg-sidebar); border: 1px solid var(--border-inverse);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(8px) scale(0.98); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fb-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.fb-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; color: var(--text-inverse); font-weight: 600; font-size: var(--text-body);
}
.fb-x {
  background: none; border: 0; color: var(--text-inverse-muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.fb-ta, .fb-name {
  width: 100%; box-sizing: border-box; padding: 11px 12px; margin-bottom: 10px;
  border: 1px solid var(--border-inverse); border-radius: var(--radius-sm);
  background: var(--bg-sidebar-card, #0e1612); color: var(--text-inverse);
  font-family: var(--font-sans); font-size: var(--text-small);
}
.fb-ta { min-height: 84px; resize: vertical; }
.fb-ta::placeholder, .fb-name::placeholder { color: var(--text-inverse-subtle); }
/* 보내기 ↔ 체크 같은 슬롯에서 morph (버튼 사라지고 체크 슥) */
.fb-send-slot { position: relative; height: 42px; }
.fb-send {
  position: absolute; inset: 0; width: 100%;
  border: 1px solid var(--cta-quote-border); border-radius: var(--radius-sm);
  background: var(--cta-quote-bg); color: var(--cta-quote-text);
  font-weight: 600; font-size: var(--text-small); cursor: pointer;
  transition: opacity 0.2s ease;
}
.fb-check {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--brand-lime); font-weight: 600; font-size: var(--text-small);
  opacity: 0; transform: scale(0.8); pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fb-send-slot.sent .fb-send  { opacity: 0; pointer-events: none; }
.fb-send-slot.sent .fb-check { opacity: 1; transform: scale(1); }

/* 모바일(hover 없음): 처음부터 펼침 + 글자 + 링 끔 */
@media (hover: none) {
  .fb-fab { width: 168px; }
  .fb-fab-label { opacity: 1; }
  .fb-fab::after { animation: none; opacity: 0; }
}
/* 모바일 하단 네비 위로 (≤1024) */
@media (max-width: 1024px) {
  .fb-fab   { bottom: 84px; }
  .fb-panel { bottom: 152px; }
}
/* 모션 최소화 존중 */
@media (prefers-reduced-motion: reduce) {
  .fb-fab, .fb-fab-label, .fb-panel, .fb-send, .fb-check { transition: none; }
  .fb-fab::after { animation: none; opacity: 0; }
}
