.warn-hint {
  color: #b45309;
  font-weight: 500;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #eef2ff 0%, #f8fafc 45%, #f1f5f9 100%);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px 28px 22px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.35rem;
}

.login-sub {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.92rem;
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-primary {
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.login-primary:hover {
  background: #1d4ed8;
}

.login-foot {
  margin-top: 14px;
  text-align: center;
}

.app-footer {
  padding: 6px 16px 10px;
  text-align: right;
  font-size: 12px;
  color: #64748b;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions .secondary {
  flex: 1 1 160px;
}

.intake-banner {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.intake-banner.hidden {
  display: none;
}

.intake-banner strong {
  color: #c2410c;
}

.intake-banner .secondary {
  flex-shrink: 0;
}

.org-notice-banner {
  margin: 10px 0 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e3a8a;
  font-size: 14px;
}

.org-notice-banner.hidden {
  display: none;
}

.org-notice-banner.warn {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.org-notice-banner .notice-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.archived-readonly-banner {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px dashed #9ca3af;
  color: #4b5563;
  font-size: 13px;
}

.archived-readonly-banner.hidden {
  display: none;
}

.todo-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.todo-list li.warn {
  color: #b45309;
}

.elim-panel {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--lt-border);
}

.edit-panel-subtitle {
  margin: 0 0 8px;
  font-size: 14px;
  color: #b91c1c;
}

button.danger {
  background: #b91c1c;
  color: #fff;
  border: none;
}

button.danger:hover {
  background: #991b1b;
}

.catalog-diff-add {
  color: #15803d;
}

.catalog-diff-remove {
  color: #b91c1c;
}

.catalog-diff-change {
  color: #b45309;
}

body {
  font-family: var(--lt-font);
  background: var(--lt-bg);
  color: var(--lt-text);
  margin: 0;
}

.app-topbar {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--lt-shadow-lg);
}

.app-topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.app-topbar .sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.app-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.app-sidebar {
  width: 200px;
  background: var(--lt-surface);
  border-right: 1px solid var(--lt-border);
  padding: 12px 8px;
  flex-shrink: 0;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--lt-muted);
  font-size: 14px;
  cursor: pointer;
}

.nav-item:hover {
  background: #f1f5f9;
  color: var(--lt-text);
}

.nav-item.active {
  background: #eff6ff;
  color: var(--lt-accent);
  font-weight: 600;
}

.nav-item.hidden {
  display: none;
}

.app-main {
  flex: 1;
  padding: 20px 24px 40px;
  max-width: 1200px;
}

.page-panel.hidden {
  display: none;
}

.breadcrumb {
  font-size: 13px;
  color: var(--lt-muted);
  margin-bottom: 12px;
}

.breadcrumb a {
  color: var(--lt-accent);
  cursor: pointer;
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.drill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.drill-card {
  background: var(--lt-surface);
  border: 1px solid var(--lt-border);
  border-radius: var(--lt-radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  box-shadow: var(--lt-shadow);
}

.drill-card:hover {
  border-color: var(--lt-accent);
  box-shadow: var(--lt-shadow-lg);
}

.drill-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.drill-card .mini {
  font-size: 12px;
  color: var(--lt-muted);
  line-height: 1.6;
}

.scope-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 12px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
}

.scope-tabs button {
  margin: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--lt-muted);
  padding: 6px 14px;
  font-size: 13px;
}

.scope-tabs button.active {
  background: var(--lt-surface);
  color: var(--lt-accent);
  font-weight: 600;
  box-shadow: var(--lt-shadow);
}

.card {
  background: var(--lt-surface);
  border-radius: var(--lt-radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--lt-shadow);
  border: 1px solid var(--lt-border);
}

.metric {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--lt-border);
  border-radius: 10px;
}

.metric.warn b {
  color: var(--lt-warning);
}

.metric.ok b {
  color: var(--lt-success);
}

.drill-card.active {
  border-color: var(--lt-accent);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.drill-card.loading {
  opacity: 0.55;
  pointer-events: none;
}

#overviewDetailContent.detail-loading {
  opacity: 0.72;
}

.detail-skeleton-cell {
  color: #888;
  padding: 24px;
  text-align: center;
}

