/* Client Hub */

@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-extrabold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --graphite: #151719;
  --ivory: #f3f0e8;
  --paper: #f8f6ef;
  --steel: #4f545a;
  --line: rgb(21 23 25 / 0.18);
  --line-strong: rgb(21 23 25 / 0.68);
  --orange: #f05a28;
  --error: #a62919;
  --font-sans: Aptos, "Segoe UI", Arial, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue Condensed", Impact, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;

  --gloss-specular: rgb(255 255 255 / 0.55);
  --gloss-sheen: linear-gradient(180deg, rgb(255 255 255 / 0.22) 0%, rgb(255 255 255 / 0.04) 42%, rgb(255 255 255 / 0) 100%);
  --gloss-sheen-dark: linear-gradient(180deg, rgb(255 255 255 / 0.14) 0%, rgb(255 255 255 / 0.02) 45%, rgb(255 255 255 / 0) 100%);
  --shadow-card: 0 1px 2px rgb(21 23 25 / 0.08), 0 8px 24px -12px rgb(21 23 25 / 0.22);
  --shadow-lift: 0 2px 4px rgb(21 23 25 / 0.1), 0 14px 32px -12px rgb(21 23 25 / 0.3);
  --shell-max: 1100px;
  --gutter: 20px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ivory);
  color: var(--graphite);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Portal surface: cooler paper sheen, same tokens */
body[data-surface="portal"] {
  background:
    linear-gradient(180deg, rgb(248 246 239 / 0.5) 0%, rgb(248 246 239 / 0) 320px),
    var(--ivory);
}

::selection {
  background: var(--orange);
  color: var(--ivory);
}

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

a {
  color: inherit;
}

h1, h2, h3, h4, h5, h6,
.page-head h1,
.section-title,
.brand-text,
.stat b,
.stat strong {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  line-height: 0.95;
  margin: 0;
}

/* ---------- Skip link ---------- */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--graphite);
  color: var(--ivory);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  padding: 10px 16px;
  text-decoration: none;
  border-inline-start: 3px solid var(--orange);
}

.skip:focus {
  left: 0;
}

/* ---------- Header (frosted gloss on ivory) ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(243 240 232 / 0.86);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  backdrop-filter: blur(12px) saturate(1.05);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
}

body[data-surface="portal"] .top {
  background: rgb(248 246 239 / 0.84);
}

.top-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--graphite);
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  background: var(--graphite);
  border-inline-start: 3px solid var(--orange);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.14), 0 1px 2px rgb(21 23 25 / 0.25);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px solid var(--ivory);
  opacity: 0.9;
}

.brand-mark-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 0.28) 48%, rgb(255 255 255 / 0.06) 55%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}

.brand:hover .brand-mark-sheen {
  animation: sheen-sweep 0.9s ease-out;
}

.brand-text {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--steel);
  padding: 8px 12px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color 150ms ease, background 150ms ease;
}

.nav a:hover {
  color: var(--graphite);
  background: rgb(248 246 239 / 0.8);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
}

.nav a[aria-current="page"],
.nav a.active {
  color: var(--graphite);
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--gloss-specular), inset 2px 0 0 var(--orange);
}

.nav-user {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
  white-space: nowrap;
}

/* ---------- Layout shell ---------- */

.main {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 40px var(--gutter) 72px;
  min-height: calc(100vh - 200px);
}

.foot {
  border-top: 1px solid var(--line);
  background: var(--paper);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
}

.foot-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 24px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-left: auto;
}

