/* DVE Portal — Da Vinci Exchange palette, phone first */
:root {
  --ink:#15120D; --panel:#1E1A14; --panel-2:#24201A; --panel-3:#2A251D;
  --line:#35301F; --line-soft:#2A2620; --gold:#B7A06C; --gold-b:#E2CFA0;
  --parch:#ECE5D5; --muted:#9A9280; --muted-2:#6E6858; --red:#C97A6D; --green:#8FAE8B;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--ink); color: var(--parch); font-family: "Public Sans", -apple-system, Segoe UI, sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::placeholder { color: var(--muted-2); }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(21,18,13,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 6px; }
.brand .mark { font-family: "Fraunces", serif; font-weight: 700; font-size: 1.15rem; letter-spacing: .04em; }
.brand .tag { font-family: "Fraunces", serif; font-style: italic; color: var(--gold-b); font-size: 1.05rem; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.who .nm { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; }
.pill { font-size: .72rem; color: var(--ink); background: var(--gold-b); border-radius: 20px; padding: 2px 10px; font-weight: 700; white-space: nowrap; }
.pill.ghost { color: var(--gold-b); background: transparent; border: 1px solid var(--line); font-weight: 500; }

/* Layout */
.shell { display: grid; grid-template-columns: 1fr; max-width: 1200px; margin: 0 auto; }
main { padding: 0 16px 100px; width: 100%; }
.side { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: 280px; background: var(--ink); border-right: 1px solid var(--line);
  padding: calc(74px + env(safe-area-inset-top)) 12px 24px; overflow-y: auto; transform: translateX(-100%); transition: transform .2s; }
.side.open { transform: none; }
.side a { display: flex; align-items: center; min-height: 48px; padding: 0 14px; border-radius: 10px; text-decoration: none; color: var(--muted); font-size: 1rem; }
.side a.on { background: var(--panel-2); color: var(--gold-b); }
.side .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); padding: 18px 14px 6px; }
.side .badge { margin-left: auto; background: var(--gold); color: var(--ink); border-radius: 10px; font-size: .72rem; padding: 0 8px; font-weight: 700; }
@media (min-width: 900px) {
  .shell { grid-template-columns: 250px 1fr; }
  /* Sign-in and other screens without the side menu use the full width */
  .side[hidden] + main { grid-column: 1 / -1; }
  .side { position: sticky; top: 64px; height: calc(100vh - 64px); transform: none; padding-top: 20px; z-index: 30; }   /* below the header and the View as bar */
  #menu-btn { display: none; }
  .viewas:not([hidden]) ~ .shell .side { top: var(--side-top, 120px); height: calc(100vh - var(--side-top, 120px)); }
  main { padding: 0 32px 80px; }
}

