/* BuyLowa shared design system
   Edit brand colours, shared header/footer, buttons, forms, modals and page tone here.
   Page-specific files should build on these tokens instead of redefining the brand.
*/

:root {
  --ink: #16140f;
  --ink-2: #34312a;
  --muted: #736f66;
  --line: #ded9cf;
  --line-dark: #26231d;
  --paper: #fbfaf6;
  --paper-2: #f1eee6;
  --white: #fffdf8;
  --green: #0f6b3d;
  --green-2: #0a4c2d;
  --green-3: #dceee3;
  --gold: #d8a821;
  --red: #bc2f2c;
  --blue: #315f8c;
  --shadow: 0 20px 45px rgba(28, 22, 10, .08);
  --font-body: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", Georgia, serif;

  /* BuyLowa semantic colour roles */
  --color-ui: var(--ink);
  --color-ui-soft: var(--ink-2);
  --color-brand: var(--gold);
  --color-brand-soft: #f6edd0;
  --color-money: #087a44;
  --color-money-soft: #e8f5ee;
  --color-action: var(--ink);
  --color-action-hover: #2a251c;
  --color-positive: #087a44;
  --color-negative: #b42318;
  --color-saving: #b42318;
  --color-warning: #b56f00;
  --color-code: var(--ink);
  --color-code-border: var(--gold);
  --color-code-bg: #fff8df;
  --color-link: var(--ink);
  --color-community: var(--gold);

  /* Compatibility aliases for older page-specific files. */
  --green-900: #0a2416;
  --green-800: #11100d;
  --green-700: #0f6b3d;
  --green-600: #168150;
  --green-400: #d8a821;
  --green-200: #dceee3;
  --green-100: #edf7f0;
  --green-50: #fbfaf6;
  --red-600: #a72724;
  --red-500: #bc2f2c;
  --red-100: #fbe4e1;
  --amber-500: #d8a821;
  --amber-100: #fbf3d3;
  --blue-500: #315f8c;
  --blue-100: #e2edf6;
  --gray-900: #16140f;
  --gray-700: #34312a;
  --gray-500: #736f66;
  --gray-600: #585247;
  --gray-400: #9b9487;
  --gray-300: #c9c2b4;
  --gray-200: #ded9cf;
  --gray-100: #f1eee6;
  --gray-50: #fbfaf6;
  --shadow-sm: 0 1px 2px rgba(28, 22, 10, .06);
  --shadow-md: 0 8px 20px rgba(28, 22, 10, .08);
  --shadow-lg: var(--shadow);
  --radius-sm: 4px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --meter: 0%;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .62;
}

:focus-visible {
  outline: 3px solid rgba(216, 168, 33, .55);
  outline-offset: 3px;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }

/* Setup */
.setup-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(135deg, #e7efe7 0%, #fbfaf6 65%);
}
.setup-panel {
  width: min(620px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 34px;
}
.setup-label, .section-kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.setup-panel h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1;
}
.setup-panel p { color: var(--muted); }
.setup-panel code { background: var(--paper-2); padding: 2px 5px; }
.setup-steps { display: grid; gap: 10px; margin: 22px 0; }
.setup-steps div { display: flex; gap: 12px; align-items: center; }
.setup-steps strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--ink);
  color: var(--white);
}
.setup-field { display: grid; gap: 6px; margin: 14px 0; font-weight: 800; }
.setup-field input,
.username-field input,
.form-input,
.form-select,
.form-textarea,
.admin-input,
.admin-select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
  border-radius: 0;
}
.form-select { min-height: 48px; }
.form-textarea { min-height: 150px; resize: vertical; }
.setup-field input:focus,
.username-field input:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.search-market:focus-within,
.admin-input:focus,
.admin-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 107, 61, .12);
}
.setup-submit,
.modal-primary,
.btn-primary-system {
  width: 100%;
  border: 0;
  background: var(--green);
  color: white;
  font-weight: 850;
  padding: 14px 18px;
  margin-top: 8px;
}


.setup-reset-btn {
  justify-self: center;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--green-700);
  text-decoration: underline;
  font-size: 14px;
  font-weight: 850;
}

/* Shared public/header system */
.market-header,
.site-header,
.admin-header {
  background: #11100d;
  color: var(--white);
  border-bottom: 4px solid var(--gold);
  box-shadow: none;
  position: relative;
  z-index: 20;
}
.header-service-row {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0;
  color: rgba(255, 253, 248, .66);
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.header-main-row {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 78px;
  display: grid;
  grid-template-columns: 245px minmax(260px, 720px) auto;
  align-items: center;
  gap: 28px;
}
.header-inner,
.admin-header-inner {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0;
}
.brand-lockup,
.logo-link,
.brand-logo,
.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  transform: skew(-12deg);
}
.brand-text,
.brand-word,
.admin-brand span {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -.04em;
  color: #fff;
}
.admin-brand small {
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.logo-mark { display: none; }
.search-market {
  background: var(--white);
  border: 1px solid transparent;
  color: var(--ink);
  height: 48px;
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  padding: 0 15px;
}
.search-symbol {
  width: 16px;
  height: 16px;
  border: 2px solid #69645c;
  border-radius: 50%;
  position: relative;
}
.search-symbol::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  background: #69645c;
  transform: rotate(45deg);
  right: -6px;
  bottom: -4px;
}
.search-market input {
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 0;
}
.member-actions,
.header-actions,
.admin-header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}
.member-link,
.post-link,
.btn-post-deal,
.header-user-btn,
.admin-head-link,
.admin-user-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0 16px;
  font-weight: 850;
  border-radius: 0;
}
.member-link,
.header-user-btn,
.admin-head-link {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: var(--white);
}
.member-link.signed-in,
.header-user-btn:hover,
.admin-head-link:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.65);
}
.post-link,
.btn-post-deal,
.admin-user-btn {
  background: var(--gold);
  border: 1px solid var(--gold);
  color: #17130a;
}
.primary-nav,
.header-nav {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
}
.header-nav { justify-content: flex-end; width: auto; margin: 0; min-height: 0; }
.primary-nav a,
.header-nav a {
  color: rgba(255,253,248,.78);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}
