/* Mosaic — Mater green/gold, same tokens as MITS (#1B4D33 / #123526 / #E3B23C / #FAF8F2,
   Playfair Display + Inter). Dark mode: OS setting, or the header toggle. */

:root {
  --green: #1B4D33;
  --green-dark: #123526;
  --gold: #E3B23C;
  --gold-dark: #B8891E;
  --bg: #FAF8F2;
  --card: #FFFFFF;
  --ink: #1E241F;
  --muted: #5F675F;
  --border: #E4E1D6;
  --soft: #F3F0E6;
  --danger: #A8382A;
  --danger-bg: #FBEDEA;
  --ok: #1E6B45;
  --ok-bg: #E8F3EC;
  --warn: #7A5A00;
  --warn-bg: #FCF3D9;
  --info-bg: #EAF1EE;
  --focus: #E3B23C;
  --shadow: 0 1px 2px rgba(18, 53, 38, .06), 0 4px 16px rgba(18, 53, 38, .06);
  --radius: 14px;
  --lvl0-bg: #E3B23C; --lvl0-ink: #2A2005;
  --lvl1-bg: #1B4D33; --lvl1-ink: #FFFFFF;
  --lvl2-bg: #DCEBE2; --lvl2-ink: #123526;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111613;
  --card: #1A211C;
  --ink: #ECE9DF;
  --muted: #A6AEA6;
  --border: #2D372F;
  --soft: #202923;
  --danger: #F09A8C;
  --danger-bg: #3A1F1A;
  --ok: #8FD9AE;
  --ok-bg: #16301F;
  --warn: #F2CF72;
  --warn-bg: #352B10;
  --info-bg: #1C2A22;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --lvl1-bg: #2F7A52; --lvl1-ink: #FFFFFF;
  --lvl2-bg: #24382C; --lvl2-ink: #CFE6D7;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613;
    --card: #1A211C;
    --ink: #ECE9DF;
    --muted: #A6AEA6;
    --border: #2D372F;
    --soft: #202923;
    --danger: #F09A8C;
    --danger-bg: #3A1F1A;
    --ok: #8FD9AE;
    --ok-bg: #16301F;
    --warn: #F2CF72;
    --warn-bg: #352B10;
    --info-bg: #1C2A22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --lvl1-bg: #2F7A52; --lvl1-ink: #FFFFFF;
    --lvl2-bg: #24382C; --lvl2-ink: #CFE6D7;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--green); }
:root[data-theme="dark"] a { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: var(--gold); } }
h1, h2, h3 { font-family: "Playfair Display", Georgia, serif; font-weight: 700; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* ---------- top bar ---------- */
.topbar { background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%); color: #fff; border-bottom: 3px solid var(--gold); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; }
.topbar > .topbar-inner { min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff !important; text-decoration: none; }
.brand-name { display: block; font-family: "Playfair Display", Georgia, serif; font-weight: 700; font-size: 1.45rem; line-height: 1.1; letter-spacing: .01em; }
.brand-sub { display: block; font-size: .78rem; opacity: .82; letter-spacing: .02em; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { color: #fff !important; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: .92rem; opacity: .88; }
.mainnav a:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
.mainnav a[aria-current="page"] { background: var(--gold); color: var(--green-dark) !important; opacity: 1; font-weight: 600; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--green-dark); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.user-name { display: block; font-weight: 600; font-size: .92rem; line-height: 1.15; }
.user-role { display: block; font-size: .75rem; opacity: .8; }
.icon-btn { background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, .2); }
.lastlogin { background: var(--green-dark); color: rgba(255, 255, 255, .86); font-size: .82rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.lastlogin .topbar-inner { min-height: 34px; gap: 14px; flex-wrap: wrap; }
.lastlogin strong { color: #fff; font-weight: 600; }
.lastlogin a { color: var(--gold) !important; margin-left: auto; }
.warn-pill { background: var(--gold); color: var(--green-dark); border-radius: 999px; padding: 1px 10px; font-weight: 600; }

/* ---------- layout ---------- */
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 20px 40px; flex: 1; }
.page-title { margin-bottom: 4px; }
.page-sub { margin: 0 0 22px; }
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { margin: 0 0 14px; font-size: .9rem; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-title { font-size: 1.4rem; }
.link-sm { font-size: .85rem; font-weight: 600; }
.narrow { max-width: 620px; margin: 0 auto; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack-col > .card:last-child { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > form { margin: 0; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 20px; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 42px; width: 100%;
}
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--green); }
input[type="color"] { padding: 4px; height: 42px; }
input:disabled { background: var(--soft); color: var(--muted); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-family: "Playfair Display", Georgia, serif; font-weight: 700; padding: 0 6px; }
.hint { font-weight: 400; font-size: .82rem; color: var(--muted); }
form label + label, form label + button { margin-top: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer;
  border-radius: 999px; padding: 9px 18px; min-height: 40px;
  background: var(--card); color: var(--ink) !important; border: 1px solid var(--border);
}
.btn:hover { border-color: var(--green); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff !important; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
:root[data-theme="dark"] .btn-primary { background: var(--gold); border-color: var(--gold); color: #1E1A0C !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: var(--gold); border-color: var(--gold); color: #1E1A0C !important; } }
.btn-danger { color: var(--danger) !important; border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-disabled { background: var(--soft); color: var(--muted) !important; cursor: not-allowed; border-style: dashed; }
.btn-ghost-light { background: transparent; color: #fff !important; border-color: rgba(255, 255, 255, .45); min-height: 36px; padding: 6px 14px; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .12); border-color: #fff; }

/* ---------- flashes ---------- */
.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: var(--info-bg); color: var(--ink); }

/* ---------- dashboard ---------- */
.dash { display: block; }
.dash-admin { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 24px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.tile {
  --app: #1B4D33;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--app); }
.tile-head { display: flex; gap: 12px; align-items: center; }
.app-icon {
  width: 46px; height: 46px; flex: none; border-radius: 12px; background: var(--app); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; letter-spacing: .02em;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.app-icon.sm { width: 34px; height: 34px; border-radius: 9px; font-size: .68rem; }
/* v1.0.3 app logos: white rounded square (stays white in dark mode so every logo reads) */
.app-icon.has-logo { background: #fff; padding: 5px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.app-icon.sm.has-logo { padding: 4px; }
.app-icon.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-title { margin: 0; font-size: 1.3rem; }
.tile-full { font-size: .82rem; color: var(--muted); line-height: 1.3; }
.tile-desc { margin: 0; font-size: .9rem; flex: 1; }
.tile-meta { display: flex; gap: 22px; margin: 0; font-size: .85rem; }
.tile-meta dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.tile-meta dd { margin: 2px 0 0; font-weight: 500; }
.tile-open { align-self: flex-start; }
.tile-note { font-size: .78rem; color: var(--muted); margin-top: -4px; }
.status { margin-left: auto; align-self: flex-start; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status-live { background: var(--ok-bg); color: var(--ok); }
.status-live::before { content: "●  "; font-size: .7em; vertical-align: 1px; }
.status-soon { background: var(--warn-bg); color: var(--warn); }
.status-hidden { background: var(--soft); color: var(--muted); }
.tile-soon { background: var(--soft); box-shadow: none; }
.tile-soon .app-icon { opacity: .75; }
.tile-next {
  border: 2px dashed var(--border); background: transparent; box-shadow: none; text-decoration: none; color: var(--ink) !important;
  align-items: center; justify-content: center; text-align: center; min-height: 230px;
}
.tile-next::before { display: none; }
.tile-next:hover { border-color: var(--gold); }
.next-plus { width: 46px; height: 46px; border-radius: 50%; border: 2px dashed var(--gold); color: var(--gold-dark); display: grid; place-items: center; font-size: 1.6rem; line-height: 1; }

.lvl { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.lvl-0 { background: var(--lvl0-bg); color: var(--lvl0-ink); }
.lvl-1 { background: var(--lvl1-bg); color: var(--lvl1-ink); }
.lvl-2, .lvl-3 { background: var(--lvl2-bg); color: var(--lvl2-ink); }
.lvl-none { color: var(--muted); }

.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.access-grid { border-collapse: collapse; width: 100%; font-size: .85rem; }
.access-grid th, .access-grid td { padding: 7px 3px; border-bottom: 1px solid var(--border); text-align: center; }
.access-grid thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.access-grid tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
.access-grid tbody th a { color: var(--ink); text-decoration: none; }
.access-grid tbody th a:hover { text-decoration: underline; }
.access-grid .lvl { font-size: .7rem; padding: 2px 7px; vertical-align: middle; }
.access-grid th, .access-grid td { white-space: nowrap; }
.sa-tag, .here-tag { font-size: .65rem; font-weight: 700; background: var(--gold); color: var(--green-dark); border-radius: 4px; padding: 1px 5px; vertical-align: 1px; }
.legend { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.link-row { margin: 10px 0 0; font-size: .85rem; }

.signins { list-style: none; margin: 0; padding: 0; }
.signins li { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.signins li:last-child { border-bottom: 0; }
.signins .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-top: 7px; grid-row: span 2; }
.signins .is-fail .dot { background: var(--danger); }
.signins .who { font-weight: 600; font-size: .9rem; }
.signins .when { font-size: .8rem; color: var(--muted); }
.fail-tag { font-size: .68rem; font-weight: 700; color: var(--danger); background: var(--danger-bg); border-radius: 4px; padding: 1px 6px; margin-left: 4px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--soft); }
.table tbody th { font-weight: 600; }
.table tbody th a { color: var(--ink); }
.table tr.is-fail td { background: color-mix(in srgb, var(--danger-bg) 60%, transparent); }
.access-edit select { min-width: 130px; min-height: 38px; padding: 7px 10px; font-size: .88rem; }
.access-edit select.is-none { color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; background: var(--card); padding-top: 14px; }
.app-cell { display: flex; gap: 10px; align-items: center; --app: #1B4D33; }

.access-rows { display: flex; flex-direction: column; gap: 10px; }
.access-row { --app: #1B4D33; display: grid; grid-template-columns: 34px minmax(120px, 1fr) 150px minmax(140px, 1fr); gap: 10px; align-items: center; }
.access-name { display: flex; flex-direction: column; line-height: 1.25; }
.access-row select, .access-row input { min-height: 38px; padding: 7px 10px; font-size: .88rem; }

.facts { margin: 0; display: grid; gap: 8px; }
.facts > div { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.temp-pw { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--card)); }
.temp-row, .secret-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.temp-row code { font-size: 1.3rem; font-weight: 700; letter-spacing: .04em; background: var(--card); border: 1px dashed var(--gold); padding: 8px 14px; border-radius: 10px; }
.secret { display: block; width: 100%; background: var(--soft); border-radius: 10px; padding: 10px 12px; overflow-wrap: anywhere; font-size: .8rem; }
.secret.is-masked { color: transparent; text-shadow: 0 0 7px var(--muted); user-select: none; }

.filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
.filters select { width: auto; min-height: 38px; padding: 6px 10px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg a { text-decoration: none; color: var(--ink) !important; padding: 6px 12px; border-radius: 999px; font-size: .88rem; font-weight: 500; border: 1px solid var(--border); }
.seg a[aria-current="true"] { background: var(--green); border-color: var(--green); color: #fff !important; }

/* ---------- sign-in pages ---------- */
.auth .auth-wrap { max-width: 440px; width: 100%; margin: 0 auto; padding: 56px 16px 40px; flex: 1; }
.auth { background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--green) 22%, var(--bg)), var(--bg)); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; justify-content: center; }
.auth-brand .mark rect:not(:first-child) { fill: var(--green); }
.auth-brand .brand-name { color: var(--ink); font-size: 1.9rem; }
.auth-brand .brand-sub { color: var(--muted); font-size: .85rem; }
.auth-card { padding: 28px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-links { text-align: center; margin: 16px 0 0; font-size: .9rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 16px 20px; display: flex; gap: 8px 24px; flex-wrap: wrap; }
.footer-inner span:first-child { font-weight: 600; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .dash-admin { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .topbar > .topbar-inner { gap: 10px 14px; }
  .mainnav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .mainnav a { white-space: nowrap; }
  .access-row { grid-template-columns: 34px 1fr; }
  .access-row select, .access-row input { grid-column: 2; }
}
@media (max-width: 560px) {
  .legend { gap: 6px 12px; }
  .page { padding: 20px 16px 32px; }
  .topbar-inner, .footer-inner { padding-left: 16px; padding-right: 16px; }
  h1, .page-title { font-size: 1.55rem; }
  .brand-sub { display: none; }
  .user-chip > span:last-child { display: none; }
  .cols-2 { grid-template-columns: 1fr; }
  .facts > div { grid-template-columns: 1fr; gap: 0; }
  .tiles { grid-template-columns: 1fr; }
  .lastlogin a { margin-left: 0; }
}
.stack > p { margin: 0; }
