/* ============================================================
   FMSAFEAI app.css v3 — 홈 대시보드 + 도구/보고서/설정 컴포넌트
   ============================================================ */

/* ---------- 진입 모션 ---------- */
@keyframes fms-rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
.home-dashboard>*{animation:fms-rise .5s cubic-bezier(.2,.7,.2,1) both}
.home-dashboard>*:nth-child(2){animation-delay:.07s}
.home-dashboard>*:nth-child(3){animation-delay:.13s}

/* ---------- 홈 레이아웃 ---------- */
body.fmsafe-integrated[data-fms-module="home"] .fms-page-hero{display:none}
body.fmsafe-integrated[data-fms-module="home"] .fms-content{padding-top:calc(var(--fms-top) + 22px)}
.home-dashboard{display:grid;gap:16px}

/* ---------- 히어로: 카피 / 건물 일러스트 / 현장환경 ---------- */
.dashboard-welcome{position:relative;overflow:hidden;padding:34px 36px;border-radius:24px;color:var(--fms-ink);
  border:1px solid #f0dfe1;background:linear-gradient(126deg,#fff 0%,#fffafa 46%,#fff2f3 100%);
  box-shadow:var(--fms-shadow);
  display:grid;grid-template-columns:minmax(0,1fr) minmax(250px,1.02fr) minmax(292px,.82fr);gap:24px;align-items:center}
