/* =====================================================================
   HC 시멘트 통합 모니터링 - 화면 모양
   900px 이상 = PC 화면(타워와 같은 구성), 미만 = 휴대폰 화면(숫자·그래프 위주)
   ===================================================================== */
:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --line: #e3e8ef;
    --text: #1f2937;
    --muted: #6b7280;
    --navy: #172b4d;
    --orange: #f08307;
    --head-bg: #fdf3e7;
    --head-fg: #3d240c;
    --zebra: #fff8f0;
    --c-pc: #f08307;
    --c-sc: #1f9e8c;
    --c-ps: #2b5b84;
    --danger: #b71c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
    font-size: 13px;
    -webkit-text-size-adjust: 100%;
}
button { font: inherit; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { margin: 0; }
small { font-weight: normal; color: var(--muted); font-size: 0.8em; }
.muted { color: var(--muted); }
.pad { padding: 12px 4px; }
.b { font-weight: bold; }

/* ---------- 상단 바 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: var(--navy); color: #fff; padding: 10px 20px;
}
.tb-left { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.tb-brand { color: var(--orange); font-weight: 900; font-size: 15px; white-space: nowrap; }
.tb-title { font-weight: bold; font-size: 15px; white-space: nowrap; }
.tb-badge { font-size: 11px; background: rgba(255,255,255,.14); padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.tb-updated, .tb-user { font-size: 12px; opacity: .8; white-space: nowrap; }
.btn-ghost {
    background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px; padding: 5px 10px; white-space: nowrap;
}
.btn-ghost:disabled { opacity: .5; }
.btn-ghost.dark { background: #fff; color: var(--navy); border-color: var(--line); }

/* ---------- 필터 ---------- */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
    background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 20px;
}
.ms { position: relative; display: flex; align-items: center; gap: 6px; }
.ms-label { font-weight: bold; color: var(--muted); white-space: nowrap; }
.ms-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    min-width: 130px; max-width: 220px; height: 30px; padding: 0 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 6px; color: var(--text);
}
.ms-btn.on { border-color: var(--orange); color: #9a4e08; font-weight: bold; }
.ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--muted); }
.ms-backdrop { position: fixed; inset: 0; z-index: 30; }
.ms-pop {
    position: absolute; top: 34px; left: 0; z-index: 31; min-width: 220px; max-height: 360px; overflow: auto;
    background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px;
}
.ms-label + .ms-btn + .ms-backdrop + .ms-pop { left: auto; }
.ms-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px; border-radius: 4px; }
.ms-row:hover { background: #f6f7f9; }
.ms-row label { display: flex; align-items: center; gap: 6px; flex: 1; padding: 4px 0; cursor: pointer; white-space: nowrap; }
.ms-all { width: 100%; border: 0; background: none; text-align: left; font-weight: bold; padding: 6px 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; border-radius: 0; }
.ms-only { border: 1px solid var(--line); background: #fff; border-radius: 4px; font-size: 11px; padding: 1px 6px; color: var(--muted); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 14px 20px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; border-top: 4px solid var(--navy); }
.kpi-pc { border-top-color: var(--c-pc); }
.kpi-sc { border-top-color: var(--c-sc); }
.kpi-ps { border-top-color: var(--c-ps); }
.k-label { color: var(--muted); font-weight: bold; }
.k-val { font-size: 24px; font-weight: 900; margin-top: 4px; white-space: nowrap; }
.k-sub { color: var(--muted); margin-top: 2px; }

/* ---------- 카드 / 표 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.card h2 { font-size: 15px; margin-bottom: 8px; }
.card h3 { font-size: 13px; margin-bottom: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--muted); }
.card-foot.b { color: var(--text); }
.card-foot.total { background: var(--navy); color: #fff; padding: 6px 10px; border-radius: 6px; font-weight: bold; justify-content: flex-end; }
.search { width: 320px; max-width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 10px; }

.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-scroll.tall { max-height: 520px; }
.table-scroll.short { max-height: 260px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
    position: sticky; top: 0; z-index: 1; background: var(--head-bg); color: var(--head-fg);
    font-weight: bold; padding: 6px 8px; border-bottom: 1px solid #f3dec4; white-space: nowrap; text-align: center;
}
.tbl td { padding: 4px 8px; border-bottom: 1px solid #f0f2f5; white-space: nowrap; text-align: center; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.zebra tbody tr:nth-child(even) { background: var(--zebra); }
.tbl tfoot td { position: sticky; bottom: 0; background: #eef2f7; font-weight: bold; border-top: 1px solid var(--line); }
.tbl tbody tr:hover { background: #fff1dc; }

/* ---------- PC 배치 ---------- */
.desktop-only { padding: 14px 20px 24px; }
.main-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; }
.section-title { font-size: 15px; margin: 18px 2px 10px; }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dash-grid .daily { grid-column: span 3; }
.dash-grid .daily .table-scroll.short { max-height: 420px; }

/* ---------- 휴대폰 ---------- */
.mobile-only { display: none; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #eef1f5; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 9px; }
.legend { display: flex; gap: 14px; justify-content: center; margin-top: 4px; color: var(--muted); font-size: 12px; }
.legend i, .share-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.c-pc { background: var(--c-pc); }
.c-sc { background: var(--c-sc); }
.c-ps { background: var(--c-ps); }
.share-bar { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: #eef1f5; }
.share-bar i { display: block; height: 100%; }
.share-legend { display: flex; justify-content: space-between; margin-top: 8px; font-weight: bold; }
.hbar { margin: 8px 0; }
.hbar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.hbar-track { display: flex; height: 10px; background: #eef1f5; border-radius: 5px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; }
.toplist { margin: 0; padding-left: 20px; }
.toplist li { padding: 6px 0; border-bottom: 1px solid #f0f2f5; }
.toplist li { display: list-item; }
.toplist li span:first-child { display: inline-block; min-width: 46%; }
.toplist li .muted { display: inline-block; min-width: 20%; }
.toplist li b { float: right; }



/* ---------- 메뉴 (PC = 상단 탭, 휴대폰 = 하단 고정) ---------- */
.tabs { display: flex; gap: 2px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 14px; overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 11px 14px; color: var(--muted); font-weight: bold; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab.on { color: var(--navy); border-bottom-color: var(--orange); }
.tab-ic { font-size: 14px; }
.tab-short { display: none; }

.view-pad { padding: 14px 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpis.five { grid-template-columns: repeat(5, 1fr); }
.tbl td.left, .tbl th.left { text-align: left; }
.tbl td small { color: var(--muted); margin-left: 4px; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { background: #fbe6cc; }
.ana-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; }
.trend-chart { max-width: 760px; margin: 0 auto 10px; }

/* 도넛 */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut { width: 210px; max-width: 60vw; height: auto; flex: none; }
.donut-c1 { font-size: 15px; font-weight: 900; fill: var(--navy); }
.donut-c2 { font-size: 10px; fill: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f0f2f5; }
.donut-legend i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.dl-name { flex: 1; }
.dl-name small { margin-left: 4px; }

/* 가로 누적 막대 */
.ebars { display: flex; flex-direction: column; gap: 7px; max-height: 420px; overflow: auto; }
.ebar { display: grid; grid-template-columns: 170px minmax(0, 1fr) 120px; align-items: center; gap: 10px; }
.ebar-name { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ebar-name small { margin-left: 4px; }
.ebar-track { display: flex; height: 18px; background: #f1f4f8; border-radius: 6px; overflow: hidden; }
.ebar-track i { display: block; height: 100%; }
.ebar-val { text-align: right; font-weight: bold; white-space: nowrap; }

/* 재고 / 주문 */
.dbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; }
.date-in { height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; }
.btn-small { height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 0 10px; color: var(--text); }
.btn-small.accent { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: bold; }
.btn-small:disabled { opacity: .6; }
.notice { border-radius: 8px; padding: 8px 12px; font-weight: bold; }
.notice.ok { background: #e3f2e3; color: #1b5e20; }
.notice.warn { background: #fdecec; color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.silo-card { background: #fff; border: 1px solid #d5dbe3; border-radius: 6px; overflow: hidden; }
.silo-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; font-size: 13px; }
.silo-title span { font-size: 11.5px; font-weight: bold; white-space: nowrap; }
.silo-title.done { background: #e3f2e3; color: #1b5e20; }
.silo-title.miss { background: #fdecec; color: var(--danger); }
.silo-title.chg { background: #ffe5bf; color: #8a4b00; }
.silo-title b { color: var(--navy); }
.silo { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.silo th, .silo td { border-top: 1px solid #d5dbe3; border-right: 1px solid #d5dbe3; padding: 2px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 21px; }
.silo th:last-child, .silo td:last-child { border-right: 0; }
.silo tr.sh th { background: var(--head-bg); color: var(--head-fg); font-weight: 600; }
.silo td.close { background: #f3f5f8; font-weight: 600; }
.silo td.close.low { background: #fdecec; color: var(--danger); }
.silo td.rm { text-align: left; }
.silo tr.dim td { color: #999; }
.silo tr.ord td { color: #c84b08; font-weight: bold; }
.silo tr.chg td { background: #fff1dc; font-weight: bold; }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #172b4d 0%, #24406e 100%); }
.login-card { width: 100%; max-width: 360px; background: #fff; border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; box-shadow: 0 16px 40px rgba(0,0,0,.25); }
.login-card .brand { color: var(--orange); font-weight: 900; }
.login-card h1 { font-size: 22px; color: var(--navy); margin: 2px 0 4px; }
.login-card p { margin: 0 0 18px; }
.login-card label { font-weight: bold; margin: 10px 0 4px; }
.login-card input { height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font-size: 15px; }
.login-msg { color: var(--danger); margin-top: 12px; }
.btn-primary { margin-top: 18px; height: 42px; border: 0; border-radius: 8px; background: var(--orange); color: #fff; font-weight: bold; font-size: 15px; }
.btn-primary:disabled { opacity: .6; }

.error-box { margin: 12px 20px 0; background: #fdecec; color: var(--danger); border: 1px solid #f5c2c2; border-radius: 8px; padding: 10px 14px; }
.loading-box { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Blazor 기본 (로딩·오류 표시) ---------- */
#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); box-sizing: border-box;
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.loading-progress { position: absolute; display: block; width: 6rem; height: 6rem; inset: 20vh 0 auto 0; margin: 0 auto; }
.loading-progress circle { fill: none; stroke: #e0e0e0; stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--orange);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; color: var(--muted); inset: calc(20vh + 7rem) 0 auto 0; }
.loading-progress-text:after { content: "불러오는 중 " var(--blazor-load-percentage-text, ""); }

/* ---------- 휴대폰 (맨 뒤에 둬야 위의 기본값을 덮어씀) ---------- */
@media (max-width: 899px) {
    body { font-size: 14px; padding-bottom: 64px; }
    .desktop-only, .desktop-block { display: none; }
    .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 0; gap: 0; border-top: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
    .tab { flex: 1; flex-direction: column; gap: 1px; padding: 7px 2px 8px; border-bottom: 0; border-top: 3px solid transparent; font-size: 11px; }
    .tab.on { border-top-color: var(--orange); border-bottom-color: transparent; }
    .tab-ic { font-size: 16px; }
    .tab-full { display: none; }
    .tab-short { display: inline; }
    .view-pad { padding: 12px 16px 20px; }
    .kpis.three, .kpis.five { grid-template-columns: 1fr 1fr; }
    .kpis.three .kpi-total, .kpis.five .kpi-total { grid-column: span 2; }
    .ana-grid { grid-template-columns: 1fr; }
    .ebar { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; }
    .ebar-track { grid-column: span 2; order: 3; height: 12px; }
    .dbar { padding: 10px 16px; }
    .two-col { grid-template-columns: 1fr; }
    .silo { font-size: 11.5px; table-layout: auto; }
    .silo th { white-space: normal; line-height: 1.15; padding: 3px 2px; }
    .silo td { padding: 2px 3px; }
    .mobile-only { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 28px; }
    .hide-sm, .tb-updated { display: none; }
    .topbar { padding: 10px 16px; }
    .tb-badge { display: none; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 16px; }
    .ms { flex-direction: column; align-items: stretch; gap: 2px; }
    .ms-label { font-size: 11px; }
    .ms-btn { min-width: 0; max-width: none; width: 100%; }
    .ms-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; max-height: 60vh; min-width: 0; }
    .ms-row label, .ms-all { padding: 9px 4px; }
    .kpis { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px 0; }
    .kpi { padding: 10px 12px; }
    .k-val { font-size: 18px; }
}
