.login-page { min-height:100dvh; display:flex; flex-direction:column; padding:32px clamp(20px,6.5vw,96px) 24px; background:#fff; --forest:#143c2d; --accent:#143c2d; --accent-hover:#20533e; }
.entry-header { display:flex; justify-content:space-between; align-items:center; gap:16px; width:min(1264px,100%); margin:0 auto; }
.entry-brand { display:flex; align-items:center; gap:20px; color:var(--forest); font-size:32px; font-weight:650; line-height:1.3; }
.entry-brand span { color:var(--muted); font-size:15px; font-weight:400; }
.entry-header button { min-height:44px; padding:10px 22px; color:var(--forest); border-color:#aac0b1; }
.login-page .entry-layout { width:min(1174px,100%); min-height:0; margin:auto; display:grid; grid-template-columns:minmax(0,1.18fr) minmax(0,1fr); gap:clamp(44px,7.5vw,108px); padding:64px 0 42px; }
.entry-story h1 { margin:0 0 12px; font-size:44px; line-height:1.25; font-weight:650; color:var(--forest); letter-spacing:-1px; }
.entry-story p { font-size:24px; color:var(--muted); margin:0 0 30px; }
.entry-story img { display:block; width:100%; height:390px; object-fit:cover; object-position:50% 53%; border-radius:16px; }
.entry-story small { display:block; margin-top:12px; color:var(--muted); font-size:12px; }
.entry-access { padding-top:12px; min-width:0; }
.entry-access h2 { font-size:30px; line-height:1.3; color:var(--forest); margin:0 0 12px; }
.entry-intro { margin:0 0 28px; font-size:15px; color:var(--muted); }
.entry-access #guest-login { margin:0; display:flex; align-items:center; justify-content:center; position:relative; width:100%; min-height:56px; font-size:17px; border-radius:10px; box-shadow:none; }
.entry-guest svg { position:absolute; right:24px; }
.entry-divider { display:flex; align-items:center; gap:18px; margin:28px 0 22px; font-size:14px; color:var(--muted); }
.entry-divider::before,.entry-divider::after { content:''; height:1px; flex:1; background:var(--line); }
.entry-access form { display:grid; gap:10px; }
.entry-access label { font-size:15px; }
.entry-access input { width:100%; min-height:48px; background:#fff; font-size:16px; padding:12px 16px; margin-bottom:12px; border-color:#cfd7d1; }
.entry-access form button { width:100%; min-height:52px; margin-top:2px; font-size:16px; box-shadow:none; }
.entry-help { margin:12px 0 0; font-size:12px; text-align:center; color:var(--muted); line-height:1.7; }
#login-error { min-height:22px; margin:14px 0 0; color:#a32323; font-size:14px; overflow-wrap:anywhere; }
.entry-footer { text-align:center; color:var(--muted); font-size:13px; padding-top:12px; }
@media(max-width:780px) {
  .login-page { padding:24px 24px 20px; }
  .entry-brand { gap:4px; display:block; font-size:27px; }
  .entry-brand span { display:block; margin-top:4px; font-size:12px; }
  .entry-header button { padding:8px 12px; font-size:12px; }
  .entry-story { display:none; }
  .login-page .entry-layout { display:block; width:min(460px,100%); padding:48px 0 20px; }
  .entry-access { padding:0; }
  .entry-access h2 { font-size:28px; }
  .entry-intro { font-size:14px; }
  .entry-footer { font-size:12px; }
}
@media(max-width:360px) { .login-page { padding:20px; } .entry-guest svg { right:16px; width:18px; } .entry-access #guest-login { font-size:16px; } }
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  --ink: #202923;
  --muted: #626d66;
  --line: #e1e7e1;
  --canvas: #f5f7f4;
  --surface: #fff;
  --glass: rgb(250 252 249 / 90%);
  --accent: #176448;
  --accent-hover: #104d36;
  --accent-soft: #edf4ee;
  --forest: #123e32;
  --sage-border: #ceded1;
  --green: #167352;
  --green-soft: #e7f5ee;
  --red: #b52d43;
  --red-soft: #fff0f1;
  --radius: 16px;
  --control-radius: 10px;
  --input-border: #929298;
  --sidebar-width: 232px;
  --shadow: 0 2px 8px rgb(0 0 0 / 2%);
  --focus: 0 0 0 3px rgb(23 100 72 / 18%);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: var(--canvas); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { min-height: 40px; border: 1px solid #d2d2d7; border-radius: var(--control-radius); background: var(--surface); color: var(--ink); padding: 9px 16px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background 160ms, border-color 160ms, box-shadow 160ms; }
button:hover:not(:disabled) { border-color: #9cae9f; background: #f2f6f1; }
:where(button, input, select, textarea, a, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; box-shadow: var(--focus); }
button:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
button.primary { border-color: var(--accent); background: linear-gradient(180deg, #217354, var(--accent)); color: #fff; font-weight: 500; box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), 0 3px 10px -6px rgb(18 62 50 / 35%); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--red); }
button.danger:hover:not(:disabled) { background: var(--red-soft); border-color: #e8b6be; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 42px; line-height: 1.2; font-weight: 600; letter-spacing: -1px; }
h2 { margin-bottom: 18px; font-size: 19px; line-height: 1.4; font-weight: 600; letter-spacing: -.3px; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }

.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--sidebar-width); height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; padding: 32px 16px 24px; border-right: 1px solid #dce5dc; background: linear-gradient(165deg, #f6f9f4 10%, #eaf1e9); color: var(--ink); }
.brand { display: flex; align-items: center; margin: 0 16px 40px; color: var(--forest); font-size: 28px; line-height: 1.3; font-weight: 600; text-decoration: none; letter-spacing: -.8px; }
.brand small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: .03em; }
.nav-label { margin: 0 16px 12px; color: var(--muted); font-size: 11px; }
nav { display: grid; gap: 5px; }
nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid transparent; border-radius: 12px; color: #515154; font-size: 14px; text-decoration: none; transition: background 160ms, color 160ms, box-shadow 160ms; }
nav a svg { flex-shrink: 0; }
.sidebar nav a:hover { background: #e2ebe1; color: var(--forest); }
.sidebar nav a.active { background: var(--forest); color: #fff; font-weight: 500; box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), 0 4px 12px -6px rgb(18 62 50 / 32%); }
.sidebar nav a.active svg { color: #c9e7cf; }
.sidebar-foot { margin-top: auto; padding: 20px 14px 0; border-top: 1px solid #d2dfd2; color: #515154; font-size: 12px; }
.sidebar-foot small { display: block; margin: 5px 0 0 14px; color: var(--muted); font-size: 10px; }
.dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--accent); }

main { min-height: 100vh; min-width: 0; margin-left: var(--sidebar-width); }
.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 40px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(16px); color: var(--muted); font-size: 12px; }
#content { width: min(1500px, 100%); min-width: 0; margin: auto; padding: 32px 40px 48px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-heading > div { min-width: 0; }
.page-heading p { margin: 0; }
.page-heading .muted { font-size: 14px; }
.page-heading .primary { min-height: 42px; padding-inline: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 32px; overflow: hidden; border-bottom: 1px solid #dcdce1; }
.stat { min-height: 144px; display: flex; flex-direction: column; justify-content: center; padding: 12px 28px 30px; position: relative; }
.stat:first-child { padding-left: 0; }
.stat + .stat::before { content: ''; position: absolute; left: 0; top: 22px; bottom: 36px; width: 1px; background: #dcdce1; }
.stat:last-child { border-right: 0; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { margin-top: 16px; font-size: 48px; line-height: 1; font-weight: 500; letter-spacing: -1.5px; }
.stat.good strong { color: var(--green); }
.stat.alert strong { color: var(--red); }

.panel { min-width: 0; margin-bottom: 24px; padding: 28px; border: 1px solid #e8e8ed; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.panel-header h2, .panel-header p { margin-bottom: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.toolbar .search { width: 196px; }
.toolbar select { width: auto; min-width: 105px; }

.table-wrap { width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #c7c7cc transparent; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { padding: 14px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafafa; color: var(--muted); font-size: 12px; font-weight: 400; text-align: left; white-space: nowrap; }
td { padding: 14px 10px; border-bottom: 1px solid #eeeef0; vertical-align: middle; white-space: nowrap; }
td strong { font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f4f8f3; }
td button { margin: 3px 2px 3px 0; padding: 6px 9px; min-height: 32px; font-size: 12px; border-color: transparent; background: transparent; color: #515154; }
td button:first-child:not(.danger) { color: var(--accent); }
#customer-table :is(th, td):nth-child(3),
#customer-table :is(th, td):nth-child(4),
#ingredient-table :is(th, td):nth-child(n+4):nth-child(-n+12),
#plan-table :is(th, td):nth-child(n+4):nth-child(-n+7),
#content:has(> .stats) > .panel :is(th, td):nth-child(n+3):nth-child(-n+6),
.result-layout > .panel:first-child .table-wrap :is(th, td):last-child { text-align: right; }
#ingredient-table th, #ingredient-table td { padding-left: 8px; padding-right: 8px; }
#ingredient-table th:first-child, #ingredient-table td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; }
#ingredient-table th:first-child { background: #fafafa; }
#ingredient-table tr:hover td:first-child { background: #f4f8f3; }
.pill { display: inline-flex; align-items: center; width: fit-content; border-radius: 14px; padding: 4px 9px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.pill.green { background: var(--green-soft); color: #086b4c; }
.pill.red { background: var(--red-soft); color: #a52d2d; }
.pill.gray { background: #f0f0f3; color: #626267; }
.pill.blue { background: var(--accent-soft); color: var(--forest); }
.grams { color: var(--ink); font-size: 26px; font-weight: 500; letter-spacing: -.5px; }

input, select, textarea { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--input-border); border-radius: var(--control-radius); background: #fff; color: var(--ink); padding: 9px 12px; font-size: 14px; line-height: 1.5; transition: border-color 160ms, box-shadow 160ms, background 160ms; }
input:hover, select:hover, textarea:hover { border-color: #6e6e73; }
input:focus, select:focus, textarea:focus { background: #fff; }
input::placeholder, textarea::placeholder { color: #6e6e73; }
input:disabled, select:disabled, textarea:disabled { background: #f5f5f7; color: #6e6e73; cursor: not-allowed; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--red); background: #fff8f8; }
textarea { min-height: 84px; resize: vertical; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.fields.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.target-setting { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px 18px; margin-bottom: 18px; }
.target-setting p { grid-column: 1 / -1; margin: 0; }
.field { display: grid; min-width: 0; align-content: start; gap: 7px; color: #515154; font-size: 13px; font-weight: 400; }
.field.wide { grid-column: 1 / -1; }
.field-group { min-width: 0; margin: 20px 0 0; border: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
.field-group legend { padding: 0 12px 0 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.form-section { margin-top: 14px; }
.hint, .error { margin-top: 16px; border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; text-wrap: pretty; }
.hint { padding: 0; border-radius: 0; color: var(--muted); }
.hint strong { color: var(--ink); }
.error { border-left: 3px solid var(--red); background: var(--red-soft); color: #8f2c2c; white-space: pre-line; }
.empty { display: grid; justify-items: center; gap: 12px; padding: 64px 24px; color: var(--muted); text-align: center; font-size: 13px; }
.empty strong { color: var(--ink); font-size: 17px; }

.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin: 0 0 22px; }
.steps span { display: flex; align-items: center; gap: 24px; padding: 4px 0; color: #6e6e73; font-size: 12px; font-weight: 400; white-space: nowrap; }
.steps span::after { content: ''; flex: 1; height: 1px; background: #d2d2d7; }
.steps span:last-child::after { display: none; }
.planner-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.planner-layout > div { min-width: 0; border: 1px solid #e8e8ed; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.planner-layout > div > .panel { margin: 0 28px; padding: 24px 0; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); background: transparent; box-shadow: none; }
.section-number { margin-right: 0; color: var(--accent); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.planner-layout .panel-header { gap: 12px; margin-bottom: 18px; }
.planner-layout .panel-header h2 { flex-shrink: 0; }
[data-action="reset-targets"] { border-color: transparent; background: transparent; color: var(--accent); padding: 7px 0 7px 10px; min-height: 32px; }
[data-action="reset-targets"]:hover:not(:disabled) { border-color: transparent; background: transparent; text-decoration: underline; }
#generate-plan { margin: 24px 28px; min-width: 200px; max-width: calc(100% - 56px); min-height: 44px; padding-inline: 24px; }
#plan-error { margin: 24px 24px 0; }
.budget-panel { position: sticky; top: 20px; min-width: 0; border: 1px solid var(--sage-border); border-radius: var(--radius); background: linear-gradient(155deg, #edf4e9, #fafcf7 52%, #fff); box-shadow: inset 0 1px 0 #fff, 0 8px 28px -18px rgb(36 70 45 / 18%); }
.selection-box, .budget-box { margin: 0 24px; padding: 24px 0; }
.budget-box { border-top: 1px solid var(--line); }
.budget-box > strong { display: block; margin: 6px 0 24px; color: var(--forest); font-size: 48px; line-height: 1.2; letter-spacing: -2px; font-weight: 600; font-variant-numeric: tabular-nums; }
#budget-lines { padding: 14px 0; border-block: 1px solid var(--line); }
.budget-box > p { margin: 15px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.budget-box .budget-warning { padding: 12px; border-radius: 14px; background: var(--red-soft); color: #8f2c2c; }
.budget-box .budget-warning.ok { background: var(--green-soft); color: #086b4c; }
.budget-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.budget-line span:last-child { color: var(--ink); text-align: right; }
.selection-list { display: grid; gap: 7px; min-height: 38px; }
.selection-list div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.selection-list span { overflow-wrap: anywhere; }
.selection-list small { color: var(--muted); white-space: nowrap; }
.selection-status { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.food-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.food-group { min-width: 0; padding-right: 10px; border-right: 1px solid var(--line); }
.food-group:last-child { border: 0; padding-right: 0; }
.food-group h3 { margin-bottom: 10px; color: var(--forest); }
.food-choice { display: flex; gap: 8px; margin: 5px -4px; padding: 10px 4px; border-radius: 14px; cursor: pointer; transition: background 160ms; }
.food-choice:hover { background: #f4f8f3; }
.food-choice:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--sage-border); }
.food-choice:has(input:disabled) { color: var(--muted); background: #f5f5f7; cursor: not-allowed; }
.food-choice input { flex: 0 0 16px; width: 16px; min-height: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); }
.food-choice span { min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.food-choice small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.result-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.result-layout > .panel:last-child { position: sticky; top: 20px; padding: 24px; border-color: var(--sage-border); background: linear-gradient(155deg, #edf4e9, #fff 70%); }
.result-layout > .panel:last-child th:last-child, .result-layout > .panel:last-child td:last-child { text-align: right; }
.result-layout > .panel:last-child td { padding: 14px 0; }
.result-layout > .panel:first-child > h3 { margin-top: 28px; }
.result-layout > .panel:last-child > .muted { margin-top: 16px; }
.result-title { margin: 0; }
.item-state { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.encouragement { border: 0; border-left: 2px solid #91b99b; border-radius: 0 var(--radius) var(--radius) 0; padding: 24px 28px; background: #edf3e9; box-shadow: none; }
.encouragement .panel-header > div { display: flex; align-items: center; gap: 10px; }
.encouragement h2 { margin: 0; }
.encouragement > p:first-of-type { margin: 3px 0 12px; font-size: 16px; line-height: 1.9; }
.receipt { display: none; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin: 0 0 24px; }
.detail-grid div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 11px; }
.detail-grid dd { margin: 5px 0 0; font-size: 13px; overflow-wrap: anywhere; }

dialog { width: min(880px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; color: var(--ink); border: 1px solid rgb(255 255 255 / 90%); border-radius: var(--radius); padding: 0; background: #fff; box-shadow: 0 24px 90px rgb(0 0 0 / 18%); }
dialog::backdrop { background: rgb(29 29 31 / 28%); backdrop-filter: blur(6px); }
body:has(dialog[open]) { overflow: hidden; }
#dialog-content { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.dialog-head h2 { margin: 6px 0 0; font-size: 26px; letter-spacing: -.6px; }
.dialog-head button { flex-shrink: 0; align-self: flex-start; }
#notice { position: fixed; z-index: 50; top: 18px; right: 24px; max-width: min(360px, calc(100vw - 32px)); border-radius: 14px; background: #262628; color: #fff; padding: 13px 18px; box-shadow: var(--shadow); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 60; padding: 12px 18px; border-radius: 14px; color: #fff; background: var(--accent); }
.skip-link:focus { top: 12px; }
#nav-toggle, #budget-toggle { display: none; }
.drawer { position: fixed; inset: 0; width: min(344px, calc(100vw - 24px)); height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: 18px 0 0 18px; background: var(--canvas); }
.drawer-close { display: block; margin: 16px 20px 12px auto; }
.nav-drawer { width: min(300px, calc(100vw - 24px)); margin: 0 auto 0 0; border-radius: 0 18px 18px 0; }
.nav-drawer .sidebar { position: relative; inset: auto; width: 100%; height: calc(100dvh - 70px); min-height: 540px; border: 0; padding-top: 6px; }
.budget-drawer .budget-panel { position: static; border: 0; border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes dialog-enter { from { opacity: 0; transform: scale(.99); } to { opacity: 1; transform: none; } }
#content > .page-heading, #content > .panel, #content > .stats, #content > form, #content > .result-layout { animation: enter 220ms ease-out; }
dialog[open] { animation: dialog-enter 200ms ease-out; }

@media (max-width: 1100px) {
  .planner-layout, .result-layout { grid-template-columns: 1fr; }
  #budget-toggle { display: inline-flex; position: fixed; right: 24px; bottom: 20px; z-index: 15; background: var(--forest); border-color: var(--forest); color: #fff; box-shadow: 0 4px 20px rgb(18 62 50 / 18%); }
  #budget-toggle:hover { background: var(--accent); }
  #content { padding-bottom: 88px; }
}

@media (max-width: 760px) {
  main { margin-left: 0; }
  #nav-toggle { display: inline-flex; min-height: 36px; padding: 6px 12px; }
  .topbar { min-height: 60px; height: auto; gap: 12px; padding: 12px 16px; }
  .topbar { flex-wrap: wrap; }
  .topbar > span:first-of-type { font-size: 11px; }
  #today { margin-left: auto; }
  #content { padding: 26px 16px 88px; }
  h1 { font-size: 30px; }
  .page-heading, .panel-header { align-items: flex-start; flex-direction: column; }
  .page-heading { gap: 18px; }
  .panel { padding: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat, .stat:first-child { min-height: 120px; padding: 20px; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stat:nth-child(3)::before { display: none; }
  .stat + .stat::before { top: 20px; bottom: 20px; }
  .stat strong { font-size: 40px; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
  .steps span { gap: 12px; }
  .steps span:nth-child(2)::after { display: none; }
  .fields, .target-setting { gap: 16px; }
  input, select, textarea { font-size: 16px; }
  .planner-layout > div > .panel { margin-inline: 20px; }
  [data-action="reset-targets"] { padding-left: 0; }
  #generate-plan { margin: 20px; width: calc(100% - 40px); max-width: none; min-width: 0; }
  .fields.four, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .food-grid { grid-template-columns: 1fr; gap: 18px; }
  .food-group { border: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .food-choice { padding: 12px 8px; }
  .toolbar { width: 100%; }
  .toolbar .search { width: 100%; flex: 1 0 100%; }
  .toolbar select { flex: 1; min-width: 0; }
  #dialog-content { padding: 22px 18px; }
  .dialog-head h2 { font-size: 19px; }
  #budget-toggle { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .fields, .fields.four, .target-setting { grid-template-columns: 1fr; }
  .detail-grid { gap: 0 12px; }
  .form-footer { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  @page { size: 58mm 297mm; margin: 2mm; }
  html { min-width: 0; background: #fff; }
  body { width: 48mm; min-height: 0; background: #fff; color: #000; }
  body > :not(main), .topbar, #notice, #content > :not(.receipt) { display: none !important; }
  main { min-height: 0; margin: 0; }
  #content { width: 48mm; padding: 0; margin: 0; }
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { display: block; width: 48mm; box-sizing: border-box; color: #000; font-family: "Microsoft YaHei", sans-serif; font-size: 10pt; }
  .receipt h1 { margin: 0 0 2mm; font-size: 15pt; text-align: center; }
  .receipt h2 { margin: 2mm 0 1mm; font-size: 10pt; }
  .receipt-center, .receipt-foot { text-align: center; }
  .receipt-center { margin: 0; }
  .receipt-rule { margin: 2.5mm 0; border-top: 1px dashed #000; }
  .receipt table { table-layout: fixed; font-size: 9pt; }
  .receipt th, .receipt td { padding: 1.5mm .5mm; border-color: #bbb; color: #000; white-space: normal; }
  .receipt tr, .receipt th, .receipt td { background: transparent; }
  .receipt th:nth-child(1), .receipt td:nth-child(1) { width: 52%; }
  .receipt th:nth-child(2), .receipt td:nth-child(2) { width: 25%; }
  .receipt th:last-child, .receipt td:last-child { width: 23%; text-align: right; }
  .receipt td small { display: block; margin-top: .5mm; color: #555; font-size: 7.5pt; }
  .receipt-nutrition { margin: 0; }
  .receipt-nutrition div { display: flex; justify-content: space-between; padding: 1mm 0; }
  .receipt-nutrition dt, .receipt-nutrition dd { margin: 0; }
  .receipt-nutrition dd { font-weight: 800; }
  .receipt-message { margin: 0; font-size: 10pt; line-height: 1.7; }
  .receipt-foot { margin: 3mm 0 0; color: #555; font-size: 8pt; }
}
#guest-login { margin-top: 12px; }
.guest-page .guest-workspace { margin: 0 auto; max-width: 960px; padding: 36px 24px; }
.guest-workspace > .panel-header { flex-wrap: wrap; }
@media (max-width: 600px) { .guest-page .guest-workspace { padding: 24px 16px; } .guest-workspace h1 { font-size: 28px; } }
.extended-nutrition table { table-layout: fixed; }
.extended-nutrition th,.extended-nutrition td { white-space: normal; overflow-wrap: anywhere; }
.extended-nutrition th:first-child { width: 22%; }
@media(max-width:600px) { .extended-nutrition th,.extended-nutrition td { padding: 12px 5px; font-size: 12px; } }

/* Portion controls stay usable in the narrow planner workspace. */
.portion-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--border,#dce4df);flex-wrap:wrap}
.portion-row small{display:block;color:var(--muted,#586b66)}
.portion-row>div{display:flex;align-items:center;gap:6px;max-width:100%}
.portion-row input{width:80px;min-width:0;text-align:center}
.portion-row button{padding:8px}
#plan-options td:first-child{min-width:150px;max-width:260px;white-space:normal;overflow-wrap:anywhere}
#energy-explanation summary{cursor:pointer}
#plan-options button.primary{color:#fff}

#diet-choices{grid-column:1/-1;min-width:0}
.diet-choice{padding:12px 0;border-bottom:1px solid var(--line);overflow-wrap:anywhere}
.diet-choice summary{cursor:pointer;font-weight:500}
.diet-choice-grid{display:flex;flex-wrap:wrap;gap:12px 20px;padding-top:14px}
.diet-choice-grid label{display:flex;align-items:center;gap:8px}
.diet-choice-grid input{width:18px;height:18px;margin:0;flex-shrink:0}

/* Customer entry shares the white / forest-green login system. */
.guest-page { background:#fff; --accent:#143c2d; --accent-hover:#20533e; --forest:#143c2d; }
.guest-page .guest-workspace { max-width:1080px; padding:32px 36px 48px; }
.guest-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; padding-bottom:24px; margin-bottom:28px; border-bottom:1px solid var(--line); }
.guest-brand { color:var(--forest); font-size:28px; font-weight:650; line-height:1.3; }
.guest-brand span,.guest-brand small { display:block; margin-top:4px; color:var(--muted); font-size:12px; font-weight:400; }
.guest-header-actions { display:flex; flex-wrap:wrap; gap:8px; }
.guest-header-actions button { min-height:44px; font-size:13px; }
.guest-page .panel { padding:28px 0; border:0; border-radius:0; box-shadow:none; background:#fff; }
.guest-page h1 { font-size:32px; font-weight:600; letter-spacing:-.5px; }
.guest-page h2 { color:var(--forest); font-size:24px; }
.guest-page .guest-hub { padding:44px 0 24px; }
.guest-entry-actions { display:grid; grid-template-columns:1fr 1fr; gap:24px; margin-top:32px; }
.guest-entry-button { display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:12px; text-align:left; min-height:180px; padding:30px; border:1px solid var(--line); border-radius:16px; color:var(--forest); background:#f2f6f2; box-shadow:none; }
.guest-entry-button strong { font-size:24px; font-weight:600; }
.guest-entry-button span,.guest-entry-button small { font-size:14px; font-weight:400; line-height:1.7; }
.guest-entry-button.primary { background:var(--forest); color:#fff; border-color:var(--forest); }
.guest-entry-button.primary:hover { background:var(--accent-hover); }
.guest-entry-edit:hover { background:#e9f1e9; }
.guest-page .field { font-size:14px; }
.guest-page input,.guest-page select { min-height:46px; background:#fff; font-size:16px; }
.guest-page .food-choice input { min-height:0; }
.guest-page table { font-size:14px; }
.guest-page button { box-shadow:none; }
.guest-page #unlock-panel { width:min(460px,100%); margin:44px auto; }
.guest-page #unlock-panel .fields { grid-template-columns:1fr; gap:18px; margin-bottom:22px; }
.guest-page #unlock-panel button { width:100%; min-height:52px; font-size:16px; }
.guest-page #unlock-panel #new-profile { min-height:56px; margin-top:12px; }
.guest-page [hidden],.login-page [hidden] { display:none !important; }
@media(max-width:600px) {
  .guest-page .guest-workspace { padding:24px 20px 32px; }
  .guest-header { gap:12px; padding-bottom:20px; margin-bottom:16px; }
  .guest-brand { font-size:25px; }
  .guest-header-actions { gap:6px; }
  .guest-header-actions button { padding:8px 10px; font-size:12px; }
  .guest-page .guest-hub { padding:24px 0; }
  .guest-page h1 { font-size:28px; }
  .guest-page h2 { font-size:22px; }
  .guest-entry-actions { grid-template-columns:1fr; gap:16px; margin-top:24px; }
  .guest-entry-button { min-height:140px; padding:24px; }
  .guest-entry-button strong { font-size:22px; }
  .guest-page .panel { padding:20px 0; }
  .guest-page .fields { grid-template-columns:1fr; }
  .guest-page th,.guest-page td { padding:12px 8px; }
}