.dashboard-welcome:before{content:"";position:absolute;inset:0;pointer-events:none;
  background-image:linear-gradient(rgba(152,0,19,.045) 1px,transparent 1px),linear-gradient(90deg,rgba(152,0,19,.045) 1px,transparent 1px);
  background-size:30px 30px;mask-image:radial-gradient(115% 105% at 50% 0%,#000 22%,transparent 72%)}
.dashboard-welcome:after{content:"";position:absolute;left:0;right:0;top:0;height:5px;background:var(--fms-hazard)}
.welcome-copy,.welcome-visual,.dashboard-welcome .weather-card{position:relative;z-index:1}
.welcome-copy{padding:6px 0}
.welcome-meta{display:flex;align-items:center;gap:13px;margin-bottom:16px;font-size:11.5px;font-weight:800;letter-spacing:.09em;color:var(--fms-muted)}
.live-dot{display:inline-flex;align-items:center;gap:8px;color:var(--fms-ink)}
.live-dot:before{content:"";width:8px;height:8px;border-radius:50%;background:#12b76a;box-shadow:0 0 0 5px rgba(18,183,106,.14)}
.welcome-copy h1{margin:0;font-size:clamp(26px,2.3vw,37px);line-height:1.2;letter-spacing:-.05em;font-weight:900;word-break:keep-all}
.welcome-copy h1 em{font-style:normal;color:var(--fms-brand)}
.welcome-copy>p{margin:15px 0 0;color:var(--fms-muted);font-size:14px;line-height:1.75;word-break:keep-all}

/* 건물 일러스트 */
.welcome-visual{margin:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.welcome-visual img{display:block;width:100%;max-width:420px;height:auto;object-fit:contain;
  filter:drop-shadow(0 22px 34px rgba(120,20,35,.14))}
.welcome-visual figcaption{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.welcome-visual.placeholder img{display:none}
.welcome-visual.placeholder:before{content:"건물 이미지 준비 중";display:grid;place-items:center;width:100%;min-height:210px;
  border:1px dashed #e4c9cd;border-radius:18px;background:rgba(255,255,255,.6);color:#b08d92;font-size:12.5px;font-weight:700}

/* ---------- 현장 환경(온·습도) ---------- */
.weather-card{position:relative;overflow:hidden;padding:21px;border-radius:20px;border:1px solid #eadfe0;
  background:linear-gradient(160deg,#fff,#fffafa 62%);box-shadow:0 3px 6px rgba(21,23,28,.04),0 16px 34px rgba(120,20,35,.08)}
.weather-card:before{content:"";position:absolute;width:230px;height:230px;right:-96px;top:-126px;border-radius:50%;
  background:radial-gradient(circle,rgba(227,7,27,.09),rgba(227,7,27,0) 70%)}
.weather-topline,.weather-main,.weather-metrics,.weather-button{position:relative;z-index:1}
.weather-topline{display:flex;justify-content:space-between;align-items:center}
.weather-topline>span{font-size:11px;font-weight:900;letter-spacing:.13em;color:var(--fms-ink)}
.sample-badge{display:inline-flex;align-items:center;border-radius:999px;padding:5px 10px;background:#f3f4f6;color:var(--fms-muted);font-size:11px;font-weight:800}
.weather-main{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:18px}
.weather-main small{color:var(--fms-muted);font-size:11.5px;font-weight:600}
.weather-main strong{display:block;margin-top:3px;font-size:31px;font-weight:800;letter-spacing:-.04em;color:var(--fms-ink)}
.weather-main p{margin:6px 0 0;max-width:180px;color:var(--fms-muted);font-size:11.5px;line-height:1.5;word-break:keep-all}
.weather-symbol{flex:0 0 auto;width:58px;height:58px;border-radius:16px;background:#fff;border:1px solid var(--fms-line);display:grid;place-items:center;box-shadow:0 6px 16px rgba(21,23,28,.07)}
.weather-symbol svg{width:37px;height:37px;fill:none;stroke:#a1720b;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.weather-metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin-top:17px}
.weather-metrics div{padding:10px 7px;border:1px solid var(--fms-line);border-radius:12px;background:rgba(255,255,255,.8);text-align:center}
.weather-metrics span{display:block;color:var(--fms-muted);font-size:11px;font-weight:600}
.weather-metrics b{display:block;margin-top:4px;font-size:13.5px;font-weight:800;color:var(--fms-ink);font-variant-numeric:tabular-nums}
.weather-button{width:100%;min-height:46px;margin-top:13px;border:0;border-radius:12px;background:#191b21;color:#fff;
  font-size:13px;font-weight:800;font-family:inherit;cursor:pointer;transition:background .15s,transform .15s,box-shadow .15s}
.weather-button:hover{background:#25282f;transform:translateY(-2px);box-shadow:0 10px 22px rgba(21,23,28,.24)}
.weather-button:active{transform:translateY(0) scale(.98)}
.weather-button:disabled{opacity:.6}
.weather-button span{margin-right:5px}

/* ---------- 핵심 업무 3종 큰 박스 ---------- */
.main-modules{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.module-box{position:relative;overflow:hidden;border:1px solid var(--fms-line);border-radius:22px;
  background:linear-gradient(180deg,#fff,#fcfcfd);display:flex;flex-direction:column;text-decoration:none;
  box-shadow:var(--fms-shadow);transition:transform .2s,box-shadow .2s,border-color .2s}
.module-box:hover{transform:translateY(-5px) scale(1.014);box-shadow:var(--fms-shadow-lift);border-color:#d6d9de}
.module-box.primary-box{background:linear-gradient(155deg,#fff5f6,#fff 56%);border-color:#f0d2d6}
/* 커버 이미지 밴드 */
.module-cover{display:block;position:relative;overflow:hidden;background:#f2f3f5}
.module-cover img{display:block;width:100%;height:auto;aspect-ratio:5/2;object-fit:cover;object-position:82% center;
  transition:transform .35s cubic-bezier(.2,.7,.2,1)}
.module-box:hover .module-cover img{transform:scale(1.045)}
.module-cover:after{content:"";position:absolute;left:0;right:0;bottom:0;height:34%;
  background:linear-gradient(180deg,rgba(255,255,255,0),#fff)}
.module-box.primary-box .module-cover:after{background:linear-gradient(180deg,rgba(255,246,247,0),#fffafa)}
.module-body{display:flex;flex-direction:column;flex:1;padding:0 24px 24px;margin-top:-26px;position:relative;z-index:1}
.module-box-icon{width:54px;height:54px;margin:-27px 0 0 24px;border-radius:16px;display:grid;place-items:center;
  background:#fff;border:1px solid var(--fms-line);color:#454b56;position:relative;z-index:1;
  box-shadow:0 6px 16px rgba(21,23,28,.1);transition:background .2s,color .2s,border-color .2s}
.module-box.primary-box .module-box-icon{background:#fff;border-color:#f0d2d6;color:var(--fms-brand)}
.module-box:hover .module-box-icon{background:var(--fms-brand-soft);border-color:#f0d2d6;color:var(--fms-brand)}
.module-box-icon svg{width:30px;height:30px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
.module-box h2{margin:16px 24px 8px;font-size:22px;font-weight:800;letter-spacing:-.035em}
.module-box p{margin:0 24px;color:var(--fms-muted);font-size:13px;line-height:1.7;word-break:keep-all}
.module-box-meta{display:inline-flex;align-items:baseline;gap:6px;margin:14px 24px 0;padding:8px 13px;border-radius:999px;
  background:#f3f4f6;color:#5b616d;font-size:12px;font-weight:700;align-self:flex-start;transition:background .2s}
.module-box:hover .module-box-meta{background:var(--fms-brand-soft);color:#8a3540}
.module-box.primary-box .module-box-meta{background:#ffe6ea;color:#8a3540}
.module-box-meta b{color:var(--fms-ink);font-size:18px;font-weight:800;font-variant-numeric:tabular-nums;letter-spacing:-.02em}
.module-box-go{margin:auto 24px 0;padding:16px 0 22px;color:#565b64;font-size:13px;font-weight:800;transition:color .2s}
.module-box:hover .module-box-go,.module-box.primary-box .module-box-go{color:var(--fms-brand)}

/* ---------- 현장도구 패널 ---------- */
.tools-panel{padding:25px}
.panel-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:18px}
.panel-heading.compact{align-items:center;margin-bottom:15px}
.panel-eyebrow{display:block;margin-bottom:6px;color:var(--fms-brand);font-size:11px;font-weight:900;letter-spacing:.16em}
.panel-heading h2{margin:0;font-size:19.5px;font-weight:800;letter-spacing:-.035em}
.text-link{align-self:center;color:#565b64;font-size:12.5px;font-weight:800;text-decoration:none;white-space:nowrap}
.text-link:hover{color:var(--fms-ink)}
.text-link b{color:var(--fms-brand)}
.quick-tools-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.quick-tools-grid a{min-height:74px;padding:14px 16px;border:1px solid var(--fms-line);border-radius:14px;background:#fff;
  text-decoration:none;display:grid;grid-template-columns:44px 1fr;align-items:center;column-gap:13px;
  transition:transform .16s,border-color .16s,box-shadow .16s}
.quick-tools-grid a:hover{transform:translateY(-3px) scale(1.015);border-color:#e8c9ce;box-shadow:var(--fms-shadow-lift)}
.quick-tools-grid a>span{grid-row:1/3;width:44px;height:44px;border-radius:13px;display:grid;place-items:center;background:#f2f3f5;color:#454b56;transition:background .18s,color .18s}
/* 호버 시 아이콘이 브랜드 레드로 */
.quick-tools-grid a:hover>span{background:var(--fms-brand-soft);color:var(--fms-brand)}
.quick-tools-grid a:hover b{color:var(--fms-brand)}
.quick-tools-grid svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.quick-tools-grid b{align-self:end;font-size:14px;font-weight:800;color:var(--fms-ink);transition:color .18s}
.quick-tools-grid small{align-self:start;margin-top:2px;color:var(--fms-faint);font-size:11.5px}
/* 로고 타일 */
.quick-tools-grid a.tool-brand{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;
  background:linear-gradient(160deg,#fff6f7,#fff 62%);border-color:#f0dcdf}
.quick-tools-grid a.tool-brand img{width:100%;max-width:132px;height:auto;object-fit:contain}
.quick-tools-grid a.tool-brand small{margin-top:0;color:#a8848a;font-weight:700}
.quick-tools-grid a.tool-brand:hover{border-color:#e3bcc2}

/* ---------- 현장에서 바로 (모바일 섹션) ---------- */
.mobile-panel{position:relative;overflow:hidden;margin-bottom:14px;border:1px solid var(--fms-line);border-radius:22px;
  background:var(--fms-card);box-shadow:var(--fms-shadow);
  display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:40px;align-items:center;padding:38px 40px 0}
.mobile-copy{padding-bottom:38px}
.mobile-copy h2{margin:0 0 12px;font-size:clamp(21px,1.9vw,27px);font-weight:800;letter-spacing:-.04em;word-break:keep-all}
.mobile-copy>p{margin:0;max-width:520px;color:var(--fms-muted);font-size:13.5px;line-height:1.8;word-break:keep-all}
.mobile-points{list-style:none;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;
  margin:22px 0 18px;padding:0;max-width:560px}
.mobile-points li{display:grid;gap:5px;padding:15px 16px;border:1px solid var(--fms-line);border-radius:14px;background:#fbfbfc}
.mobile-points b{font-size:16px;font-weight:800;letter-spacing:-.03em;color:var(--fms-ink)}
.mobile-points span{font-size:11.5px;line-height:1.55;color:var(--fms-muted);font-weight:600;word-break:keep-all}
.mobile-visual{margin:0;align-self:end;display:flex;justify-content:center}
.mobile-visual img{display:block;width:100%;max-width:330px;height:auto;
  filter:drop-shadow(0 22px 40px rgba(21,23,28,.18))}
.mobile-note{margin:0 0 22px!important;max-width:560px;padding:14px 16px;border:1px solid #e9dfc6;border-radius:13px;
  background:#fdfaf1;color:#6b510f;font-size:12.5px!important;line-height:1.75!important}
.mobile-note b{color:#5a4409;font-weight:800}

/* ---------- 홈 반응형 ---------- */
@media(max-width:1240px){
  .dashboard-welcome{grid-template-columns:minmax(0,1fr) minmax(268px,.8fr);row-gap:22px}
  .welcome-visual{order:3;grid-column:1/-1}
  .welcome-visual img{max-width:380px}
}
@media(max-width:1100px){
  .mobile-panel{grid-template-columns:minmax(0,1fr) 300px;gap:26px;padding:30px 28px 0}
  .mobile-visual img{max-width:280px}
}
@media(max-width:980px){
  body.fmsafe-integrated[data-fms-module="home"] .fms-content{padding-top:calc(var(--fms-top) + 12px)}
  .mobile-panel{grid-template-columns:1fr;padding:26px 22px 0;gap:4px}
  .mobile-copy{padding-bottom:4px}
  .mobile-visual{max-width:300px;margin:0 auto}
  .dashboard-welcome{grid-template-columns:1fr;padding:26px 22px;border-radius:20px}
  .welcome-copy h1{font-size:29px}
  .welcome-visual{order:2}
  .dashboard-welcome .weather-card{order:3}
  .main-modules{grid-template-columns:1fr}
  .module-box{min-height:0;padding:22px}
  .module-box h2{font-size:21px;margin-top:16px}
}
@media(max-width:520px){
  .home-dashboard{gap:12px}
  .dashboard-welcome{padding:22px 17px}
  .welcome-copy h1{font-size:25px;line-height:1.24}
  .welcome-copy>p{font-size:13.5px}
  .welcome-visual img{max-width:290px}
  .weather-card{padding:18px}
  .weather-main strong{font-size:28px}
  .module-box{padding:19px;border-radius:18px}
  .module-box-icon{width:52px;height:52px}
  .module-box h2{font-size:19px}
  .tools-panel{padding:17px}
  .quick-tools-grid{grid-template-columns:1fr 1fr}
  .quick-tools-grid a{min-height:70px;padding:12px 13px;grid-template-columns:38px 1fr;column-gap:10px}
  .quick-tools-grid a>span{width:38px;height:38px;border-radius:11px}
  .quick-tools-grid b{font-size:13px}
  .quick-tools-grid small{font-size:11px}
  .quick-tools-grid a.tool-brand{grid-column:1/-1;min-height:76px}
  .mobile-panel{padding:20px 17px 0;border-radius:18px}
  .mobile-points{grid-template-columns:1fr;gap:7px;margin:18px 0 20px}
  .mobile-points li{grid-template-columns:88px 1fr;align-items:baseline;gap:11px;padding:12px 14px}
  .mobile-points b{font-size:14px}
  .mobile-visual img{max-width:260px}
  .module-box h2{margin:14px 18px 7px;font-size:20px}
  .module-box p,.module-box-meta,.module-box-go{margin-left:18px;margin-right:18px}
  .module-box-icon{margin-left:18px}
}

/* ============================================================
   현장도구·자료보고서·설정 페이지 공용 컴포넌트
   ============================================================ */
.tool-section{padding:24px;margin-bottom:14px}
.tool-section h2{font-size:19.5px;font-weight:800;letter-spacing:-.03em;margin:0 0 6px}
.tool-section>.sub{color:var(--fms-muted);font-size:13px;margin:0 0 18px}
.section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:14px}
.tool-cards{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:11px}
.tool-launch{border:1px solid var(--fms-line);border-radius:15px;padding:18px;text-decoration:none;min-height:152px;
  display:flex;flex-direction:column;background:#fff;transition:transform .16s,border-color .16s,box-shadow .16s}
.tool-launch:hover{transform:translateY(-3px) scale(1.012);border-color:#d3d6db;box-shadow:var(--fms-shadow-lift)}
.module-icon{display:inline-flex;align-items:center;justify-content:center;min-width:44px;height:32px;padding:0 10px;
  border-radius:9px;background:#f2f3f5;color:#454b56;font-size:13px;font-weight:900;letter-spacing:-.01em;align-self:flex-start}
.tool-launch h3{font-size:15.5px;font-weight:800;margin:12px 0 5px}
.tool-launch p{font-size:12.5px;color:var(--fms-muted);line-height:1.6;margin:0;word-break:keep-all}
.tool-launch b{margin-top:auto;padding-top:12px;color:var(--fms-brand);font-size:12.5px;font-weight:800}
.utility-grid{display:grid;grid-template-columns:1.05fr .95fr;gap:14px}
.utility-panel{padding:22px}
.utility-panel h3{margin:0 0 13px;font-size:17.5px;font-weight:800}
.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:11px}
.field{display:grid;gap:6px;font-size:12.5px;font-weight:800;color:var(--fms-text)}
.field input,.field select,.field textarea{width:100%;min-height:46px;border:1px solid var(--fms-line);border-radius:12px;
  padding:10px 13px;background:#fff;color:var(--fms-text);font-family:inherit;font-size:14px;transition:border-color .15s,box-shadow .15s}
.field input:focus,.field select:focus,.field textarea:focus{outline:none;border-color:#c3c8d0;box-shadow:0 0 0 3px rgba(21,23,28,.06)}
.field input[type=file]{padding:9px 11px;font-size:13px}
.field input[type=file]::file-selector-button{border:1px solid var(--fms-line);border-radius:9px;background:#f3f4f6;
  color:var(--fms-text);font-family:inherit;font-size:12.5px;font-weight:800;padding:7px 12px;margin-right:11px;cursor:pointer}
.field input[type=file]::file-selector-button:hover{background:#ebedf0}
.field textarea{min-height:92px;resize:vertical}
.full{grid-column:1/-1}
.canvas-wrap{min-height:260px;border:1px dashed #ccd0d7;border-radius:14px;background:#fafafb;display:grid;place-items:center;overflow:auto}
.canvas-wrap canvas{max-width:100%;height:auto;display:block}
.inline-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.result-box{margin-top:12px;border:1px solid var(--fms-line);background:#fafafb;border-radius:13px;padding:14px;
  white-space:pre-wrap;font:12.5px/1.65 ui-monospace,SFMono-Regular,Consolas,monospace;max-height:320px;overflow:auto}
.report-table{width:100%;border-collapse:collapse;font-size:13px}
.report-table th,.report-table td{padding:13px 10px;border-bottom:1px solid var(--fms-line);text-align:left;vertical-align:top}
.report-table th{color:var(--fms-muted);font-size:11.5px;font-weight:800;letter-spacing:.04em}
.report-actions{display:flex;flex-wrap:wrap;gap:8px}
.stat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:11px;margin-bottom:16px}
.stat{border:1px solid var(--fms-line);border-radius:14px;padding:15px;background:#fff}
.stat b{display:block;font-size:24px;font-weight:800;letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.stat span,.stat small{display:block;margin-top:4px;color:var(--fms-muted);font-size:12px;font-weight:600}
.table-scroll{overflow:auto}
.help-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:13px}
.help-card{padding:22px}
.help-card h3{margin:0 0 8px;font-size:16.5px;font-weight:800}
.help-card p,.help-card li{font-size:13px;color:var(--fms-muted);line-height:1.75}
.connection-list{display:grid;gap:8px}
.connection{display:flex;align-items:center;gap:11px;border:1px solid var(--fms-line);border-radius:13px;padding:13px;background:#fff}
.connection i{width:10px;height:10px;border-radius:50%;background:#b5b8bf}
.connection.ok i{background:var(--safe-green)}
.connection.warn i{background:#d99000}
.connection b{font-size:13px;font-weight:800}
.connection span{margin-left:auto;font-size:11.5px;font-weight:700;color:var(--fms-muted)}
@media(max-width:1050px){.tool-cards{grid-template-columns:repeat(3,1fr)}}
@media(max-width:820px){
  .utility-grid{grid-template-columns:1fr}
  .tool-cards{grid-template-columns:repeat(2,1fr)}
  .help-grid{grid-template-columns:1fr}
  .stat-grid{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:520px){
  .tool-cards,.form-grid{grid-template-columns:1fr 1fr}
  .tool-launch{min-height:145px;padding:14px}
  .tool-section,.utility-panel,.help-card{padding:17px}
  .report-table{min-width:700px}
}