.foot-links a {
  color: var(--steel);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.foot-links a:hover {
  color: var(--graphite);
  border-bottom-color: var(--orange);
}

/* ---------- Page head / type blocks ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line-strong);
}

.page-head h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  letter-spacing: 0.02em;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.lede {
  font-size: 1.05rem;
  color: var(--steel);
  max-width: 62ch;
  margin: 8px 0 0;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
  margin: 0 0 10px;
}

.kicker::before {
  content: "";
  width: 14px;
  height: 3px;
  background: var(--orange);
  display: inline-block;
}

.section-title {
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  margin: 32px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Grids ---------- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

/* ---------- Cards (paper gloss) ---------- */

.card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gloss-specular);
  pointer-events: none;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gloss-sheen);
  opacity: 0.5;
  pointer-events: none;
  border-radius: inherit;
}

.card > * {
  position: relative;
  z-index: 1;
}

.card h2, .card h3 {
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.card p {
  margin: 0 0 12px;
  color: var(--steel);
}

.card p:last-child {
  margin-bottom: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 160ms ease, box-shadow 160ms ease;
  }

  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
  }
}

/* ---------- Stat (display numbers, ink sheen) ---------- */

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat b,
.stat strong {
  font-size: clamp(2.4rem, 8vw, 3.5rem);
  letter-spacing: 0.01em;
  color: var(--graphite);
  background: linear-gradient(180deg, rgb(21 23 25 / 0.95) 0%, #151719 55%, rgb(21 23 25 / 0.82) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat span,
.stat small {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
}

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--graphite);
  border-radius: 2px;
  background: var(--graphite);
  color: var(--ivory);
  padding: 12px 20px 12px 17px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16), 0 1px 2px rgb(21 23 25 / 0.28);
}

.btn::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--orange);
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gloss-sheen-dark);
  pointer-events: none;
}

.btn:hover {
  background: #1d2023;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--paper);
  color: var(--graphite);
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 0 var(--gloss-specular), 0 1px 2px rgb(21 23 25 / 0.1);
}

.btn-secondary::after {
  background: var(--gloss-sheen);
  opacity: 0.4;
}

.btn-secondary:hover {
  background: var(--ivory);
}

.btn-ghost {
  background: transparent;
  color: var(--steel);
  border-color: var(--line);
  box-shadow: none;
}

.btn-ghost::before {
  background: transparent;
}

.btn-ghost::after {
  display: none;
}

.btn-ghost:hover {
  color: var(--graphite);
  border-color: var(--line-strong);
  background: var(--paper);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
}

.btn-ghost:hover::before {
  background: var(--orange);
}

.btn-sm {
  padding: 7px 12px 7px 10px;
  font-size: 0.6875rem;
}

.btn-danger {
  background: var(--error);
  border-color: var(--error);
  color: var(--ivory);
}

.btn-danger::before {
  background: var(--graphite);
}

.btn-danger:hover {
  background: #8f2214;
}

/* ---------- Forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row.inline,
.form-inline {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
}

input,
select,
textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--graphite);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 11px 13px;
  width: 100%;
  box-shadow: inset 0 1px 0 var(--gloss-specular), inset 0 2px 4px rgb(21 23 25 / 0.04);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--steel) 50%), linear-gradient(135deg, var(--steel) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgb(79 84 90 / 0.6);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--graphite);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--graphite);
  box-shadow: inset 0 1px 0 var(--gloss-specular), 0 0 0 2px var(--orange);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 18px;
  accent-color: var(--orange);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--gloss-specular);
}

th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-align: left;
  color: var(--steel);
  background: var(--ivory);
  border-bottom: 1px solid var(--line-strong);
  padding: 10px 14px;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.95rem;
}

tbody tr:hover td {
  background: rgb(243 240 232 / 0.6);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Badges (enamel mono labels) ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  line-height: 1;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  color: var(--graphite);
  box-shadow: inset 0 1px 0 var(--gloss-specular), 0 1px 1px rgb(21 23 25 / 0.1);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--steel);
  flex: 0 0 6px;
}

.badge-ok,
.badge-paid,
.badge-active,
.badge-complete,
.badge-completed {
  border-color: var(--graphite);
  background: var(--graphite);
  color: var(--ivory);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.16);
}

.badge-ok::before,
.badge-paid::before,
.badge-active::before,
.badge-complete::before,
.badge-completed::before {
  background: var(--ivory);
}

.badge-pending,
.badge-draft,
.badge-sent {
  background: var(--ivory);
  color: var(--steel);
}

.badge-pending::before,
.badge-draft::before,
.badge-sent::before {
  background: var(--orange);
}

.badge-error,
.badge-overdue,
.badge-failed,
.badge-cancelled {
  border-color: var(--error);
  color: var(--error);
  background: var(--paper);
}

.badge-error::before,
.badge-overdue::before,
.badge-failed::before,
.badge-cancelled::before {
  background: var(--error);
}

/* ---------- Flash messages ---------- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px 13px 13px;
  margin: 0 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--gloss-specular);
  font-size: 0.95rem;
}

.flash::before {
  content: "";
  width: 3px;
  align-self: stretch;
  background: var(--orange);
  flex: 0 0 3px;
  margin: -13px 0 -13px -13px;
}

.flash-ok {
  background: var(--paper);
  border-color: var(--graphite);
}

.flash-ok::before {
  background: var(--orange);
}

.flash-error {
  border-color: var(--error);
  color: var(--error);
}

.flash-error::before {
  background: var(--error);
}

/* ---------- Empty state ---------- */

