@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css");

:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #d6dde7;
  --text: #1d2939;
  --muted: #697586;
  --navy: #182638;
  --blue: #1f6fd1;
  --cyan: #008da6;
  --green: #2f9461;
  --amber: #d98c21;
  --red: #d45252;
  --header: #0f2033;
  --sidebar: #122236;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
}

.sidebar {
  width: 236px;
  background: var(--sidebar);
  color: #eef4fb;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 2px 0 8px rgba(16, 24, 40, .08);
}
.brand { display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.12); background: #0c1d30; }
.brand-mark { width: 36px; height: 28px; display: grid; place-items: center; background: #fff; color: #123a66; border-radius: 3px; font-weight: 800; font-size: 12px; letter-spacing: 0; }
.brand strong { display: block; font-size: 14px; letter-spacing: .2px; }
.brand span { display: block; color: #9fb0c2; font-size: 11px; margin-top: 1px; }
nav { display: grid; gap: 2px; padding: 12px 10px; }
.nav-item {
  border: 0;
  color: #c8d4e2;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.nav-item.active, .nav-item:hover { background: #1d3855; color: #fff; }
.sync-box {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.12);
  border-radius: 0;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #0f2033;
}
.sync-box span { color: #aebccc; font-size: 12px; }
.sync-box strong { font-size: 14px; }
.sync-box.is-syncing strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
}
.sync-box.is-syncing strong::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255,255,255,.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sync-spin .75s linear infinite;
}
.sync-box small {
  color: #8fa2b7;
  font-size: 11px;
  line-height: 1.35;
}
.ms-auth-box {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(56, 134, 216, .16);
}
.ms-auth-box[hidden] { display: none; }
.ms-auth-box b {
  color: #fff;
  font-size: 12px;
}
.ms-auth-box span {
  color: #d9e8f8;
  font-size: 12px;
  line-height: 1.35;
  word-break: keep-all;
}
.ms-auth-box a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #102a43;
  background: #fff;
  border-radius: 4px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.ms-auth-actions {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 6px;
}
.ms-auth-actions button {
  padding: 7px 8px;
  border-color: rgba(255,255,255,.38);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.sync-box button:disabled {
  cursor: wait;
  opacity: .62;
}
button {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
  cursor: pointer;
  font: inherit;
}
.sync-box button, .panel-head button, form button, .upload-box button {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

.app { flex: 1; min-width: 0; padding: 0 24px 36px; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 -24px 0;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  min-height: 58px;
}
h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: 0; font-weight: 700; }
p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.user-badge {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 190px;
  color: #52677f;
  font-size: 12px;
}
.user-badge span {
  color: #102a43;
  font-weight: 800;
}
.user-badge strong {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 -24px 16px;
  padding: 12px 24px;
  background: #eaf1f9;
  border-bottom: 1px solid #c7d5e5;
}
.filter-title { display: grid; gap: 2px; }
.filter-title strong { color: #123a66; font-size: 14px; }
.filter-title span { color: #52677f; font-size: 12px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.filters label {
  min-width: 132px;
  color: #123a66;
  font-weight: 700;
}
select, input {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
}
.filters select {
  min-height: 38px;
  border-color: #8fb3dc;
  background: #fff;
  color: #102a43;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.view { display: none; }
.view.active { display: block; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.kpis article, .report-summary div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 11px 13px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.kpis span, .report-summary span { color: var(--muted); font-size: 12px; display: block; }
.kpis strong, .report-summary strong { font-size: 22px; line-height: 1.1; display: inline-block; margin-top: 5px; }
.kpis em, .report-summary em { color: var(--muted); font-style: normal; margin-left: 4px; }
.report-summary strong { font-size: 19px; }
.report-summary div { padding: 10px 11px; }
.collection-status-card { margin-bottom: 10px; }
.collection-chart-card { margin-bottom: 10px; }
.collection-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.collection-summary div {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #d9e3ef;
  background: #f8fbff;
  border-radius: 4px;
}
.collection-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.collection-summary strong {
  display: inline-block;
  margin-top: 5px;
  color: #102a43;
  font-size: 20px;
  line-height: 1.1;
}
.collection-summary em {
  margin-left: 4px;
  color: var(--muted);
  font-style: normal;
}

.grid { display: grid; gap: 10px; margin-top: 10px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 8px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head span { color: var(--muted); font-size: 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }

.chart {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chart svg {
  width: 100%;
  display: block;
  overflow: visible;
}
#dashboard .chart,
#dashboard .chart svg {
  height: 280px !important;
}
.chart-label {
  fill: #344054;
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.chart-value {
  fill: #1d2939;
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 800;
}
.chart-value-light {
  fill: #fff;
}
.chart-axis {
  fill: #667085;
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.chart-legend {
  fill: #344054;
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.goal-bars { display: grid; gap: 16px; padding-top: 8px; min-height: 280px; align-content: center; }
.goal-row { display: grid; grid-template-columns: 92px 1fr 54px; gap: 10px; align-items: center; font-size: 13px; }
.track { height: 18px; background: #eef2f6; border-radius: 2px; overflow: hidden; }
.fill { height: 100%; background: var(--blue); }

.weekly-report-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 4px;
}
.weekly-report-tools strong {
  display: block;
  font-size: 15px;
}
.weekly-report-tools span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.weekly-report-tools button {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 800;
}
.weekly-layout { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; }
.weekly-layout > .panel > .panel-head h2 {
  font-size: 18px;
  font-weight: 900;
}
.weekly-layout > .panel > .panel-head h2 small {
  margin-left: 8px;
  color: #52677f;
  font-size: 15px;
  font-weight: 800;
}
.weekly-export-stage .panel-head h2 {
  font-size: 24px;
  font-weight: 900;
}
.weekly-export-stage .panel-head h2 small {
  margin-left: 10px;
  color: #52677f;
  font-size: 20px;
  font-weight: 800;
}
.weekly-layout.single-division {
  grid-template-columns: 1fr 1.2fr;
}
.weekly-layout.single-division .weekly-cad-report {
  grid-column: auto;
  order: 1;
}
.weekly-layout.single-division .weekly-pipeline-report {
  order: 2;
}
.report-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.weekly-year-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.ios-unit-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ios-revenue-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.cadcam-unit-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.cadcam-revenue-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.entity-report-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.entity-debug {
  margin: 8px 0 4px;
  color: #52677f;
  font-size: 12px;
  font-weight: 700;
}
.entity-report-charts {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  gap: 12px;
}
.mini-panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  background: #fff;
}
.mini-panel .panel-head h2 {
  font-size: 13px;
  font-weight: 800;
}
.mini-panel .panel-head span {
  font-size: 11px;
}
.weekly-export-stage .mini-panel .panel-head h2 {
  font-size: 13px;
  font-weight: 700;
}
.weekly-export-stage .mini-panel .panel-head span {
  font-size: 11px;
}
.weekly-chart-grid {
  margin-top: 12px;
}
.cadcam-revenue-charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 12px;
}
.weekly-export-stage {
  position: fixed;
  left: -20000px;
  top: 0;
  width: 980px;
  padding: 22px 10px;
  background: #f5f7fa;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  font-size: 15px;
  z-index: -1;
}
.weekly-export-stage .panel {
  margin: 0;
  min-height: 500px;
  padding: 14px;
  border-radius: 4px;
  box-shadow: none;
}
.weekly-export-stage .weekly-cad-report {
  grid-column: auto;
}
.weekly-export-stage .chart,
.weekly-export-stage .chart svg {
  height: 310px !important;
}
.weekly-export-stage .chart {
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: visible;
  padding: 0 8px;
}
.weekly-export-stage .chart svg {
  width: calc(100% - 8px);
  max-width: 100%;
  margin: 0 auto;
}
.weekly-export-stage .cadcam-revenue-charts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.weekly-export-stage .cadcam-revenue-charts .mini-panel {
  min-width: 0;
}
.weekly-export-stage .report-summary {
  min-height: 74px;
}
.weekly-export-stage .report-summary div {
  padding: 12px 13px;
}
.weekly-export-stage .report-summary span {
  font-size: 13px;
}
.weekly-export-stage .report-summary strong {
  font-size: 23px;
}
.weekly-export-stage .chart-label {
  font-size: 16px;
}
.weekly-export-stage .chart-value {
  font-size: 15px;
}
.weekly-export-stage .chart-axis,
.weekly-export-stage .chart-legend {
  font-size: 13px;
}
.weekly-export-stage .weekly-pipeline-report .panel-head button,
.weekly-export-stage .weekly-pipeline-report .pipeline-filter,
.weekly-export-stage .weekly-pipeline-report th:last-child,
.weekly-export-stage .weekly-pipeline-report td:last-child {
  display: none;
}
.weekly-export-stage .weekly-pipeline-report .table-wrap {
  overflow: visible;
}
.weekly-export-stage .weekly-pipeline-report table {
  table-layout: fixed;
  width: 100%;
  font-size: 14px;
}
.weekly-export-stage .weekly-pipeline-report th,
.weekly-export-stage .weekly-pipeline-report td {
  padding: 8px 7px;
  white-space: normal;
  line-height: 1.35;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(1),
.weekly-export-stage .weekly-pipeline-report td:nth-child(1) {
  width: 34px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(2),
.weekly-export-stage .weekly-pipeline-report td:nth-child(2) {
  width: 74px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(3),
.weekly-export-stage .weekly-pipeline-report td:nth-child(3) {
  width: 90px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(4),
.weekly-export-stage .weekly-pipeline-report td:nth-child(4) {
  width: 170px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(5),
.weekly-export-stage .weekly-pipeline-report td:nth-child(5) {
  width: 110px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(6),
.weekly-export-stage .weekly-pipeline-report td:nth-child(6) {
  width: 84px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(7),
.weekly-export-stage .weekly-pipeline-report td:nth-child(7) {
  width: 44px;
}
.weekly-export-stage .weekly-pipeline-report th:nth-child(8),
.weekly-export-stage .weekly-pipeline-report td:nth-child(8) {
  width: auto;
  min-width: 260px;
  overflow-wrap: anywhere;
}
.pipeline-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}
.pipeline-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-right: 2px;
}
.pipeline-filter button {
  min-width: 34px;
  padding: 5px 10px;
  border-color: #b9c7d8;
  background: #fff;
  color: #52677f;
  font-weight: 800;
}
.pipeline-filter button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 1px 3px rgba(31, 111, 209, .22);
}
.pipeline-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.pipeline-summary div {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 4px;
  padding: 10px 11px;
}
.pipeline-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.pipeline-summary strong {
  display: inline-block;
  margin-top: 4px;
  font-size: 18px;
}
.pipeline-summary em {
  color: var(--muted);
  font-style: normal;
  margin-left: 3px;
  font-size: 12px;
}

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 9px; white-space: nowrap; text-align: right; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { text-align: left; }
th { background: #edf2f7; color: #1f344c; font-weight: 700; }
tbody tr:hover { background: #f7fafc; }
td input, td select { width: 100%; min-width: 90px; }
.row-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}
.row-actions button {
  padding: 5px 8px;
  font-size: 12px;
}
.row-actions button:last-child {
  color: var(--red);
  border-color: #efb3b3;
}
.detail-tools {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.detail-tools button {
  background: #fff;
  color: var(--blue);
  border-color: #9bbce2;
  font-weight: 700;
}
.detail-table {
  min-width: 1500px;
  font-size: 12px;
}
.detail-table th,
.detail-table td {
  padding: 7px 8px;
}
.detail-table th:nth-child(-n+12),
.detail-table td:nth-child(-n+12) {
  text-align: left;
}
.detail-table th:nth-child(8),
.detail-table td:nth-child(8),
.detail-table th:nth-child(12),
.detail-table td:nth-child(12) {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-box, .manual-form { display: grid; gap: 12px; }
.manual-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manual-form button { grid-column: 1 / -1; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list span {
  border: 1px solid var(--line);
  background: #f7fafc;
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 12px;
}
.target-list { display: grid; gap: 8px; }
.target-row { display: grid; grid-template-columns: 1fr 90px 90px; gap: 8px; align-items: center; }
.target-row input { text-align: right; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 32, 51, .42);
  z-index: 20;
}
.modal-backdrop.active { display: grid; }
.modal {
  width: min(720px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 20px 48px rgba(16, 24, 40, .22);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
}
.modal-head button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.pipeline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}
.pipeline-form .wide,
.modal-actions {
  grid-column: 1 / -1;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.modal-actions button[type="submit"] {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

@media (max-width: 980px) {
  body { display: block; }
  .sidebar { width: auto; min-height: auto; }
  .app { padding: 18px; }
  .topbar, .weekly-layout, .filterbar { display: block; }
  .topbar, .filterbar { margin-left: -18px; margin-right: -18px; }
  .filters { justify-content: flex-start; margin-top: 12px; }
  .kpis, .grid.two, .report-summary, .collection-summary, .pipeline-summary, .detail-tools, .pipeline-form { grid-template-columns: 1fr; }
}
