/* ============================================================
   MakerKoh — design system
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 px
   ============================================================ */

/* Brand wordmark ("MAKER KOH") is rendered as an image in the real Colonna MT
   typeface (see icons/logo-full.png + icons/wordmark-white.png), so it looks
   identical on every device without needing the font installed. */

:root {
  --blue: #34568b;       /* light navy */
  --blue-dark: #2a4571;  /* hover/pressed */
  --blue-tint: #e9eef6;  /* soft navy wash for secondary buttons */
  --ink: #16202c;
  --muted: #5b6776;
  --line: #e6e9ee;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1a7f4b;
  --err: #c0303a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,32,44,.06), 0 6px 20px rgba(16,32,44,.06);
  --shadow-sm: 0 1px 3px rgba(16,32,44,.08);
  --tap: 52px; /* minimum touch target */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* the hidden attribute must always win, even over .view--center's display:flex */
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
button { font-family: inherit; }
:focus-visible { outline: 3px solid rgba(31,111,235,.45); outline-offset: 2px; }

/* ---------- Layout ---------- */
.view {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}
.view--center {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

/* ---------- Sign-in screen ---------- */
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}
.brand-lockup {
  display: block; width: 100%; max-width: 230px; height: auto;
  margin: 0 auto 14px;
}
.brand-tagline { color: var(--muted); margin: 0 0 24px; font-size: 15px; }

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.gsi-slot { display: flex; justify-content: center; min-height: 44px; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 20px 0 0; }

/* Google fallback button (used if the official widget can't load) */
.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-google .g {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 13px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--blue); color: #fff;
  box-shadow: 0 2px 10px rgba(16,32,44,.12);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__logo { width: 28px; height: 28px; border-radius: 8px; background: #fff; }
.topbar__wordmark { height: 17px; width: auto; display: block; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.7); background: rgba(255,255,255,.15);
  color: #fff; font-weight: 700; font-size: 16px; cursor: pointer;
}

/* ---------- Home ---------- */
.greeting { font-size: 22px; font-weight: 700; margin: 6px 0 20px; letter-spacing: -.3px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }

/* Tiles — big, kid-friendly, perfectly aligned grid */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 0 0 28px; }
.tile {
  position: relative;
  aspect-ratio: 1 / .82;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform .08s ease, box-shadow .15s ease;
}
.tile:not(:disabled):active { transform: scale(.97); }
.tile:not(:disabled):hover { box-shadow: var(--shadow); }
.tile__icon { font-size: 34px; line-height: 1; }
.tile__label { font-size: 16px; font-weight: 650; }
.tile__badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  color: var(--muted); background: var(--bg);
  padding: 3px 8px; border-radius: 999px;
}
.tile:disabled { opacity: .6; cursor: default; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card__title { margin: 0 0 4px; font-size: 17px; }
.card__hint { margin: 0 0 16px; color: var(--muted); font-size: 14px; }

/* Buttons */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  min-height: var(--tap); padding: 0 22px;
  border: 0; border-radius: 999px;
  background: var(--blue); color: #fff;
  font-size: 16px; font-weight: 650; cursor: pointer;
  transition: background .15s ease, transform .08s ease;
}
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: scale(.98); }
.btn-secondary { background: var(--blue-tint); color: var(--blue); }
.btn-secondary:hover { background: #dce8fb; }
.btn:disabled { opacity: .55; cursor: default; }

/* Text area (announcement editor) */
.textarea {
  width: 100%; margin: 0 0 14px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px; color: var(--ink);
  line-height: 1.45; resize: vertical; min-height: 84px;
}
.textarea:focus { border-color: var(--blue); outline: none;
  box-shadow: 0 0 0 3px rgba(52,86,139,.18); }

/* Result / status */
.msg { color: var(--err); min-height: 1.2em; margin: 12px 0 0; font-size: 14px; }
.result {
  margin: 16px 0 0; padding: 14px; border-radius: var(--radius-sm);
  background: #0d1117; color: #d6e2ef; font-size: 13px;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Screen header (Products / Raw Materials) ---------- */
.screen-head {
  display: flex; align-items: center; gap: 12px; margin: 0 0 20px;
}
.screen-title { flex: 1; margin: 0; font-size: 20px; font-weight: 700; }
.btn-back {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; min-height: 40px; padding: 0 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-back:hover { background: var(--bg); }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 14px; }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px; color: var(--ink); background: #fff;
}
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(52,86,139,.18); }

/* Photo picker */
.photo-pick {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 160px; margin: 0 0 16px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; overflow: hidden;
}
.photo-placeholder { color: var(--muted); font-weight: 600; }
.photo-preview { width: 100%; max-height: 280px; object-fit: contain; }

/* Bill of materials */
.bom { margin: 4px 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.bom__head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.bom__head .section-title { margin: 0; }
.bom-row { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.bom-row .bom-mat { flex: 2; min-width: 0; }
.bom-row .bom-qty { flex: 1; min-width: 64px; }
.bom-unit { width: 42px; font-size: 13px; color: var(--muted); }
.bom-del {
  border: 0; background: transparent; color: var(--err);
  font-size: 18px; cursor: pointer; padding: 6px; line-height: 1;
}

/* ---------- Lists (Raw Materials) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list__loading { color: var(--muted); padding: 12px 0; }
.list__item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; margin: 0 0 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__name { font-weight: 650; }
.list__sub { font-size: 13px; color: var(--muted); }
.list__link { font-size: 13px; color: var(--blue); font-weight: 600; text-decoration: none; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

.pill {
  flex-shrink: 0; font-size: 13px; font-weight: 700;
  padding: 5px 12px; border-radius: 999px;
  background: var(--blue-tint); color: var(--blue);
}
.pill--ok { background: #e3f4ea; color: var(--ok); }
.pill--warn { background: #fce8ea; color: var(--err); }

/* ---------- Product cards ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.pcard {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.pcard__photo {
  aspect-ratio: 1 / 1; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.pcard__photo img { width: 100%; height: 100%; object-fit: cover; }
.pcard__noimg { font-size: 40px; opacity: .5; }
.pcard__body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.pcard__name { font-weight: 650; line-height: 1.3; }
.pcard__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pcard__price { font-weight: 700; }
.pcard__made { align-self: flex-start; }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 720px) {
  .view { padding-top: 28px; }
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .tile { aspect-ratio: 1 / .9; }
  .greeting { font-size: 26px; }
  .grid-cards { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}
