/* Client portal: sign-in, proposal list and admin console.
   Tokens match the proposal sites so moving between them feels like one product. */

:root {
  --primary: #0a96a6;
  --primary-dark: #07778a;
  --primary-tint: #e3f3f5;
  --secondary: #085159;
  --ink: #202832;
  --text-muted: #5a6470;
  --text-light: #8a929d;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --border: #e6eaee;
  --border-strong: #cbd2d8;
  --danger: #b3261e;
  --danger-tint: #fdecea;
  --warn: #8a5a00;
  --warn-tint: #fbf3e0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(32, 40, 50, 0.04);
  --shadow-lg: 0 12px 40px rgba(32, 40, 50, 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
.muted { color: var(--text-muted); }

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

/* ---------- Loading ---------- */

.center-screen { min-height: 100vh; display: grid; place-items: center; }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--bg-subtle); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1d17; border-color: #8f1d17; color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--bg-subtle); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 11px 16px; }

.btn-link {
  font: inherit; font-size: 14px; font-weight: 500;
  background: none; border: 0; padding: 4px 0;
  color: var(--primary); cursor: pointer;
}
.btn-link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- Fields ---------- */

.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 13px; }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[readonly] { background: var(--bg-subtle); color: var(--text-muted); }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0; }
.check small { display: block; color: var(--text-muted); font-size: 13px; }

.form-error {
  color: var(--danger); background: var(--danger-tint);
  border-radius: var(--radius); padding: 9px 12px; font-size: 14px;
}

.notice {
  background: var(--primary-tint); color: var(--secondary);
  border-radius: var(--radius); padding: 10px 12px; font-size: 14px;
}

/* ---------- Sign in ---------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; }

.auth-brand {
  background: linear-gradient(135deg, #0a96a6 0%, #065e69 55%, #1a2029 100%);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-brand img { height: 72px; width: auto; display: block; }
.auth-brand h1 { font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; }
.auth-brand p { color: rgba(255, 255, 255, 0.8); font-size: 17px; max-width: 34ch; }
.auth-home { color: rgba(255, 255, 255, 0.75); font-size: 14px; font-weight: 500; }
.auth-home:hover { color: #fff; }

.auth-main { display: grid; place-items: center; padding: 48px 24px; background: var(--bg); }
.auth-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.auth-form h2 + .muted { margin-top: -10px; }
.auth-form .btn-link { align-self: flex-start; }

@media (max-width: 800px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 28px 24px; gap: 20px; }
  .auth-brand img { height: 48px; }
  .auth-brand h1 { font-size: 24px; margin-bottom: 4px; }
  .auth-brand p { font-size: 15px; }
  .auth-home { display: none; }
  .auth-main { place-items: start center; padding: 32px 24px; }
}

/* ---------- App shell ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 68px; padding: 0 28px;
  display: flex; align-items: center; gap: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topbar-logo img { height: 38px; width: auto; display: block; }
.topbar-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--primary); padding-left: 16px; border-left: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.topbar-user { color: var(--text-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.page { max-width: 1080px; margin: 0 auto; padding: 40px 28px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.page-head p { color: var(--text-muted); margin-top: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.tab {
  font: inherit; font-weight: 600; font-size: 14px;
  background: none; border: 0; cursor: pointer;
  padding: 10px 14px; margin-bottom: -1px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab .count { font-weight: 500; color: var(--text-light); margin-left: 4px; }

.banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--warn-tint); color: var(--warn);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 24px;
}
.banner p { flex: 1; min-width: 240px; }
.banner strong { display: block; }

.empty {
  background: var(--bg); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 40px 24px; text-align: center; color: var(--text-muted);
}
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- Client proposals: portrait "documents" ---------- */

.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 240px)); gap: 32px 28px; }

.doc { display: block; color: var(--ink); border-radius: 6px; }
.doc:hover { color: var(--ink); }

