/* 레이아웃: 공개 화면(가운데 카드) · 앱 화면(상단 바 + 왼쪽 메뉴) */

/* ── 공개 화면 ────────────────────────────────────────── */
.public {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: var(--space-10) var(--space-4) var(--space-6);
}
.public-brand { display: inline-flex; margin-bottom: var(--space-6); border-radius: var(--radius-sm); }
.public-brand img { height: 40px; width: auto; display: block; }
.public-main { width: 100%; max-width: 960px; }
.public-card { max-width: 440px; margin: 0 auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: var(--space-8); }
.public-card.wide { max-width: 720px; }
.public-card h1 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.public-card .lead { color: var(--color-text-muted); margin-bottom: var(--space-6); }
.public-links { margin-top: var(--space-6); text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); }
.public-links a { margin: 0 var(--space-1); }
.public-footer { margin-top: auto; padding-top: var(--space-8); font-size: var(--text-xs); color: var(--color-text-muted); letter-spacing: .02em; }

@media (max-width: 480px) {
  .public { padding-top: var(--space-6); }
  .public-card { padding: var(--space-6) var(--space-5); }
}

/* 랜딩 */
.hero { text-align: center; padding: var(--space-6) 0 var(--space-10); }
.hero h1 { font-size: 34px; margin-bottom: var(--space-3); }
.hero .lead { font-size: var(--text-lg); color: var(--color-text-muted); max-width: 560px; margin: 0 auto var(--space-6); }
.hero .btn-row { justify-content: center; }
.hero .btn { min-height: 48px; padding: 0 var(--space-6); }
.hero-note { margin-top: var(--space-3); }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.feature { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: var(--space-6); }
.feature-icon { width: 44px; height: 44px; border-radius: var(--radius); display: grid; place-items: center; margin-bottom: var(--space-4); }
.feature-icon svg { width: 24px; height: 24px; }
.feature h2 { font-size: var(--text-lg); margin: 0 0 var(--space-2); }
.feature p { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.tone-orange { background: var(--color-primary-soft); color: var(--color-primary); }
.tone-sky { background: var(--color-info-soft); color: var(--color-info); }
.tone-green { background: var(--color-success-soft); color: var(--color-success-text); }
@media (max-width: 760px) {
  .features { grid-template-columns: 1fr; }
  .hero h1 { font-size: var(--text-2xl); }
}

/* ── 앱 화면 ──────────────────────────────────────────── */
.app { min-height: 100vh; display: grid; grid-template-rows: var(--topbar-height) 1fr; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-areas: "top top" "side main"; }

.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-4) 0 var(--space-5);
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
/* 왼쪽: 웅진 로고 | CRM(굵게, 진회색) + 주황 점 */
.topbar-brand { display: inline-flex; align-items: center; gap: var(--space-3); height: 40px; padding: 0 var(--space-1); text-decoration: none; color: var(--color-text); border-radius: var(--radius-sm); flex: none; }
.topbar-brand img { height: 28px; width: auto; display: block; }
.brand-sep { width: 1px; height: 22px; background: #C9CED4; }
.brand-product { position: relative; display: inline-flex; align-items: flex-start; font-weight: 800; font-size: 19px; line-height: 1; letter-spacing: .02em; color: #3A444A; }
.brand-dot { width: 6px; height: 6px; margin-left: 3px; border-radius: 50%; background: var(--logo-orange, #FA7400); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); min-width: 0; }

/* 회사 칩: 연한 배경 + 건물 아이콘(또는 회사 로고) + 회사명(길면 말줄임) */
.tenant-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; max-width: 280px; height: 32px;
  padding: 0 var(--space-3); border-radius: var(--radius-pill); background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text);
}
.tenant-chip svg { width: 16px; height: 16px; flex: none; color: var(--color-text-muted); }
.tenant-chip-logo { height: 20px; width: auto; max-width: 72px; object-fit: contain; flex: none; }
.tenant-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.nav-toggle { display: none; }

/* 사용자 사진(없으면 이니셜 원형) */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--color-primary-soft); color: var(--color-primary); font-weight: var(--weight-bold); font-size: var(--text-sm); flex: none; object-fit: cover; }
img.avatar { background: var(--color-surface-sunken); box-shadow: inset 0 0 0 1px rgba(58, 68, 74, .08); }
.avatar-sm { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar-lg { width: 96px; height: 96px; font-size: 36px; }
.person { display: inline-flex; align-items: center; gap: var(--space-2); vertical-align: middle; }

/* 역할 배지: 슈퍼관리자(주황) · 관리자(진회색) · 사용자(연회색) */
.role-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--radius-sm); font-size: 11px; font-weight: var(--weight-semibold); line-height: 1; white-space: nowrap; }
.role-super { background: var(--color-primary-soft); color: var(--color-primary); }
.role-admin { background: #3A444A; color: #FFFFFF; }
.role-member { background: var(--color-surface-sunken); color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* 사용자 메뉴(details 기반, JS 없이 동작) */
.user-menu { position: relative; }
.user-menu > summary {
  list-style: none; display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-2) 0 var(--space-1); cursor: pointer;
  border-radius: var(--radius); font-size: var(--text-sm);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--color-surface-sunken); }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.user-name { font-weight: var(--weight-semibold); line-height: 1.2; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-caret { width: 16px; height: 16px; color: var(--color-text-muted); transition: transform .15s ease; }
.user-menu[open] .user-menu-caret { transform: rotate(180deg); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--space-1)); width: 280px; z-index: 40;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(58, 68, 74, .12); padding: var(--space-2);
}
.user-menu-panel .who { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-2); }
.user-menu-panel .who .avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }
.who-text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.who-text strong, .who-tenant { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-panel a, .user-menu-panel .logout-form button {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm);
  font: inherit; font-size: var(--text-sm); text-align: left; color: var(--color-text); text-decoration: none;
  background: none; border: 0; cursor: pointer;
}
.user-menu-panel svg { width: 18px; height: 18px; flex: none; color: var(--color-text-muted); }
.user-menu-panel a:hover, .user-menu-panel .logout-form button:hover { background: var(--color-surface-sunken); }
.menu-sep { height: 1px; background: var(--color-border); margin: var(--space-2) 0; }
.menu-language { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-1) 0 var(--space-3); margin: 0; }
.menu-label { display: inline-flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--color-surface-sunken); }
.segmented button { min-height: 30px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--text-xs); color: var(--color-text-muted); cursor: pointer; }
.segmented button.active { background: var(--color-surface); color: var(--color-text); font-weight: var(--weight-semibold); box-shadow: 0 1px 2px rgba(58, 68, 74, .12); }
.logout-form { margin: 0; }

