* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", -apple-system, sans-serif;
  background: #f4f6f8;
  color: #1f2937;
  -webkit-tap-highlight-color: transparent;
}
.screen { min-height: 100vh; }

/* ----------------------------------------------------------- install banner */
.install-banner {
  background: #fff6da; color: #5c4400; font-size: 13px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.install-banner .icon-btn { color: #5c4400; font-size: 16px; padding: 0 4px; }

/* ----------------------------------------------------------------- login */
#login-screen { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  background: #fff; border-radius: 14px; padding: 32px 24px;
  width: 100%; max-width: 360px; box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  text-align: center;
}
.login-box h1 { color: #2f5496; font-size: 22px; margin-bottom: 4px; }
.login-box .sub { color: #6b7280; margin-bottom: 20px; font-size: 14px; }
.login-box .offline-sub { color: #1a7a1a; font-weight: bold; }
.login-box input {
  width: 100%; padding: 12px 14px; border: 1px solid #c7ccd4; border-radius: 8px;
  font-size: 16px; margin-bottom: 12px;
}
.error { color: #b00020; font-size: 13px; min-height: 18px; }

/* ---------------------------------------------------------------- header */
header {
  display: flex; align-items: center; justify-content: space-between;
  background: #2f5496; color: #fff; padding: 14px 16px;
  position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 18px; margin: 0; display: flex; align-items: center; gap: 8px; }
.offline-badge {
  font-size: 10px; font-weight: bold; letter-spacing: 0.5px;
  background: #1a7a1a; color: #fff; padding: 2px 6px; border-radius: 10px;
}
.icon-btn {
  background: transparent; border: none; color: #fff; font-size: 20px;
  padding: 4px 8px; cursor: pointer;
}

/* --------------------------------------------------------------- toolbar */
.toolbar { display: flex; gap: 8px; padding: 10px 12px; }
.toolbar select, .toolbar input {
  flex: 1; padding: 10px 12px; border: 1px solid #c7ccd4; border-radius: 8px;
  font-size: 15px; background: #fff;
}

button.primary {
  background: #2f5496; color: #fff; border: none; border-radius: 8px;
  padding: 12px 18px; font-size: 15px; font-weight: bold; cursor: pointer;
}
button.primary:active { background: #24406f; }
button.primary:disabled { background: #9aa7bd; }
button.secondary {
  background: #fff; color: #2f5496; border: 1px solid #2f5496; border-radius: 8px;
  padding: 10px 14px; font-size: 14px; font-weight: bold; cursor: pointer;
}
.calc-btn { display: block; width: calc(100% - 24px); margin: 4px 12px 12px; }

/* ---------------------------------------------------------- ingredients */
.card-list { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; max-height: 42vh; overflow-y: auto; }
.ing-card {
  background: #fff; border: 1px solid #e2e6ea; border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.ing-card.adjusted { border-left: 3px solid #8a6d00; }
.ing-info { flex: 1; min-width: 0; }
.ing-name { font-weight: bold; font-size: 14px; }
.ing-meta { font-size: 12px; color: #6b7280; }
.ing-price {
  width: 92px; padding: 8px; border: 1px solid #c7ccd4; border-radius: 6px;
  text-align: right; font-size: 14px;
}

/* -------------------------------------------------------------- results */
#result-panel { padding: 4px 12px 24px; }
.result-status { font-size: 16px; font-weight: bold; padding: 8px 2px; }
.result-status.ok { color: #1a7a1a; }
.result-status.bad { color: #b00020; }
.result-cost { font-size: 14px; color: #33415c; margin-bottom: 8px; }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab-btn {
  flex: 1; background: #e7ecf2; border: none; padding: 10px 6px; border-radius: 8px 8px 0 0;
  font-size: 13px; font-weight: bold; color: #33415c; cursor: pointer;
}
.tab-btn.active { background: #fff; color: #2f5496; box-shadow: 0 -1px 0 #dbe1e8 inset; }
.tab-content { display: none; background: #fff; border-radius: 0 0 10px 10px; padding: 10px; }
.tab-content.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { background: #eef2f7; color: #33415c; padding: 8px 6px; text-align: left; border-bottom: 2px solid #d7dee6; }
table td { padding: 8px 6px; border-bottom: 1px solid #eceff2; }
table td:nth-child(2), table td:nth-child(3), table th:nth-child(2), table th:nth-child(3) { text-align: right; }

.status-ok { color: #1a7a1a; font-weight: bold; }
.status-bad { color: #b00020; font-weight: bold; }

#diag-text { white-space: pre-wrap; font-size: 13px; line-height: 1.6; color: #b00020; }
#export-btn { margin-top: 10px; width: 100%; }

/* -------------------------------------------------------------- history */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-content {
  background: #fff; width: 100%; max-width: 480px; max-height: 88vh;
  border-radius: 16px 16px 0 0; padding: 16px; overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 17px; margin: 0; color: #2f5496; }
.modal-header .icon-btn { color: #333; }
#history-search {
  width: 100%; padding: 10px 12px; border: 1px solid #c7ccd4; border-radius: 8px;
  font-size: 14px; margin: 10px 0;
}
.hist-card { background: #f7f9fb; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.hist-card .name { font-weight: bold; font-size: 14px; }
.hist-card .meta { font-size: 12px; color: #6b7280; }
#history-back { width: 100%; margin-top: 10px; }

/* ----------------------------------------------------------- data footer */
.data-footer { text-align: center; font-size: 11px; color: #9aa7bd; padding: 4px 12px 16px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 200; max-width: 90vw; text-align: center;
}
