/* ==========================================================================
   Sustainable Supply Chains — styles.css
   Shared look for the student app and the admin panel, in the same design
   language as /lab/ideasearchlab (DM Serif Display + DM Sans, warm paper
   background, terracotta accent, card layout, light/dark via data-theme).
   ========================================================================== */
:root {
  --ink: #0f0e0c;
  --paper: #f5f2eb;
  --paper-dark: #ede9df;
  --accent: #c8562a;
  --accent-light: #e8784f;
  --muted: #7a7670;
  --border: #d4cfc4;
  --white: #ffffff;
  --green: #2e7d32;
  --green-bg: #e8f2e5;
  --amber: #b3760f;
  --amber-bg: #fdf3df;
  --red: #b3261e;
  --red-bg: #fdecea;
  --blue: #1f5f8b;
  --blue-bg: #e8f0f6;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(15,14,12,0.08);
  --shadow-md: 0 4px 16px rgba(15,14,12,0.10);
}
[data-theme="dark"] {
  --ink: #f0ede6;
  --paper: #1a1917;
  --paper-dark: #232220;
  --accent: #e8784f;
  --accent-light: #f09070;
  --muted: #8a8680;
  --border: #2e2c29;
  --white: #262420;
  --green: #7bd88f; --green-bg: #22301f;
  --amber: #e6c05a; --amber-bg: #322a15;
  --red: #f28b82;   --red-bg: #351f1d;
  --blue: #8ab8d8;  --blue-bg: #1c2833;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; font-weight: 400; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0.5em 0; }
a { color: var(--accent); }
button { cursor: pointer; font-family: var(--font-body); color: inherit; }
input, textarea, select { font-family: var(--font-body); color: var(--ink); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92em; }

/* ---- header ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px 18px;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--white);
  position: sticky; top: 0; z-index: 40; flex-wrap: wrap;
}
.wordmark { font-family: var(--font-display); font-size: 19px; }
.wordmark .thin { color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.role-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  background: var(--ink); color: var(--paper); padding: 3px 9px; border-radius: 3px;
}
.theme-btn {
  border: 1px solid var(--border); background: transparent; border-radius: 50%;
  width: 32px; height: 32px; font-size: 14px; line-height: 1;
}
.theme-btn:hover { background: var(--paper-dark); }

/* ---- layout ---- */
.wrap { max-width: 1220px; margin: 0 auto; padding: 30px 24px 80px; }
.wrap-narrow { max-width: 640px; }
.columns { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; align-items: start; }
.columns-wide-left { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); }
/* minmax(0,…) also when stacked: bare 1fr = minmax(auto,1fr), which lets wide
   tables force the whole page to overflow sideways on phones */
@media (max-width: 980px) { .columns, .columns-wide-left { grid-template-columns: minmax(0,1fr); } }
.columns > div { min-width: 0; }

.screen { display: none; }
.screen.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px 26px; box-shadow: var(--shadow-sm); margin: 0 0 20px;
}
.card-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-subtitle { font-size: 12px; color: var(--muted); margin: 0 0 18px; line-height: 1.6; }

.section { margin: 20px 0; }
.sub-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.section-hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin: 0 0 10px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
@media (max-width: 700px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .grid2, .grid3, .grid4 { grid-template-columns: minmax(0,1fr); } }

.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field > label { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; font-size: 14px; outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input[type=number] { max-width: 160px; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; font-size: 13px; }
select.input { max-width: 100%; }
.input-sm { padding: 5px 8px; font-size: 13px; border-radius: 5px; border-width: 1px; }
input:disabled, select:disabled { opacity: 0.55; }

/* ---- buttons ---- */
.btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 22px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500; letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--accent-light); }
.btn:active { transform: scale(0.98); }
.btn:disabled { background: var(--muted); cursor: not-allowed; opacity: 0.7; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1.5px solid var(--border);
  padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); background: var(--paper-dark); }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-green { background: var(--green); }
