:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --green: #15803d;
  --orange: #d97706;
  --shadow: 0 10px 30px rgba(15, 23, 42, .07);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 14px 22px; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.logo { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 800; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { padding: 9px 12px; border-radius: 10px; color: #374151; font-weight: 600; font-size: 14px; }
.nav a.on, .nav a:hover { background: #eff6ff; color: var(--primary); }
.page { width: min(1440px, calc(100% - 32px)); margin: 24px auto 60px; }
h1 { margin: 0 0 6px; font-size: 28px; } h2 { margin: 0; font-size: 19px; } p { margin: 0; }
.muted { color: var(--muted); }
.hero, .card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.hero { padding: 26px; display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.quick-actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cards { display: grid; gap: 16px; margin-bottom: 18px; } .cards.four { grid-template-columns: repeat(4, 1fr); }
.grid { display: grid; gap: 18px; } .grid.two { grid-template-columns: 1fr 1fr; }
.card { padding: 20px; }
.metric span { color: var(--muted); font-size: 14px; } .metric strong { display: block; font-size: 32px; margin-top: 8px; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.section-title a { color: var(--primary); font-weight: 700; }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: white; color: #111827; min-height: 38px; padding: 8px 14px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.ghost { background: #f9fafb; color: var(--muted); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.alert { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.alert.success { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.filters { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.filters input, .filters select, .entry-form input, .entry-form select, .item-grid input, .edit-table input { height: 40px; border: 1px solid #d1d5db; border-radius: 10px; padding: 0 12px; background: white; min-width: 120px; }
.filters input[type="search"] { min-width: 280px; flex: 1; }
.filters.multi input[type="search"] { flex: 1.5; }
.entry-form { max-width: 760px; display: grid; gap: 10px; margin-top: 18px; }
.entry-form label { font-weight: 800; margin-top: 8px; }
.entry-form select, .entry-form input { width: 100%; }
.action-card { max-width: 900px; margin: 0 auto; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.table-wrap.compact { max-height: 460px; }
table { width: 100%; border-collapse: collapse; min-width: 900px; background: white; }
th { position: sticky; top: 0; background: #f9fafb; z-index: 1; text-align: left; color: #374151; font-size: 13px; border-bottom: 1px solid var(--line); padding: 11px 10px; white-space: nowrap; }
td { border-bottom: 1px solid #f0f2f5; padding: 10px; vertical-align: middle; font-size: 14px; }
tr:hover td { background: #fafafa; }
.num { text-align: right; } .strong { font-weight: 900; } .plus { color: var(--green); font-weight: 800; } .minus { color: var(--danger); font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.badge, .status { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; font-weight: 800; font-size: 12px; white-space: nowrap; }
.badge.inbound, .badge.adjust_in { color: #166534; background: #dcfce7; }
.badge.outbound, .badge.adjust_out { color: #991b1b; background: #fee2e2; }
.status.정상 { color: #166534; background: #dcfce7; }
.status.부족 { color: #92400e; background: #fef3c7; }
.status.위험 { color: #991b1b; background: #fee2e2; }
.add-box { margin: 16px 0; padding: 14px; border: 1px dashed #cbd5e1; border-radius: 14px; background: #f8fafc; }
.add-box summary { cursor: pointer; font-weight: 900; }
.item-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 10px; }
.item-grid .span2 { grid-column: span 2; }
.edit-table { min-width: 1200px; }
.inline-edit { display: grid; gap: 6px; }
.edit-table td input { width: 100%; margin: 3px 0; }
.mini { border: 0; border-radius: 999px; padding: 7px 10px; font-weight: 900; cursor: pointer; }
.mini.on { color: #166534; background: #dcfce7; } .mini.off { color: #6b7280; background: #f3f4f6; }
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .hero { flex-direction: column; align-items: flex-start; }
  .cards.four, .grid.two { grid-template-columns: 1fr; }
  .item-grid { grid-template-columns: 1fr; }
  .item-grid .span2 { grid-column: auto; }
}

/* 2026-06-11: dashboard/stock simplification */
.cards.three { grid-template-columns: repeat(3, 1fr); }
.dashboard-grid { grid-template-columns: minmax(0, 1.35fr) minmax(420px, .65fr); align-items: start; }
.table-wrap.tall { max-height: 620px; }
.summary-wrap { max-height: 260px; margin-bottom: 18px; }
.recent-title { margin-top: 8px; }
.recent-wrap { max-height: 310px; }
.category-row td { background: #eff6ff !important; color: var(--primary); font-weight: 900; border-top: 1px solid #bfdbfe; }
.item-link { color: var(--primary); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.stock-table { min-width: 1050px; }
.memo-form input { width: 100%; min-width: 260px; }
.selected-item-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 14px; }
.selected-item-box span { color: var(--muted); font-size: 13px; font-weight: 800; }
.selected-item-box strong { color: #1e3a8a; }
.selected-item-box em { color: var(--muted); font-style: normal; }
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .cards.three { grid-template-columns: 1fr; }
}

/* 2026-06-11: tighter memo/save columns and item-history-only view */
.category-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 900; white-space: nowrap; }
.memo-head, .memo-cell { width: 130px; max-width: 130px; }
.save-head, .save-cell { width: 58px; max-width: 58px; text-align: center; white-space: nowrap; }
.memo-form input, .memo-input, .edit-table td input.memo-input { width: 110px !important; min-width: 110px !important; max-width: 110px !important; }
.btn.save-btn, button.btn.save-btn { min-width: 46px; min-height: 30px; padding: 5px 8px; font-size: 12px; line-height: 1; white-space: nowrap; }
.stock-table { min-width: 980px; }
.edit-table { min-width: 1120px; }
.item-history-table { min-width: 760px; }
.selected-item-box.only-item { background: #f0fdf4; border-color: #bbf7d0; }
@media (max-width: 900px) {
  .memo-form input, .memo-input, .edit-table td input.memo-input { width: 130px !important; min-width: 130px !important; max-width: 130px !important; }
}

/* 2026-06-11: transaction screen category filter and simpler item select labels */
.small-guide { font-size: 13px; margin-top: 4px; }
.entry-form select[name="item_id"] { min-height: 44px; }