.sidebar {
  grid-area: side; position: sticky; top: var(--topbar-height); height: calc(100vh - var(--topbar-height)); overflow-y: auto;
  background: var(--color-surface); border-right: 1px solid var(--color-border); padding: var(--space-4) var(--space-3);
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-muted); letter-spacing: .04em; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius);
  color: var(--color-text); text-decoration: none; font-weight: var(--weight-medium);
}
.nav-item svg { width: 18px; height: 18px; flex: none; color: var(--color-text-muted); }
a.nav-item:hover { background: var(--color-surface-sunken); color: var(--color-text); }
a.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: var(--weight-bold); }
a.nav-item.active svg { color: var(--color-primary); }
a.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--color-accent); }
.nav-item[aria-disabled="true"] { color: var(--color-text-muted); cursor: default; }
.nav-item .badge { margin-left: auto; }

.main { grid-area: main; min-width: 0; padding: var(--space-8) var(--space-8) var(--space-12); }
.main-inner { max-width: var(--content-max); margin: 0 auto; }
.app-footer { max-width: var(--content-max); margin: var(--space-12) auto 0; font-size: var(--text-xs); color: var(--color-text-muted); }

.nav-backdrop { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: calc(-1 * var(--space-2));
    background: none; border: 0; border-radius: var(--radius); color: var(--color-text); cursor: pointer;
  }
  .nav-toggle:hover { background: var(--color-surface-sunken); }
  .nav-toggle svg { width: 22px; height: 22px; }
  .sidebar {
    position: fixed; top: var(--topbar-height); left: 0; bottom: 0; height: auto; width: min(280px, 85vw); z-index: 25;
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s;
    box-shadow: 8px 0 24px rgba(58, 68, 74, .12);
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; }
  .app.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar-height) 0 0 0; z-index: 20; background: rgba(58, 68, 74, .35); border: 0; }
  .main { padding: var(--space-6) var(--space-4) var(--space-10); }
}
/* 휴대폰 폭: 회사 칩·이름·역할은 숨기고 사진만(메뉴 안에서 이름·역할·회사 확인) */
@media (max-width: 720px) {
  .tenant-chip, .user-meta, .user-menu-caret { display: none; }
  .user-menu > summary { padding: 0 var(--space-1); }
  .user-menu-panel { width: min(300px, calc(100vw - 16px)); right: -4px; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 var(--space-2) 0 var(--space-4); gap: var(--space-2); }
  .topbar-brand { gap: var(--space-2); }
  .topbar-brand img { height: 24px; }
  .brand-product { font-size: 17px; }
}