.btn-green:hover:not(:disabled) { filter: brightness(1.1); background: var(--green); }
.link-btn { border: none; background: none; color: var(--accent); font-size: 13px; padding: 2px; text-decoration: underline; }
.link-btn.danger { color: var(--red); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 6px 0 20px; flex-wrap: wrap; }
.tab {
  border: none; background: none; padding: 9px 15px; font-size: 14px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab .cnt { font-size: 11px; background: var(--paper-dark); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }

/* ---- pills, badges, stats ---- */
.pill { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-plain { background: var(--paper-dark); color: var(--muted); }

.esg { display: inline-block; min-width: 30px; text-align: center; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 5px; }
.esg-hi { background: var(--green-bg); color: var(--green); }
.esg-mid { background: var(--amber-bg); color: var(--amber); }
.esg-lo { background: var(--red-bg); color: var(--red); }

.stat-grid { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.stat-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; min-width: 110px; background: var(--white); }
.stat-box .n { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-box .n.pos { color: var(--green); } .stat-box .n.neg { color: var(--red); }
.stat-box .l { font-size: 11px; color: var(--muted); }

/* ---- tables ---- */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; background: var(--white); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--paper-dark); position: sticky; top: 0; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .pos { color: var(--green); } .tbl .neg { color: var(--red); }
.tbl-tight th, .tbl-tight td { padding: 4px 8px; font-size: 12.5px; }

/* ---- banners, news ---- */
.banner { border-radius: 10px; padding: 11px 15px; font-size: 13.5px; margin: 10px 0; border: 1px solid; }
.banner-info { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.banner-warn { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.banner-bad  { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.banner-good { background: var(--green-bg); border-color: var(--green); color: var(--green); }

/* Test-mode ("preview") ribbon — a constant, unmissable reminder that this tab
   is a throwaway sandbox and nothing is being saved (see store.js ?preview=1). */
.preview-ribbon { position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
  background: var(--amber, #b26a00); color: #fff; text-align: center;
  padding: 7px 14px; font-size: 13px; letter-spacing: 0.01em;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.18); }
.preview-ribbon b { font-weight: 600; }
body.preview-mode { padding-bottom: 40px; }
.news-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--border); font-size: 13.5px; align-items: baseline; }
.news-item:last-child { border-bottom: none; }
.news-round { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- toggle switch (admin) ---- */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--paper); border-radius: var(--radius); cursor: pointer; -webkit-user-select: none; user-select: none; margin: 6px 0; }
.toggle-label { font-size: 13px; font-weight: 500; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 36px; height: 20px; border-radius: 10px; background: var(--border); position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

/* ---- decision form specifics ---- */
.comp-card { border: 1px solid var(--border); border-radius: 10px; margin: 12px 0; overflow: hidden; background: var(--white); }
.comp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--paper-dark); flex-wrap: wrap; }
.comp-head b { font-size: 14px; }
.comp-meta { font-size: 11.5px; color: var(--muted); }
.qty-input { width: 76px; }
.mode-select { width: auto; }

.preview-box { border: 1.5px dashed var(--accent); border-radius: 10px; padding: 12px 16px; background: var(--paper); margin: 14px 0; }
.preview-box .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; }
.preview-box .row b { font-variant-numeric: tabular-nums; }

.code-box { margin: 14px 0; padding: 14px 16px; border: 1.5px dashed var(--accent); border-radius: 10px; background: var(--paper); }
.code-big { font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: 0.18em; color: var(--accent); font-weight: 700; }
.launch-link { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; margin: 6px 0; }

/* ---- session cards (admin right column) ---- */
.sess-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 15px; margin: 10px 0; background: var(--white); }
.sess-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sess-name { font-weight: 600; font-size: 15px; }
.sess-code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.sess-meta { font-size: 12px; color: var(--muted); margin: 4px 0; }
.sess-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; align-items: center; }

/* ---- misc ---- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.right { text-align: right; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.flex-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt0 { margin-top: 0; } .mt16 { margin-top: 16px; } .mb6 { margin-bottom: 6px; }
.hr { border: none; border-top: 1px dashed var(--border); margin: 16px 0; }
.err-msg { color: var(--red); font-size: 13px; margin-top: 6px; }
.ok-flash { color: var(--green); font-weight: 600; font-size: 13px; opacity: 0; transition: opacity 0.25s; }
.ok-flash.show { opacity: 1; }
.help {
  display: inline-block; width: 15px; height: 15px; line-height: 13px; text-align: center;
  font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--border);
  border-radius: 50%; cursor: help; vertical-align: middle;
}
[title]:hover > .help { color: var(--accent); border-color: var(--accent); }

.chart-box { background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 12px 0; overflow-x: auto; }
.chart-box h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.chart-box .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

.checkline { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; margin: 6px 0; cursor: pointer; }
.checkline input { margin-top: 4px; accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }

/* landing hero (student join screen) */
.hero { text-align: center; padding: 40px 0 10px; }
.hero h1 { font-size: 34px; margin-bottom: 8px; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 8px; }
.hero .globe { font-size: 40px; }

/* ---- small screens / touch ------------------------------------------------ */
@media (max-width: 640px) {
  .wrap { padding: 18px 12px 60px; }
  .topbar { padding: 10px 14px; }
  .wordmark .thin { display: none; }
  .card { padding: 16px 14px; }
  .hero h1 { font-size: 27px; }
  h1 { font-size: 25px; }
  .stat-box { min-width: 96px; padding: 8px 12px; flex: 1 1 30%; }
  .stat-box .n { font-size: 18px; }
}
/* iOS Safari zooms the page when a focused input's font is under 16px —
   keep inputs at 16px on coarse-pointer devices so focusing never zooms */
@media (pointer: coarse) {
  .input, .input-sm, select.input { font-size: 16px; }
  .qty-input { width: 92px; }
  .btn-sm { padding: 8px 15px; }
}