/* Page */
.head { padding: 26px 0 16px; }
.kicker { font-family: "Fraunces", serif; font-style: italic; color: var(--gold-b); font-size: .95rem; }
.head h1 { margin: 4px 0 4px; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.head p { color: var(--muted); margin: 0; }
h2 { font-size: 1.2rem; margin: 28px 0 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.card { background: linear-gradient(160deg, var(--panel), var(--panel-2)); border: 1px solid var(--line-soft); border-radius: 14px; padding: 18px; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card .meta { color: var(--muted); font-size: .9rem; }
.stat .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .val { font-family: "Fraunces", serif; font-size: 1.8rem; font-weight: 600; margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--line); border-radius: 14px; }
.soon { display: inline-block; margin-top: 8px; font-size: .78rem; color: var(--gold-b); border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; }
.big-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 64px; font-size: 1.15rem; font-weight: 700;
  background: var(--gold); color: var(--ink); border: 0; border-radius: 14px; cursor: pointer; text-decoration: none; }

/* Lists */
.list { border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; background: var(--panel); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); min-height: 60px; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; } .row .main b { display: block; } .row .main span { color: var(--muted); font-size: .88rem; }
.row.click { cursor: pointer; } .row.click:hover { background: var(--panel-2); }
.chip { display: inline-block; font-size: .74rem; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.ok { color: var(--green); border-color: #4c5f49; } .chip.off { color: var(--red); border-color: #6b453f; } .chip.gold { color: var(--gold-b); border-color: var(--gold); }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--gold); color: var(--ink); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--parch); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #6b453f; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
label.l { display: block; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 6px; }
.field { width: 100%; min-height: 50px; background: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 1rem; }
.field:focus { outline: none; border-color: var(--gold); }
textarea.field { min-height: 100px; }
.hint { color: var(--muted-2); font-size: .85rem; margin-top: 6px; }
.err { color: var(--red); font-size: .9rem; min-height: 1.3em; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.seg input { accent-color: var(--gold); margin-right: 8px; }
.note { background: var(--panel-2); border-left: 3px solid var(--gold); border-radius: 6px; padding: 12px 14px; color: var(--muted); font-size: .92rem; margin: 12px 0; }
.copybox { display: flex; gap: 8px; } .copybox input { flex: 1; }

/* Auth screens */
.auth { max-width: 420px; margin: 9vh auto 0; padding: 0 4px; }
.auth .logo { display: block; width: 120px; margin: 0 auto 10px; border-radius: 16px; }
.auth h1 { text-align: center; margin: 4px 0 18px; }
.auth .kicker { text-align: center; }
.qr { background: #fff; border-radius: 12px; padding: 12px; width: 220px; margin: 12px auto; }
.qr img, .qr svg { width: 100%; height: auto; display: block; }

/* Modal + toast */
.modal-bg { position: fixed; inset: 0; z-index: 80; background: rgba(8,7,5,.75); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h2 { margin-top: 0; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 160px); z-index: 99;
  background: var(--gold-b); color: var(--ink); font-weight: 700; padding: 12px 20px; border-radius: 12px; transition: transform .25s; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); } .toast.bad { background: var(--red); }
.viewas { position: sticky; top: 64px; z-index: 39; background: var(--gold); color: var(--ink); font-weight: 700; text-align: center; padding: 10px 16px; }
.viewas button { margin-left: 10px; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }
[data-readonly] .btn:not(.keep), [data-readonly] .big-btn { pointer-events: none; opacity: .45; }
.brand { flex-shrink: 0; }
@media (max-width: 600px) {
  .who .nm { display: none; }
  .who .pill { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .who .btn.sm { padding: 0 10px; min-height: 36px; font-size: .82rem; white-space: nowrap; }
  .brand .tag { display: none; }
}

/* Partner company brands (colors set by applyBrand) */
.branded .top { background: var(--top-bg); }
.branded .btn:not(.ghost):not(.danger), .branded .pill, .branded .big-btn, .branded .viewas { color: var(--btn-text); }
.branded .card { background: var(--panel); }
.brand-light .top { box-shadow: 0 1px 0 var(--line-soft); }
.brand-light .modal-bg { background: rgba(0,0,0,.35); }
.brand-light .chip.ok { color: #1e7a3a; border-color: #9fd3ae; } .brand-light .chip.off { color: #b3261e; border-color: #f0b4ae; }
.brand-light .brand img { box-shadow: 0 0 0 1px var(--line-soft); }
.viewas .btn { color: inherit; border-color: currentColor; }

/* Installed on an iPhone: keep the top bar clear of the status-bar blur */
@media (display-mode: standalone) {
  .top { padding-top: calc(10px + env(safe-area-inset-top)); background: var(--ink); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .branded .top { background: var(--top-bg); }
}

/* the how-to guide link at the bottom of the main menu */
.side a.help { margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 14px; color: var(--gold); }

/* Phone menu: dim the page behind it; tapping the dimmed area closes the menu */
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(8,7,5,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
@media (min-width: 900px) { .scrim { display: none; } }