.empty {
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  background: var(--paper);
  color: var(--steel);
  box-shadow: inset 0 1px 0 var(--gloss-specular);
}

.empty p {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

/* ---------- Messages thread ---------- */

.msg {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 16px 18px;
  margin: 0 0 12px;
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--gloss-specular);
  max-width: 78ch;
}

.msg p {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-client {
  background: var(--ivory);
  border-inline-start: 3px solid var(--orange);
  margin-left: clamp(0px, 6vw, 48px);
}

.msg-meta {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

/* ---------- Login / hero ---------- */

.login-wrap {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 40px var(--gutter);
}

.hero-panel {
  width: 100%;
  max-width: 460px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 34px 30px 30px;
  box-shadow: var(--shadow-lift), inset 0 1px 0 var(--gloss-specular);
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gloss-sheen);
  opacity: 0.5;
  pointer-events: none;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.hero-panel h1 {
  font-size: 2.4rem;
  margin-bottom: 6px;
  border-inline-start: 4px solid var(--orange);
  padding-inline-start: 14px;
}

.hero-panel .lede {
  margin-bottom: 24px;
}

.dev-link {
  display: block;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--steel);
  text-decoration: none;
  word-break: break-all;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.dev-link:hover {
  color: var(--orange);
}

/* ---------- Utility ---------- */

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.muted {
  color: var(--steel);
}

.small {
  font-size: 0.85rem;
}

.mono {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.link {
  color: var(--graphite);
  text-decoration: underline;
  text-decoration-color: var(--orange);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}

.link:hover {
  color: var(--orange);
  text-decoration-color: var(--orange);
}

/* ---------- Animations ---------- */

@keyframes sheen-sweep {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .brand:hover .brand-mark-sheen {
    animation: none;
  }
}

/* ---------- Mobile 390px first-class ---------- */

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .top-inner {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 4px 14px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .brand-text {
    font-size: 1.15rem;
  }

  .nav {
    width: 100%;
    order: 3;
    margin-left: 0;
    padding-bottom: 2px;
  }

  .nav a {
    padding: 7px 10px;
  }

  .nav-user {
    margin-left: auto;
  }

  .main {
    padding-top: 28px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }

  .card {
    padding: 18px 16px;
  }

  th, td {
    padding: 9px 10px;
    font-size: 0.88rem;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .hero-panel {
    padding: 26px 20px 22px;
  }

  .hero-panel h1 {
    font-size: 2rem;
  }

  .foot-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .foot-links {
    margin-left: 0;
  }
}

@media (max-width: 400px) {
  :root {
    --gutter: 14px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .btn {
    padding: 11px 16px 11px 14px;
  }
}