.scope-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
}

.scope-banner-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.scope-toast {
  font-size: 12px;
  color: var(--lt-success);
  font-weight: 600;
}

.scope-back {
  margin: 0;
  white-space: nowrap;
}

.dashboard-loading {
  font-size: 13px;
  color: var(--lt-accent);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}

.dashboard-loading.hidden {
  display: none;
}

.import-label {
  display: inline-block;
}

.import-label.hidden {
  display: none;
}

.script-list-bilingual .mini-line {
  font-size: 12px;
  color: var(--lt-muted);
  line-height: 1.5;
}

.role-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3;
  margin-left: 6px;
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* --- Global / button loading --- */
#apiBusyBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2000;
  background: transparent;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s;
}

#apiBusyBar.active {
  opacity: 1;
}

#apiBusyBar::before {
  content: "";
  display: block;
  width: 35%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #2563eb, #38bdf8, transparent);
  animation: lt-busy-slide 0.9s linear infinite;
}

@keyframes lt-busy-slide {
  from { transform: translateX(-120%); }
  to { transform: translateX(420%); }
}

@keyframes lt-spin {
  to { transform: rotate(360deg); }
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: lt-spin 0.65s linear infinite;
}

button.secondary .btn-spinner,
button.secondary.is-loading .btn-spinner {
  border-color: rgba(30, 58, 95, 0.2);
  border-top-color: #1e3a5f;
}

button.is-loading {
  opacity: 0.88;
  cursor: wait;
}

button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--lt-accent);
  margin-left: 8px;
}

.inline-status.hidden {
  display: none;
}

/* --- Migrated from index.html inline styles (W4) --- */
* {
  box-sizing: border-box;
}

h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

label {
  display: block;
  margin: 8px 0 4px;
  font-size: 13px;
  color: var(--lt-muted);
}

.app-main input,
.app-main select,
.app-main textarea,
#loginSection input,
#loginSection select {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--lt-border);
  border-radius: 8px;
  background: var(--lt-surface);
  color: var(--lt-text);
}

.app-main input,
.app-main select,
#loginSection input,
#loginSection select {
  width: 100%;
  max-width: 320px;
}

.app-main button:not(.nav-item),
#loginSection button,
.modal-panel button {
  background: var(--lt-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-right: 8px;
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 14px;
}

.app-main button.secondary:not(.nav-item),
#loginSection button.secondary,
.modal-panel button.secondary {
  background: #6b7280;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.metric b {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.metric span {
  display: block;
  font-size: 11px;
  color: var(--lt-muted);
  margin-top: 4px;
  text-transform: none;
}

.metric-badge {
  display: inline-block;
  font-size: 22px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  line-height: 1.15;
  vertical-align: baseline;
}

.metric b .metric-badge {
  font-size: 22px;
  font-weight: 700;
}

.metric-badge.warn {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--lt-border);
  padding: 8px;
  text-align: left;
}

th {
  background: #fafafa;
}

tr.lock-row {
  cursor: pointer;
}

tr.lock-row.selected {
  background: #eef4ff;
}

tr.lock-row:hover {
  background: #f8fafc;
}

.edit-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--lt-border);
}

.edit-panel textarea {
  width: 100%;
  max-width: 480px;
  min-height: 72px;
}

.warn-text {
  color: var(--warn, #b45309);
}

.ok-msg {
  color: var(--lt-success);
  font-size: 13px;
}

.err {
  color: var(--lt-danger);
  font-size: 13px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.filter-row label {
  margin: 0;
}

.filter-row input,
.filter-row select {
  max-width: 160px;
}

.filter-row-action {
  align-self: flex-end;
}

.filter-row-action button {
  margin-top: 0;
}

.edit-panel-title {
  font-size: 15px;
  margin: 0 0 8px;
}

.period-btns button.active {
  background: var(--lt-accent);
}

.hint {
  font-size: 13px;
  color: var(--lt-muted);
  margin: 0 0 8px;
}

.hidden {
  display: none !important;
}

#loginSection {
  max-width: 420px;
  margin: 48px auto;
}

#loginSection input {
  margin-bottom: 4px;
}

