/* ===== 토큰 ===== */
:root {
  --bg: #E8ECEF;
  --surface: #FFFFFF;
  --ink: #17222C;
  --ink-2: #5A6774;
  --line: #D2D9DF;
  --line-2: #E6EAEE;
  --go: #0E6B5E;        /* 주요 동작·생산 배치 */
  --go-soft: #DDEFEB;
  --amber: #A86A0C;     /* 주의 */
  --amber-soft: #FBF0D9;
  --red: #B3261E;       /* 지연·삭제 */
  --red-soft: #FBE4E2;
  --radius: 6px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  /* 거래처 구분색 */
  --c0: #2F6FB0; --c1: #B5502D; --c2: #4F8A3A; --c3: #7A4FA8; --c4: #B0841C;
  --c5: #1E8C95; --c6: #A8406E; --c7: #5D6B2F; --c8: #3E57A8; --c9: #8A5A3B;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--go); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 1.07rem; margin: 0 0 .6rem; }
h3 { font-size: 1.13rem; margin: 0 0 .5rem; }
h3 small { font-weight: 400; color: var(--ink-2); font-size: .8rem; }
.num { font-variant-numeric: tabular-nums; }
.muted, .sub { color: var(--ink-2); }
.sub { font-size: .82rem; }
.r { text-align: right; }
.strong { font-weight: 700; }
:focus-visible { outline: 2px solid var(--go); outline-offset: 2px; }

/* ===== 상단바 ===== */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem; height: 56px;
  background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar a { color: #C9D3DB; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff !important; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(3, 7px); gap: 2px; }
.brand-mark i { width: 7px; height: 14px; background: #3FB8A4; border-radius: 1px; }
.brand-mark i:nth-child(2) { opacity: .75; } .brand-mark i:nth-child(3) { opacity: .45; }
.brand-mark.big { grid-template-columns: repeat(3, 12px); gap: 3px; margin-bottom: .8rem; }
.brand-mark.big i { width: 12px; height: 26px; background: var(--go); }
.mainnav { display: flex; align-items: center; gap: .25rem; flex: 1; overflow-x: auto; }
.mainnav a { padding: .4rem .7rem; border-radius: var(--radius); white-space: nowrap; }
.mainnav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.mainnav a[aria-current] { background: rgba(255,255,255,.14); color: #fff; }
.nav-group { display: flex; gap: .25rem; margin-left: .75rem; padding-left: .75rem; border-left: 1px solid rgba(255,255,255,.18); }
.me { display: flex; align-items: center; gap: .75rem; font-size: .87rem; white-space: nowrap; }
.me form { margin: 0; }
.linkbtn { background: none; border: 0; color: #C9D3DB; font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.role { font-size: .75rem; padding: .05rem .45rem; border-radius: 99px; background: #3A4855; color: #fff; }
.role-admin { background: #7A3E14; } .role-customer { background: #2F5F8F; }
table .role { background: var(--line-2); color: var(--ink); }

/* ===== 레이아웃 ===== */
.page { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page.wide { max-width: 1600px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head p { margin: 0; font-size: .87rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; align-items: start; }
.sticky { position: sticky; top: 72px; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem 1rem; }
.form-grid .span2 { grid-column: span 3; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; } .sticky { position: static; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: .5rem 1rem; gap: .5rem 1rem; }
  .mainnav { order: 3; flex-basis: 100%; }
}

/* ===== 폼 ===== */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--ink); }
label em { font-style: normal; font-weight: 400; color: var(--red); font-size: .75rem; }
label small { font-weight: 400; }
th em { font-style: normal; font-weight: 400; color: var(--red); font-size: .72rem; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--go); box-shadow: 0 0 0 3px var(--go-soft); }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; }
fieldset { border: 1px solid var(--line-2); border-radius: var(--radius); padding: .5rem .8rem .7rem; display: flex; gap: 1.2rem; flex-wrap: wrap; }
legend { font-size: .82rem; font-weight: 600; padding: 0 .3rem; }
.hint { font-size: .82rem; color: var(--ink-2); margin: .6rem 0 0; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input { min-width: 220px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-size: .9rem;
  padding: .45rem .9rem; border-radius: var(--radius); border: 1px solid var(--line); background: #fff;
  color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #F3F6F8; text-decoration: none; }
.btn.primary { background: var(--go); border-color: var(--go); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #0A5A4F; }
.btn.danger { color: var(--red); border-color: #E7B9B5; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { font-size: .8rem; padding: .25rem .55rem; }
.btn.block { width: 100%; padding: .65rem; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ===== 테이블 ===== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap, .plan-card .table-wrap { border: 0; border-radius: 0; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--ink-2); background: #F5F7F9;
  padding: .55rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.grid tbody tr:hover { background: #FAFBFC; }
.grid tr:last-child td { border-bottom: 0; }
.grid.compact td { padding: .35rem .6rem; vertical-align: middle; }
.grid.lines td { vertical-align: top; }
.grid.lines input, .grid.lines select { width: 100%; }
.grid td.empty { text-align: center; color: var(--ink-2); padding: 2.5rem 1rem; }
tr.inactive td { color: #9AA5AF; }
tr.is-done td { background: #F7F9F8; }
.w-num { width: 5.5rem; }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; }
.row-actions form { margin: 0; }
.late { color: var(--red); font-weight: 600; }
.soon { color: var(--amber); font-weight: 600; }
.tbd { color: var(--amber); font-weight: 600; }
.na { color: var(--ink-2); font-size: .82rem; display: inline-block; padding-top: .45rem; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .4rem; margin-right: .25rem; border-radius: 4px; background: var(--line-2); }
.line-hint { margin-top: .25rem; font-size: .78rem; color: var(--ink-2); font-weight: 400; }

/* ===== 상태 ===== */
.pill { display: inline-block; font-size: .76rem; font-weight: 600; padding: .1rem .55rem; border-radius: 99px; white-space: nowrap; }
.st-todo { background: var(--red-soft); color: var(--red); }
.st-partial { background: var(--amber-soft); color: var(--amber); }
.st-planned { background: #E1EAF5; color: #2A5287; }
.st-done { background: var(--go-soft); color: var(--go); }
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .4rem; vertical-align: 1px; background: var(--cc); }
.c0 { --cc: var(--c0); } .c1 { --cc: var(--c1); } .c2 { --cc: var(--c2); } .c3 { --cc: var(--c3); } .c4 { --cc: var(--c4); }
.c5 { --cc: var(--c5); } .c6 { --cc: var(--c6); } .c7 { --cc: var(--c7); } .c8 { --cc: var(--c8); } .c9 { --cc: var(--c9); }

/* ===== 알림 ===== */
.flashes { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.flash { padding: .6rem .9rem; border-radius: var(--radius); border-left: 4px solid; background: #fff; font-size: .9rem; }
.flash-success { border-color: var(--go); background: var(--go-soft); }
.flash-warning { border-color: var(--amber); background: var(--amber-soft); }
.flash-error { border-color: var(--red); background: var(--red-soft); }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--ink-2); }
.empty-state h1 { font-size: 3rem; color: var(--ink); }

/* ===== 로그인 ===== */
.login-body { background: var(--ink); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; background: #fff; border-radius: 10px; padding: 2rem; display: flex; flex-direction: column; gap: .85rem; }
.login-card h1 { font-size: 1.4rem; }
.login-card p.muted { margin: -.6rem 0 .4rem; font-size: .88rem; }

/* ===== 생산계획 카드 ===== */
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden; scroll-margin-top: 72px; }
.plan-card:target { box-shadow: 0 0 0 2px var(--go); }
.pc-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1.1rem; border-bottom: 1px solid var(--line-2); background: #F8FAFB; font-size: .9rem; }
.pc-head .sub { margin-left: .5rem; }
.pc-body { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.2fr); }
.pc-info { padding: 1rem 1.1rem; }
.pc-form { padding: 1rem 1.1rem; border-left: 1px solid var(--line-2); display: flex; flex-direction: column; gap: .6rem; background: #FCFDFD; }
@media (max-width: 900px) { .pc-body { grid-template-columns: 1fr; } .pc-form { border-left: 0; border-top: 1px solid var(--line-2); } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem 1rem; margin: .7rem 0 0; font-size: .9rem; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.meter { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--go); }
.suggest { font-size: .9rem; padding: .45rem .7rem; background: var(--go-soft); border-radius: var(--radius); color: #0B4D44; }
.suggest b { font-size: 1.05rem; margin-right: .3rem; }
.pc-inputs { display: grid; grid-template-columns: 10rem 6rem 1fr; gap: .6rem; }
@media (max-width: 560px) { .pc-inputs { grid-template-columns: 1fr 1fr; } .pc-inputs .grow { grid-column: span 2; } }
.calc { font-size: .88rem; }
.warns { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.warns li { font-size: .83rem; color: var(--amber); background: var(--amber-soft); padding: .3rem .6rem; border-radius: 4px; }
.warns li.bad { color: var(--red); background: var(--red-soft); }
.pc-form .btn.primary { align-self: flex-start; }

/* 배치 표시: 배치 1개 = 칸 1개 */
.batch-pips { display: flex; flex-wrap: wrap; gap: 3px; min-height: 14px; }
.pip, .batch-pips i { display: inline-block; width: 10px; height: 14px; border-radius: 2px; background: var(--go); }
.pip.done { background: #9FB8B2; }

/* ===== 캘린더 ===== */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .5rem; }
.cal-nav, .cal-opts { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.cal-title { margin-left: .6rem; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; } .seg .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.seg .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.cal-legend { display: flex; gap: 1.2rem; margin-bottom: .6rem; align-items: center; }
.cal-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.due-mark { display: inline-block; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 9px solid var(--red); }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: #F5F7F9; padding: .4rem .6rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.cal-dow.sun, .day.sun .dnum { color: var(--red); } .cal-dow.sat, .day.sat .dnum { color: #2A5287; }
.day { background: var(--surface); min-height: 128px; padding: .35rem .4rem .5rem; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.day.other { background: #F6F8F9; } .day.other > * { opacity: .55; }
.day.today { box-shadow: inset 0 0 0 2px var(--go); }
.day-top { display: flex; justify-content: space-between; align-items: baseline; }
.dnum { font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; }
.day.today .dnum { color: var(--go); }
.dsum { font-size: .72rem; color: var(--ink-2); }

.ev { display: block; width: 100%; text-align: left; font: inherit; font-size: .78rem; line-height: 1.3; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--cc, var(--go)); border-radius: 4px; padding: .25rem .4rem; color: var(--ink); }
.ev:hover { background: #F6F9F8; }
.ev .ev-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ev .ev-pips { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 3px; align-items: center; }
.ev .ev-pips i { width: 7px; height: 10px; border-radius: 1px; background: var(--cc, var(--go)); }
.ev .ev-pips small { margin-left: 4px; color: var(--ink-2); font-size: .72rem; }
.ev.done { opacity: .6; } .ev.done .ev-pips i { background: #9FB8B2; } .ev.done .ev-name { text-decoration: line-through; }
.ev.due { border-left-color: var(--red); background: var(--red-soft); border-color: #EFC9C5; font-weight: 400; }
.ev.due .ev-name { font-weight: 400; }

.week .day { min-height: 420px; }
.week .ev { font-size: .83rem; padding: .4rem .5rem; }
.week .ev .ev-meta { display: block; font-size: .74rem; color: var(--ink-2); margin-top: 2px; }
.cal-empty { padding: .4rem 0; font-size: .75rem; color: #A3AEB8; }

dialog { border: 0; border-radius: 10px; padding: 1.3rem 1.4rem; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(23,34,44,.3); }
dialog::backdrop { background: rgba(23,34,44,.4); }
dialog form { display: flex; flex-direction: column; gap: 1rem; }
dialog .btn { align-self: flex-end; }
.ev-detail h3 { margin-bottom: .2rem; }
@media (max-width: 760px) {
  .month .day { min-height: 80px; } .month .ev .ev-name { font-size: .7rem; }
  .week { grid-template-columns: 1fr; } .week .cal-dow { display: none; } .week .day { min-height: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print {
  .topbar, .cal-opts, .cal-nav .btn, .flashes { display: none !important; }
  body { background: #fff; } .page { padding: 0; max-width: none; }
  .day { min-height: 90px; } .ev { break-inside: avoid; }
}
[hidden] { display: none !important; }
.warns:empty, .dayload:empty { display: none; }
.ev .ev-cust { display: block; font-size: .7rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== 엑셀 등록 / 메일 접수 ===== */
.badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .2rem; border-radius: 99px;
  background: #D6452F; color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.3rem; }
.import-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.import-grid .card { margin: 0; scroll-margin-top: 72px; }
.import-grid .card:target { box-shadow: 0 0 0 2px var(--go); }
.import-grid input[type=file] { padding: .6rem; border-style: dashed; background: #FAFBFC; }
.import-order { margin: -.4rem 0 1rem; }
.summary { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
label.inline { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; }
tr.row-err td { background: #FFF8F7; }
tr.group-start td { border-top: 2px solid var(--line); }
.msgs { min-width: 220px; font-size: .82rem; }
.m-err { color: var(--red); } .m-warn { color: var(--amber); }
.pre { white-space: pre-line; }
.att-row { display: flex; align-items: center; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.att-row form { margin: 0 0 0 auto; }
.mail-body { white-space: pre-wrap; font-size: .88rem; max-height: 480px; overflow: auto; background: #FAFBFC;
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
a.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
