/* FCxO Finance. Mobile first: one column, then a sidebar from 50rem. Colours come from
   theme.css as custom properties, so nothing here hardcodes a brand colour. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg, #f4f1ea); color: #16181d;
  font-family: var(--font, system-ui, sans-serif); font-size: 16px; line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-heading, Georgia, serif); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; margin-top: 1.5rem; } h3 { font-size: 1.05rem; }
a { color: #1c3f6e; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #0b1220; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: .5rem; top: .5rem; z-index: 10; background: #fff; padding: .5rem .75rem; }
.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;
}
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--accent, #c8a25e); outline-offset: 2px;
}

/* ---- header ---- */
.top {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--chrome, #0b1220); color: var(--on-chrome, #fff);
  padding: .6rem .9rem; position: sticky; top: 0; z-index: 5;
}
.brandlink { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; }
.brand { font-family: var(--font-heading); letter-spacing: .14em; font-weight: 700; }
.brandsub { font-size: .7rem; opacity: .75; letter-spacing: .06em; text-transform: uppercase; }
.top .spacer { flex: 1 1 auto; }
.chip {
  display: inline-block; padding: .1rem .45rem; border-radius: var(--radius, 2px);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  background: var(--accent, #c8a25e); color: var(--on-accent, #111);
}
.navtoggle {
  background: transparent; color: inherit; border: 1px solid currentColor;
  border-radius: var(--radius, 2px); padding: .35rem .6rem; font: inherit; cursor: pointer;
}
.usermenu { position: relative; }
.usermenu > summary { cursor: pointer; list-style: none; font-size: .9rem; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu .menu {
  position: absolute; right: 0; top: 1.9rem; min-width: 15rem; background: #fff; color: #16181d;
  border: 1px solid #ccc5b4; border-radius: var(--radius, 2px); padding: .75rem; z-index: 6;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.usermenu .menu a { display: block; padding: .2rem 0; }

/* ---- shell ---- */
.app { display: block; }
.nav { background: #fff; border-bottom: 1px solid #ddd6c6; padding: .4rem 0; display: none; }
.nav.open { display: block; }
.navsec {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: #6d6855; padding: .6rem .9rem .15rem;
}
.navlink { display: block; padding: .5rem .9rem; color: #16181d; text-decoration: none; }
.navlink:hover { background: #f1ece0; }
.navlink.on { font-weight: 600; box-shadow: inset 3px 0 0 var(--accent, #c8a25e); background: #f6f2e8; }
.main { padding: 1rem .9rem 3rem; max-width: 58rem; }
.main.wide { max-width: none; }
@media (min-width: 50rem) {
  .app { display: grid; grid-template-columns: 15rem 1fr; align-items: start; }
  .nav {
    display: block; border-bottom: 0; border-right: 1px solid #ddd6c6;
    position: sticky; top: 3.1rem; max-height: calc(100vh - 3.1rem); overflow-y: auto;
  }
  .navtoggle { display: none; }
  .main { padding: 1.5rem 2rem 4rem; }
}

/* ---- cards, tables, lists ---- */
.card {
  background: #fff; border: 1px solid #ddd6c6; border-radius: var(--radius, 2px);
  padding: 1rem; margin: 0 0 1rem;
}
.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin: 0 0 1.25rem; }
.tile { background: #fff; border: 1px solid #ddd6c6; border-radius: var(--radius, 2px); padding: .85rem; }
.tile .n { font-family: var(--font-heading); font-size: 1.8rem; line-height: 1; }
.tile .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: #6d6855; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #e6dfd0; vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #4f4a3c; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #faf7f0; }
.muted { color: #6d6855; }
.small { font-size: .85rem; }
.pill {
  display: inline-block; padding: .05rem .4rem; border: 1px solid #c9c1ad;
  border-radius: 999px; font-size: .72rem; background: #f6f2e8; white-space: nowrap;
}
.pill.on { background: #e6f2e4; border-color: #8fb98a; }
.pill.off { background: #f2e9e9; border-color: #c29a9a; }

/* ---- forms ---- */
.field { margin: 0 0 .9rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field .help { font-size: .82rem; color: #5f5a4b; margin: .15rem 0 .3rem; }
.field .err { font-size: .85rem; color: #8a1f1f; margin: .2rem 0 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; width: 100%; max-width: 32rem; padding: .5rem .6rem;
  border: 1px solid #b9b1a0; border-radius: var(--radius, 2px); background: #fff; color: inherit;
}
textarea { min-height: 5rem; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; }
.checkrow { display: flex; align-items: flex-start; gap: .5rem; margin: 0 0 .5rem; }
.checkrow label { font-weight: 400; }
fieldset { border: 1px solid #ddd6c6; border-radius: var(--radius, 2px); padding: .9rem; margin: 0 0 1rem; background: #fff; }
legend { font-family: var(--font-heading); padding: 0 .35rem; }
.grid2 { display: grid; gap: 0 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .grid2 { grid-template-columns: 1fr 1fr; } }
.suffix { display: flex; align-items: center; gap: .4rem; max-width: 32rem; }
.suffix input { flex: 1 1 auto; }
.suffix .u { font-size: .85rem; color: #5f5a4b; white-space: nowrap; }

.btn {
  display: inline-block; font: inherit; cursor: pointer; padding: .55rem 1rem; min-height: 2.6rem;
  border: 1px solid var(--chrome, #0b1220); border-radius: var(--radius, 2px);
  background: var(--chrome, #0b1220); color: var(--on-chrome, #fff); text-decoration: none;
}
.btn:hover { opacity: .9; color: var(--on-chrome, #fff); }
.btn.secondary { background: #fff; color: #16181d; border-color: #b9b1a0; }
.btn.danger { background: #fff; color: #8a1f1f; border-color: #c29a9a; }
.btn.small { padding: .3rem .6rem; min-height: 0; font-size: .85rem; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: #1c3f6e; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 0; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin: 0 0 1rem; }
.toolbar input, .toolbar select { max-width: 14rem; }

.notice { border-left: 4px solid var(--accent, #c8a25e); background: #fff; padding: .7rem .9rem; margin: 0 0 1rem; }
.notice.bad { border-left-color: #8a1f1f; }
.notice.good { border-left-color: #3f7a37; }

/* ---- bare layout (sign in) ---- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem .9rem; }
.bare .box { width: 100%; max-width: 24rem; background: #fff; border: 1px solid #ddd6c6; border-radius: var(--radius, 2px); padding: 1.5rem; }
.bare .mark { text-align: center; margin: 0 0 1rem; }
.bare h1 { text-align: center; }
.hr { border: 0; border-top: 1px solid #e6dfd0; margin: 1.25rem 0; }

.foot { padding: 1rem .9rem 2rem; color: #6d6855; font-size: .8rem; max-width: 58rem; }
@media (min-width: 50rem) { .foot { padding-left: 2rem; } }

@media print {
  .top, .nav, .actions, .toolbar, .foot { display: none !important; }
  body { background: #fff; } .card, table { border-color: #999; }
}

/* Small utilities. These exist because the application sends a strict Content Security
   Policy with style-src 'self', so a style="" attribute is blocked in the browser - which
   is the right trade: no inline style anywhere means no inline style can be injected. */
.flush { margin-top: 0; }
.gap { margin-top: .75rem; }
.nowrap { white-space: nowrap; }
.caps { text-transform: uppercase; }
dl.grid2 > div { margin: 0 0 .5rem; }
dt { margin: 0; } dd { margin: 0; }

/* The printable invoice. The screen version is a normal page; print strips the chrome and
   keeps the table readable in black on white. */
@media print {
  .card { border: 0; padding: 0; }
  .tablewrap { overflow: visible; }
  .notice { border-left-width: 3px; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
  tfoot { display: table-row-group; }
  a[href]::after { content: ""; }
}

.impersonating { background: #8a1f1f; color: #fff; padding: .55rem 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: .9rem; }
.impersonating form { margin: 0; }
.impersonating button { background: #fff; color: #8a1f1f; border: 0; border-radius: 4px; padding: .4rem .8rem; font-weight: 700; cursor: pointer; }

/* Costs screens: a button form that sits on the same line as its neighbours. */
form.inline { display: inline; margin: 0; }