.primary-nav a:hover,
.header-nav a:hover { color: #fff; }
.post-header-spacer { flex: 1; }

/* Shared footer */
.site-footer {
  margin-top: 40px;
  background: #11100d;
  color: rgba(255,253,248,.72);
  border-top: 4px solid var(--gold);
}
.footer-inner {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
.footer-inner strong,
.footer-brand strong { color: #fff; font-weight: 900; }
.footer-inner p,
.footer-brand span { margin: 6px 0 0; color: rgba(255,253,248,.72); }
.footer-brand { display: grid; gap: 2px; }
.footer-links { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.footer-links a { color: rgba(255,253,248,.72); text-decoration: none; font-weight: 800; }
.footer-links a:hover { color: #fff; }

/* Shared form/action pieces */
.form-label { display: block; font-weight: 850; margin-bottom: 7px; color: var(--ink); }
.form-hint { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.req { color: var(--red); }
.btn-set-username,
.btn-submit-deal,
.admin-primary-btn {
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  padding: 12px 16px;
  text-decoration: none;
}
.btn-cancel,
.post-secondary-link,
.admin-secondary-btn {
  border: 1px solid var(--line-dark);
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  padding: 12px 16px;
  text-decoration: none;
}
.admin-danger-btn {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  font-weight: 900;
  padding: 12px 16px;
}

/* Modal / toast */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(14, 12, 8, .55);
  display: grid;
  place-items: center;
  padding: 22px;
}
.modal-box {
  width: min(440px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-dark);
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 28px; }
.modal-close { border: 0; background: transparent; font-size: 24px; line-height: 1; }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.modal-secondary { width: 100%; border: 1px solid var(--line); background: transparent; font-weight: 900; padding: 12px; }
.username-field { display: grid; grid-template-columns: 34px 1fr; align-items: center; border: 1px solid var(--line); }
.username-field span { text-align: center; color: var(--muted); }
.username-field input { border: 0; box-shadow: none; }
.username-avail { min-height: 20px; color: var(--muted); font-size: 13px; }
.avail-yes { color: var(--green); font-weight: 850; }
.avail-no { color: var(--red); font-weight: 850; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { padding: 12px 14px; background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.toast.ok, .toast-ok { background: var(--green); }
.toast.err, .toast-err { background: var(--red); }
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }
.spinner,
.admin-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .header-main-row { grid-template-columns: 1fr; gap: 14px; padding: 18px 0; }
  .member-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .header-service-row { display: none; }
  .header-main-row,
  .primary-nav,
  .header-inner,
  .admin-header-inner,
  .footer-inner { width: min(100% - 24px, 1480px); }
  .header-inner,
  .admin-header-inner { min-height: 68px; }
  .brand-text,
  .brand-word,
  .admin-brand span { font-size: 24px; }
  .primary-nav { overflow-x: auto; gap: 20px; flex-wrap: nowrap; }
  .footer-inner { flex-direction: column; align-items: stretch; }

  .modal-overlay { padding: 12px; align-items: end; }
  .modal-box { width: 100%; max-height: calc(100vh - 24px); }
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
}

/* Account auth components */
.account-modal-box {
  width: min(520px, 100%);
}

.account-modal-body,
.post-account-card,
.admin-login-card {
  --account-gap: 12px;
}

.account-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--paper);
}

.account-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 950;
  min-height: 42px;
  padding: 10px 12px;
}

.account-tab.active,
.account-tab:hover {
  background: var(--ink);
  color: var(--white);
}

.account-form {
  display: grid;
  gap: var(--account-gap, 12px);
  min-width: 0;
}

.account-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  text-align: left;
}

.account-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.account-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-dark);
  background: var(--white);
  color: var(--ink);
  padding: 12px 13px;
  font: inherit;
  outline: 0;
}

.account-field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(28, 23, 16, .12);
}

.account-help,
.account-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

.account-status:not(:empty) {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 10px 12px;
}

.account-status[data-type="ok"] {
  color: var(--green);
  border-color: rgba(8, 122, 68, .25);
  background: var(--color-money-soft);
}

.account-status[data-type="err"] {
  color: var(--red);
  border-color: rgba(180, 35, 24, .25);
  background: #fff1ee;
}

.account-text-btn {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 0;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.account-text-btn:hover {
  color: var(--gold);
}