.chart-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

canvas#empChart {
  max-width: 100%;
  height: auto;
}

.export-row {
  margin: 8px 0 0;
}

tr.report-row-clickable {
  cursor: pointer;
}

tr.report-row-clickable:hover {
  background: #f8fafc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-panel {
  background: var(--lt-surface);
  border-radius: var(--lt-radius);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  padding: 20px;
  box-shadow: var(--lt-shadow-lg);
}

.modal-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.miss-group {
  margin-bottom: 16px;
}

.miss-group h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #444;
}

.miss-item {
  border: 1px solid var(--lt-border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.miss-item b {
  display: block;
  margin-bottom: 4px;
}

.miss-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

.miss-tag.due {
  background: #fef3c7;
  color: #92400e;
}

.miss-tag.overdue {
  background: #fee2e2;
  color: #991b1b;
}

/* --- W2/W3: Overview sections + breadcrumb --- */
.breadcrumb {
  padding: 8px 12px;
  background: var(--lt-surface);
  border: 1px solid var(--lt-border);
  border-radius: 10px;
  margin-bottom: 10px;
}

.breadcrumb a.bc-active {
  color: var(--lt-text);
  font-weight: 600;
  pointer-events: none;
  text-decoration: none;
}

.overview-section {
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--lt-accent);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.section-head h2 {
  margin: 0;
}

.hq-only-block.hidden,
.company-only-block.hidden {
  display: none !important;
}

.detail-placeholder {
  padding: 24px 16px;
  text-align: center;
  color: var(--lt-muted);
  font-size: 14px;
  background: #f8fafc;
  border: 1px dashed var(--lt-border);
  border-radius: 10px;
}

/* --- W8: Lock library pagination --- */
.pagination-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.pagination-row .page-info {
  font-size: 13px;
  color: var(--lt-muted);
}

/* --- W11: Catalog preview --- */
.catalog-preview {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--lt-border);
  border-radius: 10px;
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.catalog-preview.empty {
  color: var(--lt-muted);
  font-family: var(--lt-font);
}

/* --- W12: Global toast --- */
#globalToast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--lt-shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

#globalToast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#globalToast.info {
  background: #1e3a5f;
  color: #fff;
}

#globalToast.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

#globalToast.warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
}

#globalToast.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* --- W4: shared utility classes (replace inline styles in app.js) --- */
.miss-group p.text-muted {
  margin: 0;
}

.text-danger {
  color: #b91c1c;
}

.err-pre-wrap {
  white-space: pre-wrap;
}

.btn-inline-gap {
  margin: 0 4px 0 0;
}

.btn-inline-gap-zero {
  margin: 0;
}

.btn-inline-sm {
  margin: 0;
  padding: 4px 8px;
  font-size: 12px;
}

.breadcrumb-muted {
  color: #888;
}

/* --- W6: KPI badge variants --- */
.metric-badge.ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.metric-badge.danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.metric.danger b {
  color: #991b1b;
}

/* --- W13: mobile responsive layout (full features, not read-only) --- */
body.mobile-layout .app-topbar {
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
}

body.mobile-layout .app-topbar h1 {
  font-size: 18px;
}

body.mobile-layout .app-sidebar {
  position: sticky;
  top: 0;
  z-index: 100;
  border-right: none;
  border-bottom: 1px solid var(--lt-border);
  padding: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-layout .nav-item {
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  padding: 10px 14px;
  white-space: nowrap;
}

body.mobile-layout .app-main {
  padding: 12px 12px 32px;
  max-width: none;
}

body.mobile-layout .filter-row,
body.mobile-layout .scope-tabs {
  flex-wrap: wrap;
  gap: 8px;
}

body.mobile-layout .filter-row input,
body.mobile-layout .filter-row select,
body.mobile-layout .filter-row button {
  min-height: 40px;
}

body.mobile-layout .emp-table-wrap,
body.mobile-layout table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-layout .drill-grid {
  grid-template-columns: 1fr;
}

body.mobile-layout .metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.mobile-layout .metric b {
  font-size: 22px;
}

body.mobile-layout .card,
body.mobile-layout .page-panel > .card {
  padding: 12px;
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
  }
}
