:root{
  --paper:#FAF9F6; --card:#FFFFFF; --ink:#1F2A2E; --muted:#6B7A7E;
  --teal:#0066ff; --teal-dark:#0a1f44; --teal-soft:#e8f0ff;
  --amber:#F59E0B; --line:#E5E1D8; --danger:#47597a; --success:#15803D;
  --radius:16px; --shadow:0 10px 30px rgba(15,118,110,.10), 0 2px 8px rgba(31,42,46,.06);
}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--paper);color:var(--ink);line-height:1.6}
a{color:var(--teal);text-decoration:none} a:hover{text-decoration:underline}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:linear-gradient(135deg,var(--teal),var(--teal-dark));color:#fff!important;border:none;padding:12px 22px;border-radius:12px;font-weight:700;font-size:15px;cursor:pointer;box-shadow:0 8px 20px rgba(15,118,110,.25);transition:.2s;text-decoration:none!important}
.btn:hover{transform:translateY(-1px);box-shadow:0 12px 24px rgba(15,118,110,.30)}
.btn-block{width:100%} .btn-light{background:#fff;color:var(--teal-dark)!important;box-shadow:none;border:1px solid var(--line)}
.btn-danger{background:linear-gradient(135deg,#47597a,var(--danger));box-shadow:none} .btn-sm{padding:7px 13px;font-size:13px;border-radius:9px}
.btn-amber{background:linear-gradient(135deg,#FBBF24,var(--amber));color:#442C02!important;box-shadow:none}
/* Landing */
.hero{min-height:100vh;display:flex;flex-direction:column;background:radial-gradient(900px 500px at 85% -10%,#dbe8ff 0%,transparent 60%),radial-gradient(700px 400px at -10% 110%,#FDE68A55 0%,transparent 55%),var(--paper)}
.navbar{display:flex;justify-content:space-between;align-items:center;padding:22px 6vw}
.logo{font-size:24px;font-weight:800;color:var(--ink)} .logo b{color:var(--teal)} .logo-icon{display:inline-grid;place-items:center;width:38px;height:38px;border-radius:11px;background:linear-gradient(135deg,var(--teal),var(--teal-dark));color:#fff;margin-right:9px;vertical-align:middle}
.hero-inner{flex:1;display:grid;grid-template-columns:1.1fr .9fr;gap:48px;align-items:center;padding:20px 6vw 70px;max-width:1280px;margin:0 auto;width:100%}
.hero h1{font-size:52px;line-height:1.08;letter-spacing:-1.5px;font-weight:800}
.hero h1 span{background:linear-gradient(90deg,var(--teal),#2f7dff);-webkit-background-clip:text;background-clip:text;color:transparent}
.hero p.lead{font-size:18px;color:var(--muted);margin:20px 0 28px;max-width:520px}
.hero-actions{display:flex;gap:14px;flex-wrap:wrap}
.role-cards{display:grid;gap:16px}
.role-card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:22px;box-shadow:var(--shadow);display:flex;gap:16px;align-items:flex-start}
.role-card .rc-icon{width:52px;height:52px;border-radius:14px;display:grid;place-items:center;font-size:24px;background:var(--teal-soft);flex-shrink:0}
.role-card h3{font-size:17px} .role-card p{color:var(--muted);font-size:14px}
.pill{display:inline-block;background:var(--teal-soft);color:var(--teal-dark);font-weight:700;font-size:12px;letter-spacing:.06em;text-transform:uppercase;padding:6px 12px;border-radius:999px;margin-bottom:16px}
/* Auth */
.auth-wrap{min-height:100vh;display:grid;grid-template-columns:1fr 1fr}
.auth-side{background:linear-gradient(160deg,#0a1f44,var(--teal-dark) 55%,var(--teal));color:#fff;padding:56px;display:flex;flex-direction:column;justify-content:space-between;position:relative;overflow:hidden}
.auth-side:after{content:"";position:absolute;width:480px;height:480px;border-radius:50%;background:rgba(255,255,255,.08);right:-160px;bottom:-160px}
.auth-side h2{font-size:38px;line-height:1.15;letter-spacing:-.5px} .auth-side p{opacity:.88;max-width:420px;margin-top:14px}
.auth-side ul{list-style:none;margin-top:26px;display:grid;gap:12px} .auth-side li:before{content:"✓";margin-right:10px;background:rgba(255,255,255,.18);border-radius:50%;padding:2px 7px;font-size:12px}
.auth-main{display:flex;align-items:center;justify-content:center;padding:40px 24px}
.auth-card{width:100%;max-width:460px;background:var(--card);border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow);padding:36px}
.auth-card h1{font-size:28px;letter-spacing:-.5px} .auth-card .sub{color:var(--muted);margin:6px 0 24px;font-size:15px}
.form-group{margin-bottom:16px} label{display:block;font-weight:600;font-size:14px;margin-bottom:7px}
.input-wrap{position:relative}
input,select{width:100%;padding:12px 14px;border:1.5px solid var(--line);border-radius:11px;font-size:15px;font-family:inherit;background:#FFFEFB;transition:.15s}
input:focus,select:focus{outline:none;border-color:var(--teal);box-shadow:0 0 0 4px rgba(15,118,110,.12);background:#fff}
.toggle-pass{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:none;color:var(--teal);font-weight:700;font-size:13px;cursor:pointer}
.error-text{color:var(--danger);font-size:13px;margin-top:5px}
.alert{padding:13px 16px;border-radius:11px;margin-bottom:18px;font-size:14px;font-weight:600;transition:opacity .4s}
.alert-success{background:#DCFCE7;color:#166534;border:1px solid #86EFAC}
.alert-error{background:#FEE2E2;color:#991B1B;border:1px solid #FCA5A5}
.auth-foot{text-align:center;margin-top:20px;color:var(--muted);font-size:14px}
.demo-box{background:var(--teal-soft);border-radius:11px;padding:13px 15px;font-size:13px;margin-top:18px;color:var(--teal-dark)}
/* Dashboard layout */
.layout{display:flex;min-height:100vh}
.sidebar{width:272px;background:linear-gradient(180deg,#0a1f44,#122c55);color:#D9E8E4;padding:24px 18px;display:flex;flex-direction:column;gap:20px;position:fixed;inset:0 auto 0 0;z-index:50;height:100dvh;overflow:hidden}
.sidebar .brand{color:#fff;font-size:21px;font-weight:700;display:flex;align-items:center;gap:10px;text-decoration:none}
.brand-icon{width:38px;height:38px;border-radius:11px;background:linear-gradient(135deg,#2f7dff,var(--teal));display:grid;place-items:center;color:#fff;font-weight:800}
.side-user{display:flex;gap:12px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);padding:14px;border-radius:14px;align-items:flex-start}
.side-user strong{color:#fff;display:block;font-size:15px;line-height:1.3} .side-user small{display:block;opacity:.75;font-size:12px;word-break:break-all;margin:2px 0 7px}
.avatar{width:46px;height:46px;border-radius:50%;background:linear-gradient(135deg,var(--amber),#F97316);color:#fff;display:grid;place-items:center;font-weight:800;flex-shrink:0}
.sidebar .brand,.side-user{flex:0 0 auto}
.side-nav{display:grid;gap:6px;flex:1 1 auto;min-height:0;overflow-y:auto;align-content:start;padding-right:2px;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.28) transparent} .side-nav a{color:#C7DDD9;padding:11px 13px;border-radius:10px;font-weight:600;font-size:15px;text-decoration:none}
.side-nav::-webkit-scrollbar{width:6px} .side-nav::-webkit-scrollbar-thumb{background:rgba(255,255,255,.28);border-radius:3px}
.side-nav a:hover{background:rgba(255,255,255,.07);color:#fff;text-decoration:none} .side-nav a.active{background:var(--teal);color:#fff}
.side-nav .logout-link{color:#FCA5A5} .side-foot{flex:0 0 auto;font-size:12px;opacity:.55}
.main{flex:1;margin-left:272px;padding:34px;max-width:calc(100vw - 272px)}
.topbar{display:none}
.page-head{margin-bottom:24px} .page-head h1{font-size:30px;letter-spacing:-.6px} .page-head p{color:var(--muted)}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:18px;margin-bottom:26px}
.stat-card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:22px;box-shadow:var(--shadow)}
.stat-card small{color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.05em;font-size:12px}
.stat-card .num{font-size:36px;font-weight:800;letter-spacing:-1px;margin-top:4px}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:26px;margin-bottom:22px}
.card h2{font-size:20px;margin-bottom:14px}
table{width:100%;border-collapse:collapse;font-size:14.5px} th{text-align:left;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.05em;padding:10px;border-bottom:2px solid var(--line)}
td{padding:12px 10px;border-bottom:1px solid var(--line);vertical-align:middle} tr:hover td{background:#FBFAF7}
.badge{display:inline-block;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:700}
.badge-admin{background:#FEE2E2;color:#991B1B} .badge-manager{background:#FEF3C7;color:#92400E} .badge-user{background:var(--teal-soft);color:var(--teal-dark)}
.badge-active{background:#DCFCE7;color:#166534} .badge-inactive{background:#E5E7EB;color:#374151}
.table-wrap{overflow-x:auto} .actions{display:flex;gap:8px;flex-wrap:wrap}
.search-bar{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px} .search-bar input,.search-bar select{width:auto;flex:1;min-width:170px}
.profile-grid{display:grid;grid-template-columns:320px 1fr;gap:22px;align-items:start}
.profile-card{text-align:center} .profile-card .avatar{width:88px;height:88px;font-size:32px;margin:0 auto 12px}
.kv{display:grid;grid-template-columns:170px 1fr;gap:10px 16px;font-size:15px} .kv dt{color:var(--muted);font-weight:600} .kv dd{font-weight:600}
footer.site{text-align:center;color:var(--muted);font-size:13px;padding:26px}
@media(max-width:900px){
  .hero-inner{grid-template-columns:1fr} .hero h1{font-size:38px}
  .auth-wrap{grid-template-columns:1fr} .auth-side{display:none}
  .sidebar{transform:translateX(-100%);transition:.25s} .sidebar.open{transform:none;box-shadow:0 0 60px rgba(0,0,0,.35)}
  /* maker v0066: .layout must stack on phones too. The base rule
     (.layout{display:flex}) put .topbar and .main side by side in a
     row, so on every logged-in page the top bar became a side column
     that pushed or squeezed .main off-screen (the >=901px block has
     always set display:block; this block never did). The topbar
     title (the full folio on order-detail pages) also gets an
     ellipsis so it can never force the bar wider than the screen. */
  .layout{display:block}
  .main{margin-left:0;max-width:100%;padding:20px}
  .topbar{display:flex;align-items:center;gap:12px;background:var(--card);border-bottom:1px solid var(--line);padding:13px 18px;position:sticky;top:0;z-index:40}
  .topbar>*{min-width:0}
  .topbar strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:calc(100vw - 170px)}
  .menu-btn{background:var(--teal-soft);border:none;width:40px;height:40px;border-radius:10px;font-size:19px;cursor:pointer;color:var(--teal-dark)}
  .top-role{margin-left:auto} .profile-grid{grid-template-columns:1fr} .kv{grid-template-columns:120px 1fr}
  /* maker v0066, residual fixes found by the strict <=390px
     re-measurement and approved by Oscar as part of v0066:
     (1) on order-detail pages the page's own heading repeats the
     full folio as one unbreakable word (~462px in a 350px box) -
     let it wrap anywhere so it cannot widen the document.
     (2) .profile-grid's 1fr track is minmax(auto,1fr): the .kv
     list's min-content (120px label + unbreakable email) blew the
     track out to ~391px - floor the track at 0 instead. This rule
     intentionally comes after the 1fr rule above so it wins. */
  .page-head h1{overflow-wrap:anywhere}
  .profile-grid{grid-template-columns:minmax(0,1fr)}
}

/* ===== maker v0052: tool layout (tools/keychain.php, tools/button.php) =====
   Oscar's direction: on tool pages the side menu is MINIMIZED and
   the tool gets the full container width. Non-tool pages do not
   carry the tool-layout body class and render exactly as in v0051.

   1) Brand on one compact line. In v0051 the top bar's brand was a
      plain inline link inside a wrapping flex row: when the nav
      buttons took the first row, "oscarrdz.com" wrapped under
      "M Maker" as a second, larger line and pushed the nav into
      two rows. The brand is now a non-wrapping inline-flex unit. */
.navbar .logo{display:inline-flex;align-items:center;white-space:nowrap;flex:0 0 auto;text-decoration:none}
.navbar .logo .logo-icon{flex:0 0 auto}
.navbar .logo .logo-name{white-space:nowrap}

/* 2) Tool pages: the container spans the full viewport width -
   no 1280px cap on the top bar or on <main class="tool-main">. */
body.tool-layout .navbar{max-width:none;margin:0}
body.tool-layout .tool-main{width:100%;max-width:none;margin:0;padding:10px 18px 70px}

/* 3) THE FIX for the squeezed designer. The keychain designer
   fragment (tools/keychain/designer.inc.html, engine
   3dkeychainv0044) still carries the CSS grid of the old
   standalone app: .app-shell{grid-template-columns:228px
   minmax(0,1fr)} at min-width:920px - a 228px column for its side
   menu plus one content column. The maker extraction removed the
   fragment's own sidebar element but kept the grid, so the only
   remaining child, .app-main, is auto-placed into the FIRST
   column and the whole designer renders 228px wide, its text
   clipped by .app-main{overflow-x:clip}. These scoped overrides
   (specificity 0-2-1 beats the fragment's 0-1-0, media query
   included) collapse the shell to a single full-width column on
   tool pages only; the fragment itself is not edited. */
body.tool-layout .tool-main .app-shell{grid-template-columns:minmax(0,1fr);max-width:none}
body.tool-layout .tool-main .app-main{grid-column:1/-1;min-width:0}
/* The fragment's own .wrap cap (1180px) and the button tool's
   .wrap cap (80rem) were sized for the old narrow container;
   on tool pages they may use the wider tool width. */
body.tool-layout .tool-main .wrap{max-width:1440px}

/* 4) Minimized side menu: a 60px icon rail (includes/toolrail.php),
   signed-in users on tool pages only. The page shifts right by
   the rail's width; below 900px the rail hides and the top bar
   alone carries the navigation, as on mobile before. */
.toolrail{position:fixed;inset:0 auto 0 0;width:60px;z-index:60;background:linear-gradient(180deg,#0a1f44,#122c55);display:flex;flex-direction:column;align-items:center;gap:6px;padding:12px 0;overflow-y:auto}
.toolrail .rail-brand{width:40px;height:40px;border-radius:11px;background:linear-gradient(135deg,#2f7dff,var(--teal));color:#fff;font-weight:800;font-size:19px;display:grid;place-items:center;text-decoration:none;margin-bottom:8px;flex:0 0 auto}
.toolrail .rail-link{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;color:#C7DDD9;font-size:19px;text-decoration:none;flex:0 0 auto}
.toolrail .rail-link:hover{background:rgba(255,255,255,.08);color:#fff;text-decoration:none}
.toolrail .rail-link.active{background:var(--teal);color:#fff}
.toolrail .rail-logout{color:#FCA5A5;margin-top:auto}
body.tool-layout.has-toolrail{padding-left:60px}
@media(max-width:900px){
  .toolrail{display:none}
  body.tool-layout.has-toolrail{padding-left:0}
}

/* ===== maker v0052: hamburger button - show/hide the side menu =====
   Oscar's direction: a visible burger button in the header area
   toggles the side menu, and the content reflows into the freed
   width. The wiring lives in assets/js/app.js ([data-navburger]);
   the choice is remembered for the session (sessionStorage).

   A) Sidebar-layout pages (dashboard, My Orders, admin, account):
      the existing .topbar - which before v0052 only appeared on
      mobile - is now a slim header bar on desktop too, carrying
      the burger, the page title and the role badge. Toggling adds
      body.nav-collapsed: the sidebar slides out and .main/.topbar
      take the full width. On mobile nothing changes: the burger
      keeps the old slide-over sidebar (.sidebar.open). */
.nav-burger,.menu-btn{cursor:pointer}
.nav-burger{background:var(--teal-soft);border:none;width:40px;height:40px;border-radius:10px;font-size:19px;color:var(--teal-dark);flex:0 0 auto;display:grid;place-items:center}
.nav-burger:hover{background:#d7e6ff}
@media(min-width:901px){
  .layout{display:block}
  .topbar{display:flex;align-items:center;gap:12px;background:var(--card);border-bottom:1px solid var(--line);padding:13px 18px;position:sticky;top:0;z-index:40;margin-left:272px;transition:margin .25s ease}
  .topbar .menu-btn{background:var(--teal-soft);border:none;width:40px;height:40px;border-radius:10px;font-size:19px;color:var(--teal-dark)}
  .topbar .top-role{margin-left:auto}
  .sidebar{transition:transform .25s ease}
  .main{transition:margin .25s ease,max-width .25s ease}
  body.nav-collapsed .sidebar{transform:translateX(-105%)}
  body.nav-collapsed .main{margin-left:0;max-width:100%}
  body.nav-collapsed .topbar{margin-left:0}
}

/* B) Tool pages: the burger in the top bar expands the FULL
   sidebar over the minimized rail (body.nav-expanded) and
   collapses it back to the rail. The sidebar starts hidden on
   tool pages - minimized is the tool-layout default. */
body.tool-layout .sidebar{transform:translateX(-105%);transition:transform .25s ease}
body.tool-layout.nav-expanded .sidebar{transform:none;box-shadow:0 0 60px rgba(0,0,0,.35)}
body.tool-layout.nav-expanded .toolrail{display:none}
body.tool-layout.nav-expanded{padding-left:272px}
@media(max-width:900px){
  body.tool-layout.nav-expanded{padding-left:0}
}

/* ===== maker v0053: ONE footer; cache-busted assets =====
   Part A (cache): header.php / footer.php now load this file
   and app.js with ?v=<APP_VERSION>, because the host serves
   static files with Cache-Control: max-age=604800 - with the
   unversioned v0051/v0052 URL, browsers kept the OLD release's
   CSS/JS for days while the (no-store) HTML was already new,
   which is what broke the v0052 layout live. No rule in this
   section fixes that; the versioned URL does. See README.

   Part B (footer unification, Oscar's spec 2026-11-26): the
   tool fragments carry their OWN <footer> inside the tool
   (the keychain designer's .app-footer with "Designer
   version: 0044", the button tool's closing line). Inside
   maker there is exactly ONE footer - includes/footer.php,
   at the very bottom of the page - so any footer inside the
   tool container is suppressed here, at the maker-chrome
   level; the engine fragments are not edited. Specificity
   0-2-2 beats the fragments' footer rules (0-0-1 / 0-1-0).
   The maker footer itself is NOT inside .tool-main, so it
   is never matched by this rule. */
body.tool-layout .tool-main footer{display:none}

/* The unified footer's three lines (includes/footer.php):
   Oscar's phrase, the designer engine version, and the maker
   line whose text is admin-configurable (admin/settings.php). */
footer.site .foot-phrase{max-width:900px;margin:0 auto 6px;color:var(--ink);font-size:14px}
footer.site .foot-ver{margin-bottom:2px}
footer.site .foot-ver{font-weight:600}
footer.site .foot-maker{color:var(--muted)}

/* ===== maker v0065: the public navbar fits phones =====
   Oscar's iPhone 14 screenshot (2026-11-27, 390px
   Chrome): the landing top bar never adapted. .navbar
   was one non-wrapping flex row, the logo is nowrap
   (v0052) and the account buttons are full-size .btn,
   so at phone width the buttons squeezed into tall
   narrow columns, "Create Account" ran off the right
   edge, and the overflow widened the whole layout -
   the hero text and role cards rendered ~60% wide
   with dead space at the right. The max-width:900px
   block above only collapses the hero grid and the
   dashboard sidebar; the public navbar (index.php,
   help.php, includes/topnav.php) had NO small-screen
   rules at all. His selling is face-to-face on phones
   and tablets, so this bar is the storefront.
   Fix, small screens only: the bar wraps - logo on
   its own line, the button group on the next line,
   wrapping internally - the buttons go compact with
   one-line labels (white-space:nowrap; they wrap to
   the next line instead of squeezing into columns),
   and the logo shrinks one step. Desktop (>900px)
   renders exactly as in v0064, and the v0052
   tool-layout rules above are untouched: the tool
   top bar's <nav> already wrapped, it just inherits
   the same compact buttons. */
@media(max-width:900px){
  .navbar{flex-wrap:wrap;gap:12px;padding:18px 5vw}
  .navbar .logo{font-size:21px}
  .navbar .logo .logo-icon{width:34px;height:34px;border-radius:10px}
  .navbar>div:not(.logo){flex-wrap:wrap;gap:8px;max-width:100%}
  .navbar .btn{padding:9px 15px;font-size:14px;white-space:nowrap}
}
@media(max-width:480px){
  .navbar{padding:14px 16px;gap:10px}
  .navbar .logo{font-size:19px}
  .navbar .btn{padding:8px 12px;font-size:13px}
}

/* ===== maker v0067: ONE unified shell (Oscar, 2026-11-28) =====
   Oscar's screenshots: on the CRUD pages the full sidebar's
   bottom items (Manage Users ... Change Password, Sign out)
   were cut off at normal zoom - he had to zoom OUT to reach
   them; on the tool pages the icon rail's "My Orders" link
   used the burger glyph (&#9776;), so it looked like a menu
   button, and the real burger sits in the top bar, which
   scrolls away on tool pages.
   Decision (Oscar): unify on the CRUD shell - one sidebar,
   one CSS, one behaviour for Maker + Designer; no new theme.
   What changed here and in includes/sidebar-aside.php /
   includes/toolrail.php:
   1) The sidebar is a fixed-height flex column (100dvh,
      overflow hidden, in the base .sidebar rule above): the
      brand and the user card stay pinned at the top, the
      version foot stays pinned at the bottom, and ONLY the
      nav list scrolls (flex:1 + min-height:0 + overflow-y:
      auto in .side-nav above). Every item is reachable at
      any viewport height and at 100/125/150% zoom, on CRUD
      pages and on the expanded tool-page sidebar alike -
      they are the same <aside> element.
   2) The tool rail gets a REAL burger toggle as its first
      button (data-navburger, wired by the existing app.js),
      so expanding the full menu never depends on the top
      bar being on screen. Its style is the rail-link style
      as a <button>: */
.toolrail .rail-toggle{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;color:#fff;background:rgba(255,255,255,.10);font-size:19px;border:none;cursor:pointer;flex:0 0 auto}
.toolrail .rail-toggle:hover{background:rgba(255,255,255,.20)}
