/* Rikerworks design system. Plain CSS, no build step, no external resources (strict CSP).
   Rules enforced by tests/Feature/DesignRulesTest: sharp corners, no gradients, no shadows,
   no animation, WCAG AA contrast for every listed colour pair. */

:root {
  --c-ink: #141414;
  --c-paper: #f3f3f1;
  --c-white: #ffffff;
  --c-char-950: #0e0e0e;
  --c-char-900: #181818;
  --c-char-800: #222222;
  --c-char-700: #2e2e2e;
  --c-char-600: #383838;
  --c-grey-600: #4d4d4d;
  --c-grey-500: #5c5c5c;
  --c-line: #cfcfcb;
  --c-on-dark: #f2f2f0;
  --c-on-dark-muted: #b9b9b5;
  --c-amber: #f2b705;
  --c-danger: #a3151a;
  --c-danger-bg: #fbeaea;
  --c-success: #1d6b3a;
  --c-success-bg: #e6f3ea;
  --c-warn-ink: #4d3900;
  --c-warn-bg: #fff3c4;
  --c-focus: #111111;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 1rem/1.55 var(--font); color: var(--c-ink); background: var(--c-paper); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .75rem; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1rem; }
a { color: var(--c-ink); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--c-line); margin: 1.5rem 0; }
.muted { color: var(--c-grey-500); }
.small { font-size: .875rem; }

:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.on-dark :focus-visible, .sidebar :focus-visible, .auth__brand :focus-visible { outline-color: var(--c-white); }

