/* ===== Gmail-style Design Tokens ===== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --header-bg: #fff;
  --accent: #1a73e8;
  --success: #1e8e3e;
  --success-bg: #e6f4ea;
  --warning: #f9ab00;
  --warning-bg: #fef7e0;
  --danger: #d93025;
  --danger-bg: #fce8e6;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --border: #dadce0;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;
  --shadow-sm: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px rgba(60,64,67,.15);
  --shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px rgba(60,64,67,.15);
  --shadow-md: 0 2px 6px rgba(60,64,67,.3), 0 6px 10px rgba(60,64,67,.15);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 24px;
  --sidebar-w: 256px;
  --header-h: 64px;
  --font: 'Pretendard Variable', 'Pretendard', -apple-system, 'Malgun Gothic', sans-serif;

  /* ===== 동(棟)별 색상 — 현황판에서 건물 구분용 (중앙 관리) ===== */
  --dong-a: #1565c0;   --dong-a-bg: #e8f0fe;
  --dong-b: #c62828;   --dong-b-bg: #fce8e6;
  --dong-c: #2e7d32;   --dong-c-bg: #e6f4ea;
  --dong-m: #e65100;   --dong-m-bg: #fff3e0;
  /* 위임/소유 구분 색상 */
  --owner: #1e8e3e;    /* 소유자 위임 */
  --tenant: #e65100;   /* 점유자 위임 */
  --both: #7c3aed;     /* 둘 다 / OCR 강조 */
  --corp: #b06000;     /* 시행사/법인 */
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header (Gmail style - white) ===== */
.app-header {
  background: var(--header-bg);
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  width: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-inner { max-width: 1080px; margin: 0 auto; }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo-link { display: flex; align-items: center; flex-shrink: 0; }
.header-logo-img { height: 30px; width: auto; display: block; }
.header-title { font-size: 1.1rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text-secondary); }
.header-role-badge { font-size: .75rem; padding: 1px 6px; background: var(--primary-light); color: var(--primary); border-radius: 4px; font-weight: 600; }
.header-logout { color: var(--text-muted); padding: 6px; border-radius: 50%; display: flex; }
.header-logout:hover { background: #f1f3f4; color: var(--danger); text-decoration: none; }
.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav-item { color: var(--text-secondary); font-size: .88rem; padding: 8px 14px; border-radius: var(--radius-xl); transition: background .2s; font-weight: 500; cursor: pointer; border: none; background: none; font-family: var(--font); display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.header-nav-item:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.header-nav-item i { width: 15px; height: 15px; }
.header-nav .nav-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.hamburger { display: none; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 8px; border-radius: 50%; }
.hamburger:hover { background: #f1f3f4; }

/* ===== Admin Layout ===== */
.sidebar-overlay { display: none; }
.admin-layout { display: flex; }

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  flex-shrink: 0;
  padding: 12px 10px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-section { margin-bottom: 2px; }
.sidebar-label { display: none; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 500;
  transition: all .15s;
  text-decoration: none;
  position: relative;
}
.sidebar-link:hover { background: #f1f3f4; color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-link i { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto;
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.sidebar-badge-primary { background: var(--primary-light); color: var(--primary); }
.sidebar-badge-success { background: var(--success-bg); color: var(--success); }
.sidebar-badge-warning { background: var(--warning-bg); color: var(--warning); }
.sidebar-badge-muted { background: #f1f3f4; color: var(--text-muted); }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 6px 14px; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.admin-content {
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}
.admin-content-inner {
  max-width: 1100px;
}

/* ===== Public Layout ===== */
.public-main { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ===== Footer ===== */
.app-footer { background: var(--surface); color: var(--text-muted); text-align: center; padding: 16px; font-size: .95rem; border-top: 1px solid var(--border); }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--text-secondary); width: 20px; height: 20px; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card.stat-total .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.stat-verified .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.stat-pending .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.stat-rejected .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-number { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .9rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead th { font-weight: 600; font-size: .9rem; text-transform: uppercase; letter-spacing: .3px; color: var(--text-secondary); padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 10px 16px; border-bottom: 1px solid #f1f3f4; font-size: .95rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fa; }

/* ===== Tags ===== */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-xl); font-size: .9rem; font-weight: 600; }
.tag-verified { background: var(--success-bg); color: var(--success); }
.tag-rejected { background: var(--danger-bg); color: var(--danger); }
.tag-pending { background: var(--warning-bg); color: #e37400; }
.tag-processing { background: var(--primary-light); color: var(--primary); }
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-failed { background: var(--danger-bg); color: var(--danger); }
.tag-skipped { background: #f1f3f4; color: var(--text-muted); }

/* ===== Score Bar ===== */
.score-bar { height: 6px; background: #e8eaed; border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.score-bar-fill.high { background: var(--success); }
.score-bar-fill.mid { background: var(--warning); }
.score-bar-fill.low { background: var(--danger); }
.score-text { font-size: .9rem; font-weight: 600; margin-bottom: 4px; }

/* ===== Buttons (Gmail style) ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 24px; border: none; border-radius: var(--radius-xl);
  font-size: .95rem; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all .15s; text-decoration: none; line-height: 1.4;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: #f8f9fa; border-color: #bdc1c6; }
.btn-sm { padding: 4px 14px; font-size: .95rem; }
.btn-lg { padding: 12px 32px; font-size: 1rem; font-weight: 600; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; font-size: .95rem; margin-bottom: 6px; color: var(--text); }
.form-label .required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; font-family: var(--font);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,.2);
}
.form-hint { font-size: .9rem; color: var(--text-muted); margin-top: 4px; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; background: var(--surface); }
.form-section-title { font-size: .95rem; font-weight: 600; margin-bottom: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.alert-error { background: var(--danger-bg); color: #a50e0e; }
.alert-success { background: var(--success-bg); color: #0d652d; }
.alert-warning { background: var(--warning-bg); color: #8a6d00; }

/* ===== Detail Table ===== */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th { text-align: left; padding: 10px 16px; color: var(--text-secondary); font-weight: 500; font-size: .9rem; width: 130px; vertical-align: top; border-bottom: 1px solid #f1f3f4; }
.detail-table td { padding: 10px 16px; border-bottom: 1px solid #f1f3f4; }

/* ===== Spinner ===== */
.spinner-wrap { text-align: center; padding: 40px; }
.spinner { width: 36px; height: 36px; border: 3px solid #e8eaed; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .7; } }
@keyframes sirenFlash { 0%,100% { background: rgba(0,0,0,.92); } 50% { background: rgba(80,0,0,.95); } }
@keyframes sirenSpin { 0% { transform: rotate(0) scale(1); } 25% { transform: rotate(-15deg) scale(1.1); } 50% { transform: rotate(0) scale(1); } 75% { transform: rotate(15deg) scale(1.1); } }
@keyframes sirenPulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 76px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); font-size: .95rem; font-weight: 500; color: #fff; box-shadow: var(--shadow-md); animation: slideIn .3s ease; display: flex; align-items: center; gap: 8px; min-width: 260px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { opacity: 1; } to { opacity: 0; } }

/* ===== Modal ===== */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 500; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 50%; }
.modal-close:hover { background: #f1f3f4; }
.modal-body { padding: 16px 24px 24px; }

/* ===== Landing ===== */

/* ===== Landing - Info ===== */
.info-section { padding: 32px 0; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.info-icon { width: 52px; height: 52px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.info-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; }
.info-card p { font-size: .95rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.info-list { list-style: none; font-size: .9rem; }
.info-list li { display: flex; align-items: center; gap: 6px; padding: 4px 0; color: var(--text-secondary); }

/* ===== Landing - CTA ===== */
.cta-section { padding: 32px 0 48px; }
.cta-buttons { display: flex; gap: 16px; justify-content: center; }
.cta-btn {
  display: flex; align-items: center; gap: 14px; padding: 18px 36px;
  border-radius: var(--radius-lg); font-family: var(--font); cursor: pointer;
  text-decoration: none; transition: all .2s; border: none; min-width: 220px;
}
.cta-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.cta-btn span { text-align: left; }
.cta-btn strong { display: block; font-size: 1.1rem; }
.cta-btn small { display: block; font-size: .9rem; opacity: .8; margin-top: 2px; }
.cta-primary { background: var(--primary); color: #fff; }
.cta-primary:hover { background: var(--primary-dark); }
.cta-secondary { background: #e65100; color: #fff; }
.cta-secondary:hover { background: #bf360c; }

/* ===== Login ===== */
.login-page { min-height: calc(100vh - var(--header-h) - 50px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 40px; width: 100%; max-width: 400px; }
.login-card h2 { text-align: center; margin-bottom: 24px; color: var(--text); font-size: 1.2rem; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .name { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.login-brand .desc { font-size: .9rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Badge/Certificate ===== */
.badge-page { max-width: 560px; margin: 40px auto; padding: 0 20px; }
.badge-certificate {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 48px 40px; text-align: center; position: relative; box-shadow: var(--shadow);
}
.badge-certificate::before { content: ''; position: absolute; inset: 8px; border: 1px dashed var(--border); border-radius: var(--radius); pointer-events: none; }
.badge-certificate.expired { opacity: .6; }
.expired-banner { position: absolute; top: -1px; left: -1px; right: -1px; background: var(--danger); color: #fff; padding: 8px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; font-weight: 600; }
.badge-header h1 { font-size: 1.3rem; color: var(--text); }
.badge-header .building-name { font-size: 1rem; color: var(--primary); font-weight: 600; margin-top: 4px; }
.badge-header .building-addr { font-size: .95rem; color: var(--text-muted); }
.badge-body { margin: 28px 0; }
.badge-company { font-size: 1.5rem; font-weight: 700; }
.badge-unit { font-size: .95rem; color: var(--text-secondary); margin-top: 4px; }
.verified-stamp { display: inline-flex; align-items: center; justify-content: center; width: 88px; height: 88px; border: 3px solid var(--success); border-radius: 50%; color: var(--success); font-size: 1.1rem; font-weight: 800; margin: 20px 0; }
.badge-score { font-size: .95rem; color: var(--text-secondary); }
.badge-footer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 20px; }
.badge-dates { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text-muted); }
.badge-token { font-size: .72rem; color: var(--text-muted); margin-top: 8px; letter-spacing: 1px; }
.badge-actions { text-align: center; margin-top: 16px; display: flex; justify-content: center; gap: 8px; }

/* ===== Settings (tab layout) ===== */
.settings-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; flex-wrap: wrap; }
.settings-tab {
  padding: 10px 20px; font-size: .95rem; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s;
  background: none; border-top: none; border-left: none; border-right: none; font-family: var(--font);
}
.settings-tab:hover { color: var(--primary); background: var(--primary-light); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-grid .form-group { margin-bottom: 0; }
.settings-actions { display: flex; gap: 8px; align-items: center; }
.settings-test-result { font-size: .9rem; font-weight: 600; }
.settings-test-result.ok { color: var(--success); }
.settings-test-result.fail { color: var(--danger); }
.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 40px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 50%; }
.password-toggle:hover { background: #f1f3f4; }

/* ===== Type Selection ===== */
.type-option {
  border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 14px 12px;
  text-align: center; transition: all .15s; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.type-option:hover { border-color: var(--primary); background: var(--primary-light); }
input[type="radio"]:checked + .type-option { border-color: var(--primary); background: var(--primary-light); color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,.2); }

/* ===== Error ===== */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h2 { font-size: 1.3rem; margin-bottom: 8px; }
.error-page p { color: var(--text-secondary); margin-bottom: 20px; }

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .95rem; }
.fw-600 { font-weight: 600; }

/* ===== Card Action Button (shine effect) ===== */
.card-action-btn {
  display: inline-flex; align-items: center; gap: 14px; padding: 14px 28px;
  background: var(--btn-color, var(--primary)); color: #fff;
  border: none; border-radius: var(--radius-xl); font-size: 1rem; font-weight: 600;
  font-family: var(--font); cursor: pointer; position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s; text-decoration: none;
}
.card-action-btn .btn-icon { flex-shrink: 0; width: 28px; height: 28px; opacity: .9; }
.card-action-btn .btn-text { display: flex; flex-direction: column; text-align: left; }
.card-action-btn .btn-main { font-size: 1.05rem; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.card-action-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.2); text-decoration: none; color: #fff; }
.card-action-btn .btn-subtitle { font-size: .72rem; font-weight: 400; opacity: .8; margin-top: 2px; white-space: nowrap; }
/* 반짝임 효과 */
.card-action-btn::after {
  content: ''; position: absolute; top: -50%; left: -60%; width: 40%; height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  transform: skewX(-20deg); animation: btnShine 4s infinite;
}
@keyframes btnShine {
  0% { left: -60%; }
  40% { left: 120%; }
  100% { left: 120%; }
}
/* 약한 효과 버전 */
.card-action-btn-soft { font-size: .92rem; padding: 14px 22px; line-height: 1.4; text-align: center; }
.card-action-btn-soft::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent); animation-duration: 5s; }

/* ===== Chairman Photo ===== */
.chairman-photo {
  width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
  margin: 0 auto 10px; border: 3px solid var(--primary);
  background: #e8ecf1;
}
.chairman-photo img {
  width: 100%; height: 100%; object-fit: cover; object-position: center 15%;
  display: block;
}
.chairman-fallback {
  width: 100%; height: 100%; align-items: center; justify-content: center; background: #e8ecf1;
}

/* ===== SNS Buttons ===== */
.sns-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-xl); font-size: .82rem; font-weight: 600;
  text-decoration: none; color: #fff; transition: transform .15s, box-shadow .15s;
  font-family: var(--font);
}
.sns-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.15); text-decoration: none; color: #fff; }
.sns-kakao { background: #FEE500; color: #3C1E1E; }
.sns-kakao:hover { color: #3C1E1E; }
.sns-blog { background: #03C75A; }
.sns-cafe { background: #03C75A; }

/* ===== Chat ===== */
.chat-msg { display: flex; }
.chat-msg.chat-user { justify-content: flex-end; }
.chat-bubble { max-width: 85%; padding: 10px 14px; border-radius: var(--radius-lg); font-size: .92rem; line-height: 1.6; word-break: break-word; }
.chat-bubble-ai { background: #f1f3f4; color: var(--text); border-bottom-left-radius: 4px; }
.chat-bubble-user { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-typing { display: flex; gap: 4px; padding: 10px 14px; }
.chat-typing span { width: 8px; height: 8px; border-radius: 50%; background: #bbb; animation: chatDot 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot { 0%,100% { opacity:.3; } 50% { opacity:1; } }

/* ===== Mobile Bottom Nav ===== */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -1px 4px rgba(0,0,0,.08);
  justify-content: space-around; padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; color: var(--text-muted); text-decoration: none;
  background: none; border: none; font-family: var(--font); cursor: pointer; padding: 4px 8px;
}
.mobile-nav-item i { width: 20px; height: 20px; }
.mobile-nav-item:hover, .mobile-nav-item:active { color: var(--primary); text-decoration: none; }

/* ===== Print ===== */
@media print {
  .app-header, .app-footer, .badge-actions, .admin-sidebar { display: none !important; }
  body { background: #fff; }
}

/* ===== settings-tab as link ===== */
a.settings-tab { text-decoration: none; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 14px; }

  /* 사이드바 */
  .admin-sidebar { position: fixed; left: -280px; width: 280px; top: var(--header-h); bottom: 0; z-index: 200; transition: left .3s ease; border-right: none; box-shadow: none; background: var(--surface); }
  .admin-sidebar.open { left: 0; box-shadow: var(--shadow-md); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; top: var(--header-h); background: rgba(0,0,0,.4); z-index: 199; }
  .admin-content { padding: 10px; margin-left: 0 !important; }

  /* 헤더 */
  .hamburger { display: flex; }
  .header-nav { display: none; }
  .header-title { display: none; }
  .header-logo-img { height: 24px; }
  .header-user span { display: none; }
  .header-role-badge { display: none; }

  /* 모바일 하단 네비 */
  .mobile-nav { display: flex !important; }
  .public-main { padding-bottom: 70px; }

  /* 모든 그리드 → 1열 */
  .stats-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .info-grid { grid-template-columns: 1fr !important; }
  .settings-grid { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* 위임장 현황 동별 그리드 → 가로 스크롤 */
  .dong-grid { grid-template-columns: repeat(3, minmax(200px, 1fr)) !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* 위임장 대시보드 텍스트 유지 */
  .mandate-dashboard { padding: 14px !important; }
  div[style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
  div[style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr !important; }

  /* 카드 */
  .card { padding: 12px; margin-bottom: 10px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .info-card { padding: 14px; }

  /* 페이지 헤더 */
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-title { font-size: 1.15rem; }

  /* 랜딩 */
  .public-main { padding: 0 12px; padding-bottom: 70px; }
  .cta-buttons { flex-direction: column; gap: 10px; }
  .cta-btn { min-width: auto; padding: 14px 18px; }
  .cta-section { padding: 20px 0 32px; }
  .info-section { padding: 12px 0; }
  .steps-list { flex-direction: column; align-items: center; }

  /* 위원장 인사말 카드 */
  .info-card > div[style*="display:flex"][style*="gap:28px"] {
    flex-direction: column !important;
    gap: 16px !important;
    align-items: center !important;
  }
  /* 인사말 텍스트 */
  .info-card > div > div[style*="min-width:250px"] {
    min-width: auto !important;
  }
  /* 위원장 사진 */
  .chairman-photo { width: 90px; height: 90px; }
  /* 인사말 제목 */
  .info-card h3[style*="1.3rem"] { font-size: 1.1rem !important; text-align: center; }
  /* 요구사항 버튼 */
  .card-action-btn-soft { font-size: .82rem !important; padding: 10px 18px !important; }
  /* SNS 버튼 */
  .sns-btn { font-size: .75rem; padding: 6px 12px; }

  /* 3열 카드 → 1열 */
  .info-grid[style*="repeat(3"] { grid-template-columns: 1fr !important; }
  /* 카드 액션 버튼 */
  .card-action-btn { padding: 12px 20px !important; }
  .card-action-btn .btn-main { font-size: 1rem !important; }
  .card-action-btn .btn-icon { width: 24px !important; height: 24px !important; }
  /* 카드 설명 텍스트 */
  .info-card h3 { font-size: 1rem; }
  .info-card p { font-size: .88rem; }
  .info-list li { font-size: .82rem; }

  /* 모달 */
  .modal { max-width: 100%; margin: 0 6px; max-height: 95vh; }
  .modal-body { padding: 10px 12px 16px; }
  .modal-header { padding: 12px 12px 0; }
  .type-option { padding: 10px 8px; }

  /* 탭 */
  .settings-tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; gap: 0; }
  .settings-tab { flex-shrink: 0; padding: 8px 12px; font-size: .88rem; }

  /* 테이블 */
  .table-wrap { margin: 0 -10px; border-radius: 0; border-left: none; border-right: none; overflow-x: auto; }
  thead th, tbody td { padding: 7px 8px; font-size: .82rem; white-space: nowrap; }

  /* 로그인 */
  .login-card { margin: 0 12px; padding: 20px; }
  .login-brand .name { font-size: 1rem; }

  /* 푸터 */
  .app-footer { font-size: .72rem; padding: 12px; margin-bottom: 56px; }

  /* 동/호실 입력 */
  .dong-ho-row { grid-template-columns: 80px 1fr auto auto !important; }

  /* 채팅 모달 */
  #chatModal .modal { height: 90vh; }
  .chat-bubble { font-size: .85rem; }

  /* stat 카드 */
  .stat-card { padding: 12px; }
  .stat-number { font-size: 1.3rem; }

  /* 인증서 */
  .badge-certificate { padding: 20px 14px; }
  .badge-dates { flex-direction: column; gap: 4px; }

  /* 상세 페이지 */
  .detail-table th { width: 80px !important; font-size: .82rem; }
  .compare-table { table-layout: auto !important; }
  .compare-table .row-label { width: auto !important; white-space: normal !important; }
  .compare-table .col-input, .compare-table .col-api { width: auto !important; }
  .compare-table .col-match { width: 36px !important; }

  /* 대시보드 */
  .dashboard-grid { grid-template-columns: 1fr !important; }

  /* flex 래핑 */
  .flex { flex-wrap: wrap; }
  .flex-between { flex-wrap: wrap; gap: 8px; }
}
