/* ===================================
   성심로지스 배차관리센터 V1 - 메인 스타일
   =================================== */

:root {
  --primary: #1a3c6e;
  --primary-light: #2557a7;
  --secondary: #e8720c;
  --success: #2e7d32;
  --danger: #c62828;
  --warning: #f57c00;
  --info: #0277bd;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --border: #dde1e7;
  --text: #1a1a2e;
  --text-light: #555;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans KR', sans-serif; background: var(--bg); color: var(--text); font-size: 13px; }

/* ===== 헤더 ===== */
#main-header { background: var(--primary); color: white; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.header-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; }
.header-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 28px; }
.logo-title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.logo-sub { font-size: 11px; opacity: 0.8; }
.header-info { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.header-info span { font-size: 11px; opacity: 0.85; }
.header-policy { font-size: 10px !important; opacity: 0.7 !important; }
.header-cloud-row { display: flex; align-items: center; gap: 8px; }
.cloud-toggle-btn {
  background: #9e9e9e; color: white; border: none;
  padding: 3px 10px; border-radius: 12px; cursor: pointer;
  font-size: 10px; font-family: inherit; font-weight: 600;
  transition: background 0.2s;
}
.cloud-toggle-btn:hover { opacity: 0.85; }

/* ===== 네비게이션 ===== */
#main-nav { display: flex; overflow-x: auto; background: rgba(0,0,0,0.2); padding: 0 8px; }
.nav-tab { background: none; border: none; color: rgba(255,255,255,0.75); padding: 10px 14px; cursor: pointer; font-size: 12px; font-family: inherit; white-space: nowrap; border-bottom: 3px solid transparent; transition: all 0.2s; }
.nav-tab:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-tab.active { color: white; border-bottom-color: var(--secondary); font-weight: 600; }
.nav-tab.admin-tab { color: rgba(255,200,100,0.8); }
.nav-tab.admin-tab.active { color: #ffd54f; border-bottom-color: #ffd54f; }

/* ===== 페이지 ===== */
#page-container { padding: 16px; min-height: calc(100vh - 100px); }
.page { display: none; }
.page.active { display: block; }
.page-content { max-width: 1600px; margin: 0 auto; }
.page-header { background: white; padding: 16px 20px; border-radius: var(--radius); margin-bottom: 16px; border-left: 5px solid var(--primary); box-shadow: var(--shadow); }
.page-header h1 { font-size: 18px; color: var(--primary); margin-bottom: 4px; }
.page-header p { color: var(--text-light); font-size: 12px; }
.admin-header { border-left-color: var(--secondary); }
.admin-header h1 { color: var(--secondary); }

/* ===== 홈 페이지 ===== */
.home-hero { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: white; padding: 32px; border-radius: var(--radius); margin-bottom: 20px; text-align: center; }
.home-hero h1 { font-size: 22px; margin-bottom: 8px; }
.hero-sub { font-size: 13px; opacity: 0.85; margin-bottom: 4px; }
.hero-policy { font-size: 11px; opacity: 0.7; }

/* 워크플로우 */
.workflow-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.workflow-section h2 { font-size: 15px; color: var(--primary); margin-bottom: 16px; }
.workflow-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; justify-content: center; }
.wf-step { background: var(--primary); color: white; padding: 12px 16px; border-radius: var(--radius); text-align: center; min-width: 100px; }
.wf-num { font-size: 18px; font-weight: 700; margin-bottom: 4px; color: var(--secondary); }
.wf-text { font-size: 11px; line-height: 1.4; }
.wf-arrow { font-size: 18px; color: var(--primary); font-weight: bold; }

/* 시트 안내 테이블 */
.sheet-nav-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.sheet-nav-section h2 { font-size: 15px; color: var(--primary); margin-bottom: 12px; }
.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th { background: var(--primary); color: white; padding: 8px 12px; text-align: left; font-size: 12px; }
.sheet-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.sheet-table tr:hover td { background: #f8f9ff; }
.admin-row td { background: #fffbf0; }
.admin-row:hover td { background: #fff3cd; }

/* 배지 */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 10px; font-weight: 600; }
.badge.staff { background: #e3f2fd; color: #1565c0; }
.badge.admin { background: #fff3e0; color: #e65100; }

/* 버튼 이동 */
.btn-go { background: var(--primary); color: white; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.btn-go:hover { background: var(--primary-light); }
.btn-go.admin { background: var(--secondary); }
.btn-go.admin:hover { background: #d4600a; }

/* 핵심 원칙 */
.principles-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.principles-section h2 { font-size: 15px; color: var(--primary); margin-bottom: 16px; }
.principles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.principle-card { padding: 16px; border-radius: var(--radius); text-align: center; }
.principle-card.speed { background: #e3f2fd; border: 2px solid #42a5f5; }
.principle-card.compare { background: #e8f5e9; border: 2px solid #66bb6a; }
.principle-card.raise { background: #fff3e0; border: 2px solid #ffa726; }
.principle-card.record { background: #fce4ec; border: 2px solid #ef5350; }
.p-icon { font-size: 28px; margin-bottom: 8px; }
.p-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.p-desc { font-size: 11px; color: var(--text-light); line-height: 1.5; }

/* ===== 배차 계산기 ===== */
.calc-workflow { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; background: white; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.cwf-step { padding: 6px 12px; border-radius: 20px; background: #e0e4ed; color: #555; font-size: 11px; font-weight: 500; }
.cwf-step.active { background: var(--primary); color: white; }
.cwf-step.done { background: var(--success); color: white; }
.cwf-arrow { color: #aaa; font-size: 14px; }

.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .calc-grid { grid-template-columns: 1fr; } }

.calc-section { background: white; padding: 16px; border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); }
.section-title { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 4px; margin-bottom: 12px; }
.section-title.s1 { background: #e3f2fd; color: #1565c0; }
.section-title.s2 { background: #fff9c4; color: #f57f17; }
.section-title.s3 { background: #e8f5e9; color: #2e7d32; }
.section-title.s4 { background: #fce4ec; color: #c62828; }
.section-title.s5 { background: #f3e5f5; color: #6a1b9a; }

.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.input-row { display: flex; flex-direction: column; gap: 3px; }
.input-row label { font-size: 11px; font-weight: 600; color: var(--text-light); }
.input-row input, .input-row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; font-family: inherit; }
.input-row input:focus, .input-row select:focus { outline: none; border-color: var(--primary); }
.auto-field { background: #f0f4ff; color: var(--primary); font-weight: 600; }
.auto-field.highlight { background: #fff3e0; color: var(--secondary); font-size: 13px !important; }

/* 시나리오 테이블 */
.scenario-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.scenario-table th { background: #37474f; color: white; padding: 6px 8px; text-align: center; }
.scenario-table td { padding: 6px 8px; border-bottom: 1px solid #eee; text-align: center; }
.step-cell { font-weight: 700; font-size: 10px; }
.step1 { color: #1565c0; }
.step2 { color: #2e7d32; }
.step3 { color: #37474f; }
.step4 { color: #f57c00; }
.step5 { color: #e65100; }
.step6 { color: #c62828; }
.step-base { background: #f9fbe7; }
.price-cell { font-weight: 700; font-size: 13px; color: var(--primary); }
.judge-ok { background: #4caf50; color: white; padding: 1px 6px; border-radius: 10px; font-size: 10px; }
.judge-warn { background: #ff9800; color: white; padding: 1px 6px; border-radius: 10px; font-size: 10px; }
.judge-bad { background: #f44336; color: white; padding: 1px 6px; border-radius: 10px; font-size: 10px; }
.judge-wait { background: #9e9e9e; color: white; padding: 1px 6px; border-radius: 10px; font-size: 10px; }

/* 결과 그리드 */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #f8f9fa; border-radius: 4px; }
.result-item.highlight-box { grid-column: span 2; background: var(--primary); color: white; padding: 12px 16px; }
.r-label { font-size: 11px; color: var(--text-light); }
.result-item.highlight-box .r-label { color: rgba(255,255,255,0.8); }
.r-value { font-weight: 700; font-size: 13px; color: var(--primary); }
.result-item.highlight-box .r-value { color: #ffd54f; }
.r-value.big { font-size: 20px; }
.r-value.surcharge { color: var(--secondary); }

/* 할증 체크 */
.surcharge-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.check-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: #f8f9fa; border-radius: 4px; cursor: pointer; font-size: 11px; }
.check-item:hover { background: #e8f0fe; }
.check-item input { cursor: pointer; }

/* 배차 폼 */
.dispatch-form { display: flex; flex-direction: column; gap: 8px; }
.form-row { display: flex; flex-direction: column; gap: 3px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-row label { font-size: 11px; font-weight: 600; color: var(--text-light); }
.form-row input, .form-row select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; font-family: inherit; }
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); }

/* 발송 텍스트 */
.dispatch-text-area { display: flex; flex-direction: column; gap: 8px; }
.dispatch-text-area textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 4px; font-family: 'Malgun Gothic', sans-serif; font-size: 12px; resize: vertical; background: #fafafa; }

/* ===== 배차 일정표 ===== */
.schedule-summary { margin-bottom: 16px; }
#day-summary-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.day-card { background: white; border-radius: var(--radius); padding: 12px; text-align: center; box-shadow: var(--shadow); border-top: 4px solid var(--primary); }
.day-card.today { border-top-color: var(--secondary); background: #fff8f0; }
.day-card-date { font-weight: 700; font-size: 13px; color: var(--primary); margin-bottom: 4px; }
.day-card-count { font-size: 24px; font-weight: 700; color: var(--secondary); }
.day-card-label { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.day-card-status { font-size: 10px; margin-top: 4px; }

.day-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.day-tab { padding: 7px 16px; background: white; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.day-tab.active { background: var(--primary); color: white; border-color: var(--primary); font-weight: 600; }
.day-tab:hover:not(.active) { background: #e8f0fe; }

.schedule-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.legend { display: flex; gap: 12px; align-items: center; font-size: 11px; }
.leg { display: flex; align-items: center; gap: 4px; }
.leg.confirmed { color: #2e7d32; }
.leg.progress { color: #f57c00; }
.leg.waiting { color: #0277bd; }
.leg.cancelled { color: #9e9e9e; }

/* ===== 공통 테이블 ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { background: var(--primary); color: white; padding: 8px 8px; text-align: center; white-space: nowrap; position: sticky; top: 0; }
.data-table td { padding: 7px 8px; border-bottom: 1px solid #eee; text-align: center; white-space: nowrap; }
.data-table tr:hover td { background: #f0f4ff; }
.status-confirmed { background: #c8e6c9; color: #1b5e20; padding: 2px 8px; border-radius: 10px; font-size: 10px; }
.status-progress { background: #fff9c4; color: #f57f17; padding: 2px 8px; border-radius: 10px; font-size: 10px; }
.status-waiting { background: #e3f2fd; color: #0d47a1; padding: 2px 8px; border-radius: 10px; font-size: 10px; }
.status-cancelled { background: #f5f5f5; color: #757575; padding: 2px 8px; border-radius: 10px; text-decoration: line-through; font-size: 10px; }
.margin-pos { color: var(--success); font-weight: 700; }
.margin-neg { color: var(--danger); font-weight: 700; }

/* 테이블 스크롤 */
.table-scroll { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: white; }
.schedule-table-section { background: white; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* ===== 단가표 ===== */
.rates-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.rates-section h3 { font-size: 14px; color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.rates-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rates-table th { background: var(--primary); color: white; padding: 8px 10px; text-align: center; }
.rates-table td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: right; }
.rates-table .ton-cell { text-align: left; font-weight: 700; color: var(--primary); }
.highlight-green { background: #c8e6c9; font-weight: 700; color: #1b5e20; }
.row-5ton td { background: #fff8e1; }
.rates-table.compact td, .rates-table.compact th { padding: 6px 10px; }
.zone-inner { color: #1565c0; font-weight: 700; }
.zone-near { color: #2e7d32; font-weight: 700; }
.zone-mid { color: #6a1b9a; font-weight: 700; }
.zone-far { color: #e65100; font-weight: 700; }
.zone-vfar { color: #c62828; font-weight: 700; }
.zone-nego { color: #37474f; font-weight: 700; }

/* ===== 할증 테이블 ===== */
.surcharge-section { background: white; padding: 20px; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.surcharge-section h3 { font-size: 14px; color: var(--primary); margin-bottom: 12px; }
.surcharge-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.surcharge-table th { background: #37474f; color: white; padding: 8px 10px; }
.surcharge-table td { padding: 8px 10px; border-bottom: 1px solid #eee; }
.cat-label { font-weight: 700; text-align: center; border-right: 2px solid #ddd; }
.cat-label.time { background: #e3f2fd; color: #1565c0; }
.cat-label.work { background: #e8f5e9; color: #2e7d32; }
.cat-label.dist { background: #fff3e0; color: #e65100; }
.cat-label.cargo { background: #fce4ec; color: #c62828; }
.cat-time td { background: #f8fbff; }
.cat-work td { background: #f9fdf9; }
.cat-dist td { background: #fffbf5; }
.cat-cargo td { background: #fff8f8; }
.surcharge-val { font-weight: 700; color: #c62828; }
.priority { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.priority.must { background: #ffcdd2; color: #c62828; }
.priority.often { background: #fff9c4; color: #f57f17; }
.priority.occur { background: #e0f2f1; color: #00695c; }

/* ===== DB 요약 ===== */
.db-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.summary-card { background: white; padding: 14px 16px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.summary-card .s-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.summary-card .s-label { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ===== 툴바 ===== */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.toolbar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }

/* ===== 버튼 ===== */
.btn-primary { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background 0.2s; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: #546e7a; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary:hover { background: #37474f; }
.btn-copy { background: #4caf50; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-copy:hover { background: #388e3c; }
.btn-edit    { background: #1976d2; color: white; border: none; padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 10px; }
.btn-delete  { background: #e53935; color: white; border: none; padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 10px; }
.btn-import  { background: #2e7d32; color: white; border: none; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-import:hover  { background: #1b5e20; }
.btn-export  { background: #0277bd; color: white; border: none; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-export:hover  { background: #01579b; }
.btn-template{ background: #6a1b9a; color: white; border: none; padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 12px; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-template:hover{ background: #4a148c; }

/* 폼 그리드 */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
@media (max-width: 560px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-row { display: flex; flex-direction: column; gap: 3px; }
.form-row label { font-size: 11px; font-weight: 600; color: var(--text-light); }
.form-row input, .form-row select, .form-row textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; font-family: inherit; transition: border-color 0.2s;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,60,110,0.1); }

/* 임포트 모달 */
.import-guide-box { display: flex; gap: 12px; padding: 14px; background: #e8f5e9; border-radius: 8px; margin-bottom: 14px; }
.import-guide-icon { font-size: 24px; flex-shrink: 0; }
.import-guide-box strong { display: block; font-size: 13px; color: #1b5e20; margin-bottom: 6px; }
.import-guide-box p { font-size: 11px; color: #333; line-height: 1.8; margin: 0; }
.import-upload-zone {
  border: 2px dashed #bdbdbd; border-radius: 8px; padding: 28px 16px;
  text-align: center; cursor: pointer; transition: all 0.2s; color: #9e9e9e;
}
.import-upload-zone:hover { border-color: var(--primary); background: #f0f4ff; color: var(--primary); }
.import-upload-zone p { margin: 4px 0; font-size: 13px; }

/* ===== 대시보드 ===== */
.kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.kpi-card .kpi-val { font-size: 22px; font-weight: 700; color: var(--primary); }
.kpi-card .kpi-val.neg { color: var(--danger); }
.kpi-card .kpi-label { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.kpi-card .kpi-sub { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.kpi-card.orange { border-left-color: var(--secondary); }
.kpi-card.orange .kpi-val { color: var(--secondary); }
.kpi-card.green { border-left-color: var(--success); }
.kpi-card.green .kpi-val { color: var(--success); }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.dash-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.dash-card h3 { font-size: 13px; color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

#top-customers-list { display: flex; flex-direction: column; gap: 6px; }
.top-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; background: #f8f9fa; border-radius: 4px; font-size: 12px; }
.top-rank { font-weight: 700; color: var(--primary); width: 30px; }
.top-name { flex: 1; }
.top-val { font-weight: 700; color: var(--secondary); }

/* ===== 페이지네이션 ===== */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.page-btn { padding: 4px 10px; border: 1px solid var(--border); background: white; cursor: pointer; border-radius: 4px; font-size: 11px; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== 모달 ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-box { background: white; border-radius: var(--radius); width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: var(--primary); color: white; border-radius: var(--radius) var(--radius) 0 0; }
.modal-header h3 { font-size: 15px; }
.modal-close { background: none; border: none; color: white; font-size: 18px; cursor: pointer; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }

/* ===== 토스트 ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: #37474f; color: white; padding: 12px 20px; border-radius: 6px; font-size: 13px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.3); animation: slideUp 0.3s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* 등급 */
.grade-stars { color: #ffc107; }
.grade-new { color: #9e9e9e; font-size: 11px; }
.grade-excellent { color: #2e7d32; }
.exclusive-y { background: #fff176; color: #f57f17; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.exclusive-n { color: #9e9e9e; font-size: 11px; }

/* ===== 노선 빠른 선택 바 ===== */
.quick-route-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: white; padding: 10px 14px; border-radius: var(--radius);
  margin-bottom: 14px; box-shadow: var(--shadow);
  border-left: 4px solid #ffd54f;
}
.qr-label { font-size: 12px; font-weight: 700; color: var(--secondary); white-space: nowrap; }
.qr-btns  { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.qr-btn   {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 12px; border: 2px solid var(--primary); border-radius: 6px;
  background: white; cursor: pointer; transition: all 0.2s; min-width: 70px;
}
.qr-btn:hover { background: var(--primary); color: white; }
.qr-code  { font-size: 9px; color: var(--secondary); font-weight: 700; }
.qr-btn:hover .qr-code { color: #ffd54f; }
.qr-route { font-size: 12px; font-weight: 700; }
.qr-ton   { font-size: 9px; color: #9e9e9e; }
.qr-btn:hover .qr-ton { color: rgba(255,255,255,0.7); }
.qr-manage { background: #546e7a; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 11px; font-family: inherit; white-space: nowrap; }
.qr-manage:hover { background: #37474f; }

/* ===== 발송 템플릿 탭 ===== */
.template-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tpl-tab {
  padding: 5px 14px; border: 2px solid var(--border); background: white;
  border-radius: 4px; cursor: pointer; font-size: 11px; font-family: inherit; font-weight: 600;
  transition: all 0.2s;
}
.tpl-tab:hover  { border-color: var(--primary); color: var(--primary); }
.tpl-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* 반응형 */
@media (max-width: 768px) {
  #day-summary-cards { grid-template-columns: repeat(3, 1fr); }
  .input-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .result-item.highlight-box { grid-column: span 1; }
  .workflow-steps { gap: 8px; }
  .wf-arrow { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #day-summary-cards { grid-template-columns: repeat(2, 1fr); }
  .principles-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   신규 페이지 공통 스타일 (노선마스터 / 유가관리 / 분석 탭)
   ============================================================ */

/* 분석 탭 */
.nav-tab.analysis-tab { color: rgba(255,220,150,0.85); }
.nav-tab.analysis-tab.active { color: #ffe082; border-bottom-color: #ffe082; }
.nav-divider { width: 1px; background: rgba(255,255,255,0.2); margin: 6px 4px; }

/* 분석 페이지 헤더 */
.analysis-header { border-left-color: #7b1fa2; }
.analysis-header h1 { color: #7b1fa2; }

/* ===== 노선 마스터 ===== */
.route-grade-summary { display: flex; flex-direction: column; gap: 8px; }
.rgs-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); }
.rgs-item.a { background: #e8f5e9; border-left: 5px solid #2e7d32; }
.rgs-item.b { background: #fff9c4; border-left: 5px solid #f57c00; }
.rgs-item.c { background: #ffebee; border-left: 5px solid #c62828; }
.rgs-grade { font-weight: 700; font-size: 16px; min-width: 56px; }
.rgs-item.a .rgs-grade { color: #2e7d32; }
.rgs-item.b .rgs-grade { color: #f57c00; }
.rgs-item.c .rgs-grade { color: #c62828; }
.rgs-count { font-weight: 600; font-size: 13px; min-width: 72px; }
.rgs-desc { font-size: 12px; color: var(--text-light); }

/* ===== 유가관리 ===== */
.fuel-dashboard { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .fuel-dashboard { grid-template-columns: 1fr; } }

.fuel-control-card { background: white; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.fuel-control-card h3 { font-size: 14px; color: var(--primary); margin-bottom: 16px; }
.fuel-input-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fuel-input-row label { font-size: 11px; font-weight: 600; color: var(--text-light); }
.fuel-input-row input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; font-family: inherit; width: 100%; }

.fuel-diff-display { text-align: center; padding: 16px; background: #f5f5f5; border-radius: var(--radius); margin-bottom: 12px; }
.fuel-diff-val { font-size: 28px; font-weight: 700; }
.fuel-diff-sub { font-size: 13px; margin-top: 4px; color: var(--text-light); }
.fuel-base-info { font-size: 11px; color: #9e9e9e; text-align: center; margin-top: 4px; }

.fuel-info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.fuel-info-card { background: white; padding: 14px 16px; border-radius: var(--radius); box-shadow: var(--shadow); border-left: 4px solid var(--info); }
.fuel-info-card.warn { border-left-color: var(--warning); }
.fuel-info-card.danger { border-left-color: var(--danger); }
.fuel-info-card .fi-label { font-size: 11px; color: var(--text-light); margin-bottom: 6px; }
.fuel-info-card .fi-val { font-size: 20px; font-weight: 700; color: var(--primary); }
.fuel-info-card .fi-sub { font-size: 10px; color: #9e9e9e; margin-top: 2px; }

/* 매트릭스 테이블 */
.matrix-table-wrap { overflow-x: auto; }
.matrix-table { border-collapse: collapse; font-size: 11px; min-width: 700px; }
.matrix-table th, .matrix-table td { border: 1px solid #ddd; padding: 6px 10px; text-align: center; white-space: nowrap; }
.matrix-table thead th { background: var(--primary); color: white; font-weight: 600; }
.matrix-table tbody tr:hover td { filter: brightness(0.95); }

/* ===== 트레닛 분석 ===== */
.trenit-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .trenit-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px)  { .trenit-grid { grid-template-columns: 1fr; } }

.trenit-chart-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.trenit-chart-card h3 { font-size: 13px; color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== Heatmap ===== */
.heatmap-wrap { overflow-x: auto; margin-bottom: 16px; }

.heatmap-table { border-collapse: collapse; font-size: 12px; min-width: 640px; width: 100%; }
.heatmap-table th { background: var(--primary); color: white; padding: 8px 12px; text-align: center; font-size: 11px; white-space: nowrap; }
.heatmap-table td { border: 2px solid white; padding: 0; }
.hm-corner { background: #263238 !important; }
.hm-avg-col { background: #37474f !important; min-width: 72px; }
.hm-day-label { background: #f5f5f5 !important; font-weight: 600; padding: 10px 12px !important; min-width: 80px; font-size: 12px; }
.hm-cell { width: 80px; min-width: 72px; height: 48px; text-align: center; vertical-align: middle; position: relative; cursor: default; transition: filter 0.15s; }
.hm-cell:hover { filter: brightness(1.12); }
.hm-val { font-size: 12px; font-weight: 700; display: block; }
.hm-crown { font-size: 14px; position: absolute; top: 2px; right: 4px; }
.hm-day-avg { font-weight: 700; font-size: 12px; text-align: center; padding: 8px 10px !important; min-width: 68px; }
.hm-time-avg-row td { border-top: 3px solid #333 !important; }
.hm-time-avg { font-weight: 700; font-size: 12px; text-align: center; padding: 8px 10px !important; }
.hm-weekend td { opacity: 0.95; }

.hm-legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px 0; font-size: 11px; }
.hm-legend-title { font-weight: 700; color: var(--text-light); }
.hm-litem { padding: 3px 10px; border-radius: 12px; font-size: 10px; font-weight: 600; }

/* 주말 패턴 분석 */
.weekend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .weekend-grid { grid-template-columns: 1fr; } }
.wg-section { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.wg-section h4 { font-size: 13px; color: var(--primary); margin-bottom: 12px; }
.wg-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; }
.wg-item.rank1 { background: #fff9c4; }
.wg-item.rank2 { background: #f5f5f5; }
.wg-item.rank3 { background: #fafafa; }
.wg-item.weekend { opacity: 0.85; }
.wg-rank { font-size: 18px; font-weight: 700; color: var(--secondary); min-width: 28px; }
.wg-hour { font-size: 14px; font-weight: 600; flex: 1; }
.wg-rate { font-size: 14px; font-weight: 700; color: var(--success); }
.wg-warning { margin-top: 8px; padding: 8px 12px; background: #fff3e0; border-radius: 4px; font-size: 11px; color: var(--warning); font-weight: 600; }

/* Insight box */
.insight-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.insight-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.insight-item i { font-size: 22px; margin-top: 2px; flex-shrink: 0; }
.insight-item.best i { color: #ffd700; }
.insight-item.good i { color: var(--success); }
.insight-item.warn i { color: var(--warning); }
.insight-item.info i { color: var(--info); }
.insight-item strong { display: block; font-size: 13px; margin-bottom: 4px; color: var(--primary); }
.insight-item p { font-size: 12px; color: var(--text); }
.insight-item small { font-size: 10px; color: var(--text-light); }
.insight-rate { color: var(--success); font-weight: 700; }
.insight-rate-bad { color: var(--danger); font-weight: 700; }

/* ===== KPI 분석 ===== */
.kpi-section { margin-bottom: 20px; }
.kpi-section h2 { font-size: 14px; color: var(--primary); margin-bottom: 12px; padding: 8px 12px; background: #e8eaf6; border-radius: 4px; }

.kpi-analysis-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-analysis-card { background: white; padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi-analysis-card.achieved { border-top: 4px solid var(--success); }
.kpi-analysis-card.not-achieved { border-top: 4px solid var(--danger); }
.kac-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kac-badge { background: var(--primary); color: white; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.kac-status { font-size: 11px; font-weight: 700; }
.kac-title { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.kac-val { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.kac-target { font-size: 11px; color: var(--text-light); margin-bottom: 4px; }
.kac-count { font-size: 11px; color: var(--text-light); margin-bottom: 8px; }
.kac-bar { background: #eee; border-radius: 4px; height: 6px; overflow: hidden; }
.kac-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

.kpi-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .kpi-charts-grid { grid-template-columns: 1fr; } }

.kpi-chart-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi-chart-card h3 { font-size: 13px; color: var(--primary); margin-bottom: 12px; }

/* ===== 시장가 DB ===== */
.market-section { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.market-section h3 { font-size: 13px; color: var(--primary); margin-bottom: 4px; }
.market-section .market-sub { font-size: 11px; color: var(--text-light); margin-bottom: 12px; }

.market-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.market-tab-btn { padding: 7px 16px; border: 2px solid var(--border); background: white; border-radius: 20px; cursor: pointer; font-size: 12px; font-family: inherit; font-weight: 500; transition: all 0.2s; }
.market-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.market-tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.market-panel { display: none; }
.market-panel.active { display: block; }

.market-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; margin-bottom: 12px; }
.market-badge.gov { background: #e3f2fd; color: #1565c0; }
.market-badge.call { background: #fff3e0; color: #e65100; }
.market-badge.khf { background: #e8f5e9; color: #2e7d32; }

/* 비교표 강조 */
.compare-highlight { background: #fff3e0 !important; }
.compare-best { color: var(--success) !important; font-weight: 700; }
.compare-worst { color: var(--danger) !important; font-weight: 700; }

/* section card 공통 */
.analysis-card { background: white; padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.analysis-card h3 { font-size: 13px; color: var(--primary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); display: flex; align-items: center; gap: 6px; }

/* 반응형 추가 */
@media (max-width: 768px) {
  .trenit-grid { grid-template-columns: 1fr; }
  .weekend-grid { grid-template-columns: 1fr; }
  .kpi-analysis-cards { grid-template-columns: 1fr; }
  .kpi-charts-grid { grid-template-columns: 1fr; }
  .fuel-dashboard { grid-template-columns: 1fr; }
}

/* ===================================================
   🅒 PWA + 모바일 UI 전면 개선
   =================================================== */

/* PWA 설치 배너 */
.pwa-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9998;
  display: flex; align-items: center; gap: 10px;
  background: var(--primary); color: white;
  padding: 12px 16px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
}
.pwa-icon { font-size: 28px; flex-shrink: 0; }
.pwa-text { flex: 1; }
.pwa-text strong { display: block; font-size: 13px; }
.pwa-text span   { font-size: 11px; opacity: 0.85; }
.pwa-install-btn {
  background: var(--secondary); color: white; border: none;
  padding: 8px 16px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-family: inherit; font-weight: 700;
  white-space: nowrap;
}
.pwa-close-btn {
  background: none; border: none; color: white; font-size: 18px;
  cursor: pointer; padding: 4px 8px; opacity: 0.7; flex-shrink: 0;
}

/* 모바일 전용 스타일 */
@media (max-width: 768px) {
  /* 헤더 축약 */
  .header-top { padding: 6px 10px; }
  .logo-title  { font-size: 15px; }
  .logo-sub    { display: none; }
  .header-policy { display: none; }

  /* 네비: 스크롤 + 작은 버튼 */
  #main-nav { padding: 0 4px; }
  .nav-tab  { padding: 8px 10px; font-size: 10px; }
  .nav-tab i { display: block; font-size: 14px; margin-bottom: 2px; }

  /* 페이지 패딩 축소 */
  #page-container { padding: 10px 8px; }
  .page-header { padding: 12px 14px; }
  .page-header h1 { font-size: 15px; }

  /* 계산기 그리드 → 1열 */
  .calc-grid { grid-template-columns: 1fr !important; }

  /* 노선 빠른선택 */
  .quick-route-bar { flex-wrap: wrap; gap: 6px; }
  .qr-btn { min-width: 58px; padding: 4px 8px; }

  /* 툴바 버튼 축소 */
  .toolbar { gap: 6px; }
  .btn-import, .btn-export, .btn-template { padding: 6px 10px; font-size: 11px; }

  /* 테이블: 가로 스크롤 */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 600px; }

  /* KPI 카드 2열 */
  .kpi-cards { grid-template-columns: 1fr 1fr; }

  /* 모달 풀스크린 */
  .modal-box { width: 96% !important; max-height: 85vh; margin: 0 auto; }

  /* 발주이력 테이블 간소화 */
  .data-table th, .data-table td { padding: 6px 8px; font-size: 11px; }

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

  /* 워크플로우 간소화 */
  .cwf-arrow { display: none; }
  .calc-workflow { gap: 4px; }
  .cwf-step { font-size: 10px; padding: 5px 8px; }

  /* 시나리오 테이블 */
  .scenario-table { font-size: 10px; }
  .scenario-table th, .scenario-table td { padding: 4px 6px; }
}

@media (max-width: 480px) {
  /* 극소형 화면 */
  .kpi-cards { grid-template-columns: 1fr; }
  .nav-tab span { display: none; } /* 텍스트 숨김, 아이콘만 */
  .nav-tab i { font-size: 16px; margin: 0; }
  .nav-tab { padding: 10px 8px; min-width: 40px; }

  /* 빠른선택 숨김 처리 */
  .qr-label { display: none; }

  /* 헤더 더 축약 */
  .logo-icon { font-size: 22px; }
  .logo-title { font-size: 13px; }
}
