:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #1767d0;
  --primary-dark: #0d4fa5;
  --green: #157347;
  --red: #c62828;
  --yellow: #b7791f;
  --blue: #1767d0;
  --gray: #667085;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; background: #0f2747; color: #fff; box-shadow: 0 2px 12px rgba(15,39,71,.16); }
.brand { display: flex; gap: 10px; align-items: baseline; font-weight: 800; font-size: 20px; }
.brand a { color: #fff; }
.brand span { color: #bdd7ff; font-size: 13px; font-weight: 600; }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.userbox small { color: #bdd7ff; }
.userbox a { color: #fff; padding: 6px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; }
.menu-toggle { display: none; border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; padding: 8px 12px; border-radius: 8px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.nav a { color: #24324b; padding: 9px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.nav a.active, .nav a:hover { background: #e9f2ff; color: var(--primary-dark); }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.footer { color: var(--muted); text-align: center; padding: 28px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 10px 25px rgba(31,44,71,.06); margin-bottom: 18px; }
.card h1, .card h2, .card h3 { margin-top: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 28px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stat span { color: var(--muted); font-size: 14px; font-weight: 700; }
.stat strong { display: block; font-size: 30px; margin-top: 8px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f2f6fc; font-size: 13px; color: #344054; }
tr:hover td { background: #fbfdff; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
label { font-weight: 800; color: #344054; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 12px 13px; font-size: 16px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 15px; background: var(--primary); color: #fff; font-weight: 800; cursor: pointer; min-height: 42px; }
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #475467; }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-yellow { background: var(--yellow); }
.btn-light { background: #e9eef7; color: #1f2937; }
.btn-small { padding: 7px 10px; min-height: 32px; border-radius: 9px; font-size: 13px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 58px; padding: 5px 9px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 900; }
.badge-green { background: var(--green); }
.badge-red { background: var(--red); }
.badge-yellow { background: var(--yellow); }
.badge-blue { background: var(--blue); }
.badge-gray { background: var(--gray); }
.alert { padding: 14px 16px; border-radius: 14px; margin-bottom: 16px; font-weight: 800; }
.alert-success { background: #e7f7ef; color: #0b6b3a; border: 1px solid #b7ebcf; }
.alert-error { background: #fdecec; color: #a11b1b; border: 1px solid #f6c5c5; }
.alert-info { background: #e9f2ff; color: #164f91; border: 1px solid #c5dcff; }
.login-wrap { max-width: 460px; margin: 70px auto; }
.login-wrap .brand-login { text-align: center; margin-bottom: 18px; }
.login-wrap h1 { margin-bottom: 4px; }
.help { color: var(--muted); font-size: 13px; line-height: 1.5; }
.mobile-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.mobile-quick button { min-height: 54px; font-size: 16px; }
@media (max-width: 900px) {
  .topbar { padding: 12px 14px; }
  .brand { font-size: 17px; }
  .userbox { display: none; }
  .menu-toggle { display: inline-flex; }
  .nav { display: none; flex-direction: column; padding: 10px; }
  .nav.open { display: flex; }
  .container { padding: 14px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 14px; }
  .page-head h1 { font-size: 23px; }
  .stat strong { font-size: 26px; }
  input, select, textarea { font-size: 18px; padding: 14px; }
  .btn { width: 100%; min-height: 48px; font-size: 16px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .mobile-quick { grid-template-columns: repeat(2, 1fr); }
  table { min-width: 760px; }
}


/* v2.0.4 대시보드 가로 밀림 방지 */
.card, .grid > *, .grid-2 > *, .table-wrap { min-width: 0; }
.dashboard-stack { display: grid; grid-template-columns: 1fr; gap: 14px; }
.dashboard-stack .card { width: 100%; min-width: 0; }
.dashboard-stack .table-wrap { max-width: 100%; overflow-x: auto; }
.dashboard-stack table { width: 100%; }
.loss-summary-card table { min-width: 680px; }
@media (max-width: 900px) {
  .dashboard-stack { grid-template-columns: 1fr; }
  .loss-summary-card table { min-width: 620px; }
}

/* v2.2 현장 입력/상태관리 개선 */
html, body { max-width: 100%; overflow-x: hidden; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-weight: 700; line-height: 1.5; }
.muted { color: var(--muted); font-size: 12px; }
.compact-head { margin-bottom: 10px; }
.compact-head h2 { margin: 0; }
.actions-nowrap { flex-wrap: nowrap; }
.status-guide { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 16px; }
.status-guide div { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fbfdff; }
.status-guide strong { display: block; margin-bottom: 5px; font-size: 15px; }
.status-guide span { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; }
.mobile-entry-card { border-width: 2px; }
.entry-top-grid { grid-template-columns: 1.5fr 1fr; }
.entry-wide { grid-column: span 1; }
.big-control { min-height: 58px; font-size: 19px; font-weight: 800; }
.qty-input { font-size: 28px; font-weight: 900; text-align: right; }
.tx-button-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tx-choice { border: 2px solid #d6e0ee; border-radius: 18px; background: #fff; min-height: 82px; padding: 12px; cursor: pointer; text-align: left; color: var(--text); }
.tx-choice strong { display: block; font-size: 22px; margin-bottom: 5px; }
.tx-choice span { color: var(--muted); font-weight: 800; }
.tx-choice.active { border-color: var(--primary); background: #e9f2ff; box-shadow: 0 0 0 3px rgba(23,103,208,.13); }
.btn-save-big { width: 100%; min-height: 62px; font-size: 21px; }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 900px) {
  .status-guide { grid-template-columns: 1fr; }
  .entry-top-grid { grid-template-columns: 1fr; }
  .tx-button-grid { grid-template-columns: repeat(2, 1fr); }
  .tx-choice { min-height: 88px; }
  .tx-choice strong { font-size: 23px; }
  .big-control { min-height: 62px; font-size: 20px; }
  .qty-input { font-size: 30px; }
  .btn-save-big { min-height: 66px; font-size: 22px; }
  .actions-nowrap { flex-wrap: wrap; }
}

.stock-info-box {
  margin-top: 10px;
  padding: 13px 15px;
  border-radius: 14px;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  color: #174ea6;
  font-weight: 900;
  font-size: 16px;
}
.stock-warning-box {
  margin-top: 10px;
  padding: 14px 15px;
  border-radius: 14px;
  background: #fff3e6;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-weight: 900;
  line-height: 1.55;
}
.tx-choice:disabled {
  opacity: .42;
  cursor: not-allowed;
  background: #f3f4f6;
  border-color: #e5e7eb;
  box-shadow: none;
}
.tx-choice:disabled strong,
.tx-choice:disabled span {
  color: #9ca3af;
}
