* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: #f5f6f8;
  color: #1a1a1a;
  font-size: 14px;
}

.view { min-height: 100vh; }
.hidden { display: none !important; }

/* 로그인 */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 360px;
}
.login-box h1 {
  margin: 0 0 24px;
  text-align: center;
  color: #2c3e50;
}
.login-box label {
  display: block;
  margin-bottom: 16px;
  font-weight: 500;
}
.login-box input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #d0d4dc;
  border-radius: 6px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 12px;
  background: #2c7a7b;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-box button:hover { background: #226063; }
.error { color: #c53030; font-size: 13px; margin-top: 8px; }

/* 앱 헤더 */
header {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e2e5ea;
  padding: 0 20px;
  gap: 20px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: #2c7a7b;
  padding: 16px 0;
}
header nav { flex: 1; display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: none;
  padding: 16px 18px;
  font-size: 14px;
  cursor: pointer;
  color: #555;
  border-bottom: 3px solid transparent;
}
.tab:hover { color: #2c7a7b; }
.tab.active {
  color: #2c7a7b;
  font-weight: 600;
  border-bottom-color: #2c7a7b;
}
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #666; }
.user button {
  padding: 6px 12px;
  background: #f0f2f5;
  border: 1px solid #d0d4dc;
  border-radius: 4px;
  cursor: pointer;
}

/* 메인 */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.page h2 { margin: 0 0 20px; color: #2c3e50; }
.page h3 { margin: 32px 0 12px; color: #555; font-size: 15px; }
.stock-group-title { margin: 24px 0 8px; color: #2c3e50; font-size: 16px; font-weight: 600; }
#stock table { table-layout: fixed; }
#stock th, #stock td { text-align: center; }
#stock th:first-child, #stock td:first-child { width: 50%; }
#stock th:nth-child(2), #stock td:nth-child(2) { width: 25%; }
#stock th:nth-child(3), #stock td:nth-child(3) { width: 25%; }
.qty-with-unit { display: flex; align-items: center; gap: 8px; }
.qty-with-unit input { flex: 1; }
.unit-input { width: 60px !important; flex: none !important; text-align: center; font-weight: 600; color: #2c7a7b; }

/* 요약 카드 */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card .label { color: #888; font-size: 13px; margin-bottom: 8px; }
.card .value { font-size: 32px; font-weight: 700; color: #2c7a7b; }

/* 필터 */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.filters select, .filters input {
  padding: 8px 12px;
  border: 1px solid #d0d4dc;
  border-radius: 6px;
  font-size: 14px;
}
.filters input { flex: 1; max-width: 300px; }

/* 테이블 */
table {
  width: 100%;
  background: #fff;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eef0f3;
}
th {
  background: #f7f8fa;
  font-weight: 600;
  color: #555;
  font-size: 13px;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
#stock td.num { text-align: center; }
td.empty { text-align: center; color: #aaa; padding: 24px; }
tr:last-child td { border-bottom: none; }

/* 폼 */
.entry-form {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.entry-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  gap: 6px;
}
.entry-form input, .entry-form select {
  padding: 8px 10px;
  border: 1px solid #d0d4dc;
  border-radius: 5px;
  font-size: 14px;
}
.entry-form fieldset {
  grid-column: 1 / -1;
  border: 1px solid #e2e5ea;
  border-radius: 6px;
  padding: 14px;
}
.entry-form legend { font-weight: 600; padding: 0 8px; color: #2c7a7b; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.form-actions button {
  padding: 9px 20px;
  border-radius: 5px;
  border: 1px solid #d0d4dc;
  cursor: pointer;
  background: #fff;
  font-size: 14px;
}
.form-actions button[type="submit"] {
  background: #2c7a7b;
  color: #fff;
  border-color: #2c7a7b;
  font-weight: 600;
}
.form-actions button[type="submit"]:hover { background: #226063; }

/* 재료 테이블 */
.materials-table td, .materials-table th { padding: 6px 8px; }
.materials-table select, .materials-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d0d4dc;
  border-radius: 4px;
}
.materials-table button {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #d0d4dc;
  border-radius: 4px;
  cursor: pointer;
}
#add-material {
  margin-top: 8px;
  padding: 6px 12px;
  background: #f0f2f5;
  border: 1px dashed #aaa;
  border-radius: 4px;
  cursor: pointer;
}

/* 품목관리 */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.page-head h2 { margin: 0; }
#add-item-btn {
  padding: 8px 16px;
  background: #2c7a7b;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}
.edit-item, .del-item {
  padding: 5px 10px;
  margin-right: 4px;
  background: #fff;
  border: 1px solid #d0d4dc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.del-item { color: #c53030; }

/* 다이얼로그 */
dialog {
  border: none;
  border-radius: 10px;
  padding: 24px;
  width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog h3 { margin: 0 0 18px; color: #2c3e50; }
dialog label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
}
dialog input, dialog select {
  padding: 8px 10px;
  border: 1px solid #d0d4dc;
  border-radius: 5px;
  font-size: 14px;
}

/* 상태 메시지 */
.status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
}
.status:empty { display: none; }
.status.ok { background: #2c7a7b; color: #fff; }
.status.error { background: #c53030; color: #fff; }