.skip { position: absolute; left: .5rem; top: -4rem; background: var(--c-white); color: var(--c-ink); padding: .75rem 1rem; border: 2px solid var(--c-ink); z-index: 10; }
.skip:focus { top: .5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Logo: the supplied mark. Light surface = original colours; dark surface = inverted. */
.logo { display: block; width: 4.5rem; height: auto; }
.logo__a { fill: #141414; }
.logo__b { fill: #383838; }
.logo__c { fill: #ffffff; }
.logo--dark .logo__a { fill: #f2f2f0; }
.logo--dark .logo__b { fill: #8c8c8c; }
.logo--dark .logo__c { fill: var(--c-char-900); }
.wordmark { font-weight: 800; letter-spacing: .22em; text-transform: uppercase; font-size: 1rem; }
.brand { display: flex; align-items: center; gap: 1.1rem; color: inherit; text-decoration: none; }

/* Checkbox groups (permissions, roles) */
fieldset.checks { border: 1px solid var(--c-line); margin: 0 0 1rem; padding: .75rem 1rem 1rem; background: var(--c-white); min-width: 0; }
fieldset.checks legend { font-weight: 700; padding: 0 .4rem; }
.check { display: flex; align-items: flex-start; gap: .75rem; min-height: 2.25rem; padding: .25rem 0; }
.check label { flex: 1; font-weight: 400; padding-top: .1rem; }
input[type="checkbox"] { width: 1.5rem; height: 1.5rem; margin: .1rem 0 0; flex: none; accent-color: var(--c-char-900); }
input[type="checkbox"]:disabled + label { color: var(--c-grey-500); }
.hint { color: var(--c-grey-500); font-size: .875rem; font-weight: 400; }

/* Forms */
.form { display: grid; gap: 1.1rem; }
.form + p, form + p { margin-top: 1.25rem; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; }
.field .hint { color: var(--c-grey-500); font-size: .875rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; min-height: 2.75rem; padding: .6rem .75rem; font: inherit; color: var(--c-ink);
  background: var(--c-white); border: 1px solid var(--c-grey-500); border-radius: 0;
}
input[aria-invalid="true"] { border: 2px solid var(--c-danger); }
.error { color: var(--c-danger); font-weight: 600; font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .6rem 1.25rem; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--c-char-900); color: var(--c-white); border: 2px solid var(--c-char-900); border-radius: 0; text-decoration: none; }
.btn:hover { background: var(--c-char-700); border-color: var(--c-char-700); }
.btn--secondary { background: var(--c-white); color: var(--c-ink); border-color: var(--c-ink); }
.btn--secondary:hover { background: var(--c-paper); border-color: var(--c-ink); }
.btn--danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn--danger:hover { background: #7e1014; border-color: #7e1014; }
.btn--block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

.alert { padding: .85rem 1rem; border: 1px solid var(--c-line); border-left-width: 6px; background: var(--c-white); margin: 0 0 1.25rem; }
.alert--error { border-color: var(--c-danger); background: var(--c-danger-bg); color: var(--c-ink); }
.alert--success { border-color: var(--c-success); background: var(--c-success-bg); }
.alert--warning { border-color: var(--c-warn-ink); background: var(--c-warn-bg); color: var(--c-warn-ink); }
.alert strong { display: block; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(18rem, 5fr) 7fr; }
.auth__brand { background: var(--c-char-900); color: var(--c-on-dark); padding: 2.5rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; border-right: 6px solid var(--c-char-600); }
.auth__brand .logo { width: 7.5rem; }
.auth__brand p { color: var(--c-on-dark-muted); max-width: 22rem; margin: 0; }
.auth__brand .tag { border-top: 1px solid var(--c-char-600); padding-top: 1rem; font-size: .875rem; }
.auth__panel { padding: 3rem 1.5rem; display: flex; align-items: center; justify-content: center; }
.auth__box { width: 100%; max-width: 26rem; }
.auth__box h1 { margin-bottom: 1.5rem; }

/* App shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 15.5rem 1fr; }
.sidebar { background: var(--c-char-900); color: var(--c-on-dark); padding: 1.5rem 0; display: flex; flex-direction: column; border-right: 1px solid var(--c-char-950); }
.sidebar .brand { padding: 0 1.25rem 1.5rem; }
.sidebar .logo { width: 3rem; }
.sidebar nav { flex: 1; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a.nav { display: block; padding: .8rem 1.25rem; color: var(--c-on-dark-muted); text-decoration: none; border-left: 4px solid transparent; font-weight: 600; }
.sidebar a.nav:hover { background: var(--c-char-700); color: var(--c-white); }
.sidebar a.nav[aria-current="page"] { color: var(--c-white); background: var(--c-char-800); border-left-color: var(--c-white); }
.sidebar .who { padding: 1rem 1.25rem 0; border-top: 1px solid var(--c-char-600); font-size: .875rem; color: var(--c-on-dark-muted); }
.sidebar .who strong { color: var(--c-white); display: block; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 2rem; background: var(--c-white); border-bottom: 1px solid var(--c-line); }
.content { padding: 2rem; max-width: 70rem; width: 100%; }
.pagehead { margin-bottom: 1.5rem; }

.card { background: var(--c-white); border: 1px solid var(--c-line); padding: 1.5rem; margin-bottom: 1.5rem; }
.grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
.kv dt { color: var(--c-grey-500); font-weight: 600; }
.kv dd { margin: 0; }
.badge { display: inline-block; padding: .1rem .55rem; border: 1px solid var(--c-ink); font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--c-white); }
.badge--ok { border-color: var(--c-success); color: var(--c-success); }
.badge--bad { border-color: var(--c-danger); color: var(--c-danger); }

table { width: 100%; border-collapse: collapse; background: var(--c-white); }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--c-line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-grey-600); background: var(--c-paper); border-bottom: 2px solid var(--c-char-600); }
tbody th { text-transform: none; letter-spacing: normal; font-size: 1rem; color: var(--c-ink); background: transparent; border-bottom: 1px solid var(--c-line); font-weight: 700; }
.table-wrap { overflow-x: auto; border: 1px solid var(--c-line); }

.qr { display: inline-block; padding: 1rem; background: var(--c-white); border: 1px solid var(--c-ink); }
.qr svg { display: block; width: 12rem; height: 12rem; }
.codes { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem; font-family: var(--mono); }
.codes li { padding: .4rem .6rem; border: 1px solid var(--c-line); background: var(--c-paper); }
.secret { font-family: var(--mono); word-break: break-all; padding: .5rem .75rem; background: var(--c-paper); border: 1px solid var(--c-line); }

/* Platform console: visibly different, so nobody mistakes it for a tenant screen. */
.shell--platform .sidebar { background: var(--c-char-950); border-top: 6px solid var(--c-amber); }
.platform-flag { display: block; width: max-content; margin-bottom: 1rem; background: var(--c-amber); color: var(--c-ink); font-weight: 800; letter-spacing: .12em; padding: .15rem .6rem; font-size: .75rem; text-transform: uppercase; margin-top: .5rem; }
.auth--platform .auth__brand { border-top: 6px solid var(--c-amber); }

@media (max-width: 52rem) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
  .auth__brand { flex-direction: row; align-items: center; justify-content: flex-start; padding: 1.25rem; border-right: 0; border-bottom: 6px solid var(--c-char-600); }
  .auth__brand p, .auth__brand .tag { display: none; }
  .auth__brand .logo { width: 3.5rem; }
  .auth__panel { padding: 2rem 1rem; align-items: flex-start; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 1rem 0; }
  .sidebar nav ul { display: flex; flex-wrap: wrap; }
  .sidebar .who { display: none; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* Document library */
.filters { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); align-items: end; }
.filters .field--wide { grid-column: 1 / -1; }
.filters .actions { grid-column: 1 / -1; }
.block { display: block; }
.snippet { color: var(--c-grey-600); font-weight: 400; margin-top: .25rem; }
mark { background: var(--c-amber); color: var(--c-ink); padding: 0 .1rem; }
.pager { display: flex; gap: .75rem; margin-top: 1rem; }
.preview { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .9rem; max-height: 40rem; overflow: auto; margin: 0; padding: 1rem; background: var(--c-paper); border: 1px solid var(--c-line); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.inline { display: inline; }
.stack { display: grid; gap: .4rem; margin-top: .5rem; min-width: 14rem; }
td .btn { margin-top: .25rem; }
input[type="file"], input[type="date"] { font: inherit; padding: .5rem; border: 1px solid var(--c-ink); background: var(--c-white); max-width: 100%; }
.share-form { margin-top: 1.5rem; max-width: 32rem; }
