/* ── 공통 변수 ── */
:root {
  --primary:      #2e5fa3;
  --primary-dark: #1e3a5f;
  --primary-light:#e8f0fb;
  --success:      #198754;
  --warning:      #ffc107;
  --danger:       #dc3545;
  --border-radius: 10px;
}

/* ── 레이아웃 ── */
body { background: #f0f2f5; font-family: 'Segoe UI', 'Malgun Gothic', sans-serif; }

.navbar-app {
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 0;
  border-bottom: 1px solid #e8ebef;
  background: rgba(255, 255, 255, .97);
  color: #191f28;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .06);
  backdrop-filter: blur(14px);
}

.app-shell-top {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 9px 20px;
}

.app-shell-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  color: #191f28;
  font-size: 1.02rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -.025em;
}

.app-shell-brand:hover { color: #1769e0; }

.app-shell-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: #3182f6;
  color: #fff;
}

.app-shell-company {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
}

.app-shell-company label {
  flex: 0 0 auto;
  margin: 0;
  color: #6b7684;
  font-size: .75rem;
  font-weight: 700;
}

.app-shell-company .form-select {
  min-height: 40px;
  border-color: #e5e8eb;
  border-radius: 11px;
  background-color: #f7f8fa;
  color: #333d4b;
  font-weight: 650;
}

.app-shell-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.app-shell-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 0 6px;
  color: #6b7684;
  font-size: .8rem;
}

.app-shell-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell-menu-toggle,
.app-shell-logout {
  min-height: 40px;
  border-radius: 11px;
  font-size: .8rem;
  font-weight: 700;
}

.app-shell-menu-toggle {
  border: 1px solid #dbe8fb;
  background: #eef6ff;
  color: #1769e0;
}

.app-shell-menu-toggle:hover {
  border-color: #b7d4fa;
  background: #e3f0ff;
  color: #0b4da2;
}

.app-shell-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #e5e8eb;
  background: #fff;
  color: #4e5968;
}

.app-shell-logout:hover {
  border-color: #cfd5dc;
  background: #f7f8fa;
  color: #191f28;
}

#appMenuPanel { border-top: 1px solid #f0f2f4; }

.app-menu-tree {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 20px 14px;
}

.app-menu-loading {
  grid-column: 1 / -1;
  padding: 12px;
  color: #8b95a1;
  font-size: .82rem;
}

.app-menu-group {
  min-width: 0;
  border: 1px solid #edf0f2;
  border-radius: 14px;
  background: #f9fafb;
  overflow: hidden;
}

.app-menu-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 12px;
  color: #333d4b;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 750;
  list-style: none;
  user-select: none;
}

.app-menu-group > summary::-webkit-details-marker { display: none; }
.app-menu-group > summary:hover { background: #f2f6fb; }
.app-menu-group > summary .app-menu-chevron {
  margin-left: auto;
  transition: transform .18s ease;
}
.app-menu-group:not([open]) > summary .app-menu-chevron { transform: rotate(-90deg); }

.app-menu-children {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 9px 10px;
}

.app-menu-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 10px;
  color: #4e5968;
  font-size: .78rem;
  font-weight: 650;
  text-decoration: none;
}

.app-menu-link:hover {
  background: #eef6ff;
  color: #1769e0;
}

.app-menu-link.active {
  background: #3182f6;
  color: #fff;
  box-shadow: 0 5px 12px rgba(49, 130, 246, .2);
}

.app-menu-empty {
  padding: 8px 4px;
  color: #8b95a1;
  font-size: .76rem;
}

.card-app {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

.card-app .card-header {
  background: var(--primary);
  color: #fff;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  font-weight: 700;
  padding: .75rem 1.2rem;
}

/* ── Tabulator 커스텀 ── */
.tabulator .tabulator-header {
  background: var(--primary) !important;
  border-bottom: none;
}
.tabulator .tabulator-col {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,.18) !important;
}
.tabulator .tabulator-col .tabulator-col-title { color: #fff !important; }
.tabulator .tabulator-col .tabulator-arrow    { border-top-color: rgba(255,255,255,.7) !important; }
.tabulator-row.tabulator-selected             { background: var(--primary-light) !important; }
.tabulator-row:hover                          { background: #f5f8ff !important; }
.tabulator .tabulator-footer                  { background: #fafafa; border-top: 1px solid #e0e0e0; }

/* ── 툴바 ── */
.toolbar {
  background: #fff;
  border-radius: var(--border-radius);
  padding: .7rem 1rem;
  margin-bottom: .9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.toolbar .sep {
  width: 1px; height: 26px;
  background: #dee2e6;
  margin: 0 .2rem;
}

/* ── 업로드 폼 ── */
.upload-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .7rem 1.2rem;
  border-bottom: 1px solid #f0f0f0;
}
.upload-row:last-child { border-bottom: none; }
.upload-label {
  min-width: 200px;
  font-size: .88rem;
  font-weight: 600;
  color: #333;
}
.file-name {
  font-size: .8rem;
  color: #888;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 보고서 테이블 ── */
#reportTable thead th  { background: var(--primary); color: #fff; }
#reportTable tfoot td  { background: #eef2fb; font-weight: 700; border-top: 2px solid var(--primary); }
#reportTable tbody tr:hover { background: #f5f8ff; }

/* ── 로그인 ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f2f5 0%, #dce6f5 100%);
}
.login-card {
  width: min(380px, calc(100% - 24px));
  border: none;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(30,58,95,.15);
}
.login-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  border-radius: 14px 14px 0 0;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}
.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #4e5968;
  font-size: .86rem;
}
.login-options .form-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin: 0;
}
.login-options .form-check-input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  cursor: pointer;
}
.login-options .form-check-label { cursor: pointer; }
.login-security-note {
  margin-top: 13px;
  color: #8b95a1;
  font-size: .73rem;
  text-align: center;
}
@media (max-width: 380px) {
  .login-options { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (max-width: 767.98px) {
  .navbar-app { margin-bottom: 10px !important; }
  .app-shell-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding: 9px 12px 10px;
  }
  .app-shell-brand { min-height: 42px; }
  .app-shell-logo { width: 36px; height: 36px; }
  .app-shell-company {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }
  .app-shell-company label { width: 32px; }
  .app-shell-company .form-select {
    flex: 1 1 auto;
    min-height: 46px;
    font-size: 16px;
  }
  .app-shell-actions {
    grid-column: 2;
    grid-row: 1;
    margin-left: 0;
  }
  .app-shell-user { display: none; }
  .app-shell-menu-toggle,
  .app-shell-logout {
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 8px 10px;
  }
  .app-shell-menu-toggle span,
  .app-shell-logout span { display: none; }
  #appMenuPanel {
    max-height: calc(100dvh - 116px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .app-menu-tree {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px 12px 14px;
  }
  .app-menu-group { border-radius: 16px; background: #fff; }
  .app-menu-group > summary {
    min-height: 50px;
    padding: 12px 14px;
    font-size: .92rem;
  }
  .app-menu-children {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 10px 11px;
  }
  .app-menu-link {
    min-height: 48px;
    padding: 10px 11px;
    border-radius: 13px;
    background: #f7f8fa;
    font-size: .82rem;
  }
}

@media (max-width: 390px) {
  .app-menu-children { grid-template-columns: 1fr; }
}
