/* The signed-in areas: customer account and staff admin. Same tokens as the
   public site, plainer and denser. Components here are shared by both. */

body.app { background: var(--paper); }

/* ------------------------------------------------------------ top bar */
.app-bar { background: var(--ink); color: #e8ecf8; position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 8px 24px -12px rgba(0,0,0,.5); }
.app-bar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--grad); opacity: .85; }
.app-bar-in { max-width: 1480px; margin: 0 auto; padding: 0 var(--gutter); min-height: 60px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.app-bar .wordmark { color: #fff; }
.app-bar .brand { padding: 12px 0; }
.area-tag { margin-left: 4px; font: 600 11px/1 var(--font); letter-spacing: .1em; text-transform: uppercase; color: #b9c5ee; border: 1px solid rgba(255,255,255,.22); padding: 4px 7px; border-radius: 6px; }
.app-nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.app-nav a { color: #c6cfea; text-decoration: none; padding: 9px 13px; border-radius: 9px; font-weight: 600; font-size: 15px; display: inline-flex; gap: 8px; align-items: center; }
.app-nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.app-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.12); }
.count { background: var(--grad); color: #fff; font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; }
.app-who { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: 14px; }
.who-name { color: #aeb9dc; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-link { color: #c6cfea; }
.app-bar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.28); }
.app-bar .btn-ghost:hover { border-color: #fff; color: #fff; }

.app-main { max-width: 1320px; margin: 0 auto; padding: 32px var(--gutter) 72px; }
.app-main.wide { max-width: 1480px; }

/* --------------------------------------------------------- page pieces */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(28px, 4vw, 38px); }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 18px; }
.card > h2, .card-head h2 { font-size: 20px; margin-bottom: 4px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > .card-head { padding: 18px 22px 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat .k { font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .v { font: 650 30px/1.1 var(--font-display); letter-spacing: -.03em; margin-top: 6px; }
.stat .s { color: var(--muted); font-size: 14px; margin-top: 4px; }
.stat.good .v { color: var(--green); }
.stat.warn { border-color: #efc27a; background: #fffaf0; }
.stat.warn .v { color: var(--amber); }

.needs { display: grid; gap: 10px; margin-bottom: 20px; }
.need { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--amber); text-decoration: none; color: inherit; }
.need:hover { border-color: var(--cobalt); border-left-color: var(--amber); }
.need b { font: 700 24px/1 var(--font-display); min-width: 34px; }
.need span { color: var(--muted); font-size: 14.5px; }
.need .go { margin-left: auto; font-weight: 600; color: var(--blue); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 19px; margin-bottom: 6px; }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--line); background: #f8f9fd; white-space: nowrap; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid #edf0f7; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl a.row-link { font-weight: 600; text-decoration: none; }
.tbl a.row-link:hover { text-decoration: underline; }
.tbl .sub { display: block; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { width: auto; }
.tabs { display: inline-flex; background: #e9edf7; padding: 4px; border-radius: 11px; gap: 2px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="true"] { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------- licence cards */
.seat { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: start; }
.seat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seat-head h3 { font-size: 18px; }
.seat .ref { font: 500 13px var(--mono); color: var(--muted); }
.keybox { display: flex; gap: 10px; align-items: stretch; margin-top: 12px; }
.keybox code { flex: 1; min-width: 0; background: var(--ink); color: #cfe0ff; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-all; }
.mid { font: 500 15px var(--mono); letter-spacing: .02em; background: #eef2fc; padding: 4px 8px; border-radius: 7px; white-space: nowrap; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 8px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1; min-width: 220px; }

/* ---------------------------------------------------------- ticket thread */
.thread { display: grid; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 16px 18px; max-width: 820px; }
.msg.staff { background: #f3f6ff; border-color: #cfdcff; margin-left: auto; }
.msg.note { background: #fff8e6; border-color: #f0d792; border-style: dashed; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.msg-head b { color: var(--text); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
details.diag { margin-top: 10px; }
details.diag summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--blue); }
details.diag pre { max-height: 320px; overflow: auto; background: var(--ink); color: #cfe0ff; padding: 12px; border-radius: 10px; font-size: 12.5px; white-space: pre-wrap; }

/* ----------------------------------------------------- centred card pages */
body.app-card { display: grid; min-height: 100vh; background: radial-gradient(900px 500px at 50% -10%, #dfe7ff 0%, transparent 60%), var(--paper); }
.card-page { width: min(440px, calc(100vw - 32px)); margin: 0 auto; padding: 48px 0; align-self: center; }
.card-page.wide { width: min(560px, calc(100vw - 32px)); }
.card-brand { margin-bottom: 22px; }
.card-page .card { padding: 28px; }
.card-page h1 { font-size: 28px; margin-bottom: 8px; }
.card-page .lead { color: var(--muted); margin-bottom: 20px; }
.card-foot { text-align: center; font-size: 14px; margin-top: 18px; }
.links-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14.5px; }

.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

@media (max-width: 720px) {
  .app-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 8px; }
  .app-who { gap: 8px; }
  .who-name { display: none; }
  .seat { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}

/* a reply box sits below the conversation, not against it */
.thread + .card, .thread + .flash, .thread + form { margin-top: 18px; }

/* ---- the side menu (a fixed column on a computer, a slide-out drawer on a phone) */
.admin-frame { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.admin-col { min-width: 0; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 20px 14px 16px; background: var(--ink); color: #c6cfea; scrollbar-width: thin; }
.side::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 2px; background: var(--grad); opacity: .8; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 2px 10px 18px; }
.side .wordmark, .m-bar .wordmark { color: #fff; }
.side-group { display: grid; gap: 2px; padding: 14px 0 6px; }
.side-group + .side-group { border-top: 1px solid rgba(255, 255, 255, .08); }
.side-title { margin: 0 0 6px; padding: 0 12px; font: 600 11px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: #8b99c4; }
.side-group a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #c6cfea; text-decoration: none; font-weight: 600; font-size: 15px; }
.side-group a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.side-group a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .13); }
.side-group a[aria-current="page"] .side-ico { color: #8fb0ff; }
.side-ico { flex: none; opacity: .92; }
.side .count { margin-left: auto; }
.side-foot { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid rgba(255, 255, 255, .1); display: grid; gap: 10px; }
.side-who { font-size: 13px; color: #aeb9dc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-site { color: #c6cfea; font-size: 14px; }
.side .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .28); }
.side .btn-ghost:hover { border-color: #fff; color: #fff; }
.m-bar, .side-backdrop { display: none; }
.side-toggle { width: 42px; height: 42px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .28); background: transparent; display: grid; place-content: center; gap: 5px; cursor: pointer; }
.side-toggle span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; }
@media (max-width: 960px) {
  .admin-frame { display: block; }
  .m-bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; min-height: 58px; padding: 0 var(--gutter); background: var(--ink); box-shadow: 0 8px 24px -14px rgba(0, 0, 0, .6); }
  .m-bar .brand { padding: 10px 0; }
  .side { position: fixed; z-index: 50; top: 0; left: 0; width: min(300px, 86vw); height: 100vh; height: 100dvh; visibility: hidden; transform: translateX(-102%); transition: transform .22s ease, visibility 0s .22s; }
  body.side-open .side { visibility: visible; transform: none; transition-delay: 0s; box-shadow: 24px 0 60px rgba(0, 0, 0, .45); }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 30, .55); }
  body.side-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

