:root {
  --ink: #16222e;
  --muted: #6a7784;
  --line: #dfe5ea;
  --paper: #f6f8fa;
  --card: #ffffff;
  --brand: #12263a;
  --accent: #b3752b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 12px 16px;
  min-height: 46px;
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
  width: 100%;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: inherit;
  padding: 8px 10px;
  min-height: 44px;
}

.muted { color: var(--muted); font-weight: 400; }
.centre { text-align: center; }

/* ---------------------------------------------------------------- sign in */

.signin {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--brand);
}

.signin form {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.signin h1 { margin: 0 0 6px; font-size: 1.45rem; }
.signin .muted { margin: 0 0 22px; font-size: 0.95rem; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.field input {
  width: 100%;
  font: inherit;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.note { min-height: 1.2em; color: #a3311f; font-size: 0.9rem; margin: 12px 0 0; }

/* ------------------------------------------------------------------- list */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--brand);
  color: #fff;
}

.bar strong { font-size: 1.1rem; }
.bar .muted { color: rgba(255, 255, 255, 0.7); margin-left: 8px; font-size: 0.85rem; }

.customers { padding: 14px 14px 40px; display: grid; gap: 12px; }

.customer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.customer > button {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 16px;
  text-align: left;
}

.customer-name { font-weight: 600; font-size: 1.05rem; }
.customer-meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.documents { border-top: 1px solid var(--line); }
.customer.collapsed .documents { display: none; }

.document {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 14px 16px;
  text-align: left;
}

.document:last-child { border-bottom: 0; }
.document:active { background: #eef3f7; }

.document-kind {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.document-name { grid-column: 1 / 2; font-weight: 500; }
.document-figures { grid-column: 1 / 2; color: var(--muted); font-size: 0.85rem; }
.document-open { grid-row: 1 / 4; grid-column: 2 / 3; align-self: center; color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------------- viewer */

.viewer {
  position: fixed;
  inset: 0;
  background: #2a3138;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.viewer-bar { background: #1b2228; }
.viewer-name {
  flex: 1;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.zoom { display: flex; gap: 4px; }
.zoom button { font-size: 1.3rem; line-height: 1; color: #fff; }

.pages {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #2a3138;
  -webkit-overflow-scrolling: touch;
}

.pages iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  transform-origin: top left;
}

.linkish { text-decoration: none; display: inline-flex; align-items: center; color: #fff; }

.viewer .note { color: #ffd7cd; padding: 0 16px 16px; }

@media (min-width: 720px) {
  .customers { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