/* 대시보드 */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.dash-grid .card + .card { margin-top: 0; }
.dash-action { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-5); text-decoration: none; color: var(--color-text); }
.dash-action .feature-icon { margin: 0; flex: none; }
.dash-action > span:last-child { display: flex; flex-direction: column; gap: var(--space-1); }
a.dash-action:hover { border-color: var(--color-primary); color: var(--color-text); }
.dash-action.is-soon { box-shadow: none; background: var(--color-bg); }

/* 로그인 */
.login-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: space-between; }

/* 명함 인식 */
.ocr-gap { margin-top: var(--space-4); }
.ocr-fields col.col-label { width: 128px; }
.ocr-fields col.col-conf { width: 88px; }
.ocr-fields tbody th { font-weight: var(--weight-semibold); white-space: nowrap; vertical-align: top; padding-top: calc(var(--space-3) + 10px); }
.ocr-fields td { vertical-align: top; }
.ocr-fields td.num { padding-top: calc(var(--space-3) + 9px); }
.ocr-fields td.value { padding-top: calc(var(--space-3) + 8px); white-space: normal; overflow-wrap: anywhere; }
.ocr-note { display: block; margin-top: var(--space-1); font-size: var(--text-sm); color: var(--color-warning-text); }
.address-row { display: grid; grid-template-columns: minmax(96px, 168px) minmax(0, 1fr); gap: var(--space-3); }
.address-row .field > label { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-muted); }
.ocr-line { padding: 2px 0; }
@media (max-width: 640px) {
  .ocr-fields colgroup, .ocr-fields thead { display: none; }
  .ocr-fields tbody tr { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .ocr-fields tbody th, .ocr-fields tbody td { display: block; padding: 0; border: 0; }
  .ocr-fields tbody th { grid-column: 1; align-self: center; }
  .ocr-fields tbody td.num { grid-column: 2; grid-row: 1; padding: 0; align-self: center; }
  .ocr-fields tbody td:not(.num) { grid-column: 1 / -1; padding-top: 0; }
  .ocr-fields td.value { padding-top: 0; }
  .address-row { grid-template-columns: 1fr; }
}

/* 긴 화면에서도 왼쪽 메뉴 열의 배경·구분선이 끝까지 이어지도록 */
@media (min-width: 961px) {
  .app { background: linear-gradient(to right, var(--color-surface) calc(var(--sidebar-width) - 1px), var(--color-border) calc(var(--sidebar-width) - 1px), var(--color-border) var(--sidebar-width), transparent var(--sidebar-width)); }
}

/* 공개 화면 오른쪽 위 언어 전환·하단 약관 링크 */
.public { position: relative; }
.public-top { position: absolute; top: var(--space-4); right: var(--space-4); }
.public-footer { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.footer-links { display: flex; gap: var(--space-4); }
.footer-links a { color: var(--color-text-muted); }
.app-footer { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.app-footer a { color: var(--color-text-muted); }
@media (max-width: 480px) {
  .public { padding-top: calc(var(--space-6) + 40px); }
  .public-top { top: var(--space-3); right: var(--space-3); }
}

/* 메뉴 이름은 한 줄(길면 말줄임), "준비 중" 배지는 오른쪽 */
.nav-item { white-space: nowrap; overflow-wrap: normal; }
.nav-item .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
