/* menhir management UI — "ink & seal" aesthetic.
   Deep charcoal ink, parchment text, a single wax-seal vermilion accent, monospace for serials.
   Display: Fraunces (notary gravitas). Body: Hanken Grotesk. Mono: JetBrains Mono.
   Fonts load from Google Fonts when online; robust fallbacks keep it legible offline. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Hanken+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink:        #11131b;
  --ink-2:      #181b26;
  --ink-3:      #1f2330;
  --line:       #2c3142;
  --parchment:  #ece3d2;
  --muted:      #8b8e9e;
  --seal:       #d6432f;
  --seal-bright:#ec5a44;
  --gold:       #cba85f;
  --green:      #6ec08a;
  --radius:     14px;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 78% -10%, #1b2030 0%, var(--ink) 55%) fixed;
  color: var(--parchment);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* fine film grain for letterpress depth */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--body); cursor: pointer; }
.mono { font-family: var(--mono); font-size: .86em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.truncate { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- auth (login / setup) ---------- */
body.auth { display: grid; place-items: center; padding: 6vh 1rem; }
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.4rem 2rem 2rem; text-align: center;
  box-shadow: 0 30px 80px -40px #000, inset 0 1px 0 #ffffff0a;
  animation: rise .6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.seal { width: 68px; height: 68px; margin: 0 auto .6rem; }
.seal svg { width: 100%; height: 100%; }
.seal-ring { fill: none; stroke: var(--seal); stroke-width: 2; stroke-dasharray: 4 5; opacity: .8; }
.seal-stone { fill: var(--seal); }
.wordmark {
  font-family: var(--display); font-weight: 600; font-size: 2.1rem;
  margin: .1rem 0 .15rem; letter-spacing: .01em;
}
.tagline { color: var(--muted); margin: 0 0 1.5rem; font-size: .9rem; }
.stack { display: grid; gap: 1rem; text-align: left; }
.stack label { display: grid; gap: .35rem; font-size: .82rem; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; }
.stack input {
  background: var(--ink); border: 1px solid var(--line); border-radius: 9px;
  color: var(--parchment); padding: .7rem .8rem; font-size: .95rem; font-family: var(--body);
  transition: border-color .15s, box-shadow .15s;
}
.stack input:focus { outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px #d6432f33; }
.hint { font-size: .72rem; text-transform: none; letter-spacing: 0; }
.stack button, button.ghost {
  background: var(--seal); color: #fff; border: 0; border-radius: 9px;
  padding: .75rem 1rem; font-weight: 600; font-size: .95rem; letter-spacing: .02em;
  transition: background .15s, transform .05s;
}
.stack button:hover { background: var(--seal-bright); }
.stack button:active { transform: translateY(1px); }
.flash { border-radius: 9px; padding: .6rem .8rem; font-size: .85rem; margin: 0 0 1rem; }
.flash.error { background: #d6432f1f; border: 1px solid #d6432f55; color: #f0b3a7; }

/* ---------- app shell ---------- */
body.app { padding: 0; }
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-right: 1px solid var(--line); padding: 1.4rem 1rem; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: .55rem; padding: .2rem .4rem 1.4rem; }
.brand-mark { width: 22px; height: 22px; fill: var(--seal); }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 1.3rem; }
.nav { display: grid; gap: 2px; }
.nav-item {
  padding: .55rem .7rem; border-radius: 8px; color: var(--muted); font-size: .9rem;
  font-weight: 500; transition: background .15s, color .15s; position: relative;
}
.nav-item:hover { background: #ffffff08; color: var(--parchment); }
.nav-item.active { background: #d6432f1a; color: var(--parchment); }
.nav-item.active::before {
  content: ""; position: absolute; left: -1rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--seal); border-radius: 0 3px 3px 0;
}
.nav-item.soon { opacity: .5; }
.nav-item.soon::after { content: "soon"; font-family: var(--mono); font-size: .6rem; color: var(--gold); margin-left: .4rem; vertical-align: middle; }
.sidebar-foot { margin-top: auto; padding: .6rem .4rem 0; font-family: var(--mono); font-size: .68rem; color: var(--muted); opacity: .7; }

.main { padding: 1.8rem 2.2rem 3rem; overflow: auto; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1.8rem; gap: 1rem; }
.page-title { font-family: var(--display); font-weight: 600; font-size: 1.9rem; margin: 0; }
.page-sub { color: var(--muted); margin: .15rem 0 0; font-size: .9rem; }
.who { display: flex; align-items: center; gap: .9rem; }
.who-name { font-family: var(--mono); font-size: .82rem; color: var(--gold); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: .5rem .8rem; border-radius: 8px; font-size: .85rem; }
button.ghost:hover { border-color: var(--seal); color: var(--parchment); }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.8rem; }
.stat {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
  display: grid; gap: .25rem; position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; background: radial-gradient(circle, #d6432f22, transparent 70%); }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-family: var(--display); font-weight: 600; font-size: 2.3rem; line-height: 1; }
.stat-foot { font-size: .74rem; color: var(--muted); }
.accent-gold { color: var(--gold); }
.accent-seal { color: var(--seal-bright); }

/* panel + ledger table */
.panel { background: linear-gradient(180deg, var(--ink-2), var(--ink-3)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; padding: 1.1rem 1.3rem .8rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-family: var(--display); font-weight: 600; font-size: 1.15rem; margin: 0; }
.panel-note { font-family: var(--mono); font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.empty { padding: 2rem 1.3rem; color: var(--muted); }
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .7rem 1.3rem; font-weight: 600; }
.ledger td { padding: .65rem 1.3rem; border-top: 1px solid var(--line); font-size: .88rem; }
.ledger tbody tr:hover { background: #ffffff06; }

/* status pills */
.pill { font-family: var(--mono); font-size: .7rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill-issue, .pill-account-create, .pill-order-create, .pill-admin-login, .pill-admin-create { color: var(--green); border-color: #6ec08a55; background: #6ec08a14; }
.pill-revoke, .pill-order-rejected, .pill-account-rejected, .pill-issue-rejected { color: var(--seal-bright); border-color: #ec5a4455; background: #ec5a4414; }
.pill-challenge-valid { color: var(--gold); border-color: #cba85f55; background: #cba85f14; }

/* filters, row actions, data lists, code blocks */
.filter, .searchform input {
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  color: var(--parchment); padding: .45rem .7rem; font-size: .85rem; font-family: var(--body); min-width: 220px;
}
.filter:focus, .searchform input:focus { outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px #d6432f33; }
.searchform { display: flex; gap: .5rem; }
.row-action { text-align: right; }
button.danger {
  background: transparent; border: 1px solid #ec5a4455; color: var(--seal-bright);
  padding: .35rem .7rem; border-radius: 7px; font-size: .78rem; font-weight: 600;
}
button.danger:hover { background: var(--seal); border-color: var(--seal); color: #fff; }
.datalist { margin: 0; padding: 1.1rem 1.3rem; display: grid; gap: .1rem; }
.datalist > div { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.datalist > div:last-child { border-bottom: 0; }
.datalist dt { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; margin: 0; }
.datalist dd { margin: 0; word-break: break-all; }
.codeblock {
  margin: 0 1.3rem 1.3rem; padding: 1rem 1.1rem; background: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; font-family: var(--mono); font-size: .74rem; color: var(--muted);
  white-space: pre-wrap; word-break: break-all; max-height: 280px; overflow: auto;
}
.pill-deactivated, .pill-pending, .pill-ready { color: var(--muted); border-color: var(--line); background: #ffffff08; }
.pill-policy-edit, .pill-account-deactivate { color: var(--gold); border-color: #cba85f55; background: #cba85f14; }

/* policy edit form */
.formgrid { padding: 1.2rem 1.3rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; }
.formgrid label { display: grid; gap: .35rem; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.formgrid label.check { flex-direction: row; display: flex; align-items: center; gap: .5rem; text-transform: none; letter-spacing: 0; color: var(--parchment); font-size: .9rem; }
.formgrid input[type=text], .formgrid input:not([type]), .formgrid input[type=number] {
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px; color: var(--parchment);
  padding: .55rem .7rem; font-size: .9rem; font-family: var(--body);
}
.formgrid input:focus { outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px #d6432f33; }
.formgrid input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--seal); }
.formactions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.formactions button { background: var(--seal); color: #fff; border: 0; border-radius: 9px; padding: .6rem 1.3rem; font-weight: 600; }
.formactions button:hover { background: var(--seal-bright); }
@media (max-width: 760px) { .formgrid { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .sidebar-foot { display: none; }
}