.doc-page {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  aspect-ratio: 210 / 297; /* A4 */
  padding: 22px 20px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 5px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(32, 40, 50, 0.06), 0 6px 18px rgba(32, 40, 50, 0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.doc:hover .doc-page, .doc:focus-visible .doc-page { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(32, 40, 50, 0.06), 0 18px 40px rgba(32, 40, 50, 0.16); }

.doc-logo { width: 62%; height: auto; display: block; }

.doc-body { display: flex; flex-direction: column; gap: 8px; margin-top: auto; margin-bottom: auto; padding-top: 12px; }
.doc-kind { font-size: 10px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--primary); }
.doc-title {
  font-size: 17px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; color: var(--secondary);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden;
}
.doc-client { font-size: 12px; line-height: 1.45; color: var(--text-muted); padding-top: 10px; border-top: 1px solid var(--border); }
.doc-client strong { display: block; color: var(--ink); font-weight: 600; font-size: 13px; }

.doc-foot { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-light); }

.doc-open {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(7, 119, 138, 0.94); color: #fff;
  font-size: 15px; font-weight: 600;
  opacity: 0; transition: opacity 0.2s ease;
}
.doc-open svg { width: 30px; height: 30px; }
.doc:hover .doc-open, .doc:focus-visible .doc-open { opacity: 1; }

/* Touch screens have no hover: show the action as a strip along the bottom instead. */
@media (hover: none) {
  .doc-open { inset: auto 0 0 0; flex-direction: row; padding: 10px; font-size: 13px; opacity: 1; }
  .doc-open svg { width: 18px; height: 18px; }
  .doc-foot { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .doc-page, .doc-open { transition: none; }
  .doc:hover .doc-page, .doc:focus-visible .doc-page { transform: none; }
}
@media (max-width: 520px) { .docs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; } .doc-title { font-size: 15px; } }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); }

/* ---------- Admin: proposals ---------- */

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

.panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 24px; flex-wrap: wrap; }
.panel-title { flex: 1; min-width: 220px; }
.panel-title h2 { font-size: 18px; font-weight: 600; line-height: 1.35; margin-top: 2px; }
.panel-title .path { font-size: 13px; color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { border-top: 1px solid var(--border); padding: 16px 24px 20px; }
.panel-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 4px 3px 12px; font-size: 13px; font-weight: 500;
}
.chip.is-disabled { color: var(--text-light); text-decoration: line-through; }
.chip button {
  font: inherit; line-height: 1; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.chip button:hover { background: var(--danger-tint); color: var(--danger); }
.chips select { width: auto; padding: 5px 10px; font-size: 13px; border-radius: 999px; }
.chips .none { color: var(--text-light); font-size: 14px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill-live { background: var(--primary-tint); color: var(--secondary); }
.pill-off { background: #eceff2; color: var(--text-muted); }
.pill-admin { background: #ebe5fb; color: #4a2a9c; }
.pill-warn { background: var(--warn-tint); color: var(--warn); }

.hint { margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.hint code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #eceff2; padding: 1px 5px; border-radius: 4px; }

/* ---------- Admin: users ---------- */

.table-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted);
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.user-name { font-weight: 600; }
.user-email { color: var(--text-muted); font-size: 13px; }
tr.is-disabled .user-name, tr.is-disabled .user-email { color: var(--text-light); }
td.nowrap { white-space: nowrap; color: var(--text-muted); }

/* ---------- Dialogs ---------- */

dialog {
  border: 0; border-radius: var(--radius-lg); padding: 0;
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  box-shadow: var(--shadow-lg); color: var(--ink);
}
dialog::backdrop { background: rgba(32, 40, 50, 0.45); }
.dialog-form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dialog-form h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; margin: 0; }
.fieldset legend { font-size: 13px; font-weight: 600; padding: 0 4px; }

.credentials {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; font-family: inherit; font-size: 14px;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 100;
  max-width: calc(100vw - 32px);
}
.toast.is-error { background: var(--danger); }

@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-title, .topbar-user { display: none; }
  .page { padding: 28px 16px 64px; }
  .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
}
