:root {
  /* Constellation brand: navy #24245C, grey #585A58, pale blue #BBD2E8 on light */
  --navy: #24245c;
  --navy-deep: #1a1a47;
  --bg: #f4f6fb;        /* page background */
  --bg-2: #eaeef6;      /* subtle alt background */
  --panel: #ffffff;     /* cards */
  --panel-2: #f0f3fa;
  --line: #d9e0ee;      /* borders */
  --text: #1f2440;      /* main text (near-navy) */
  --muted: #6b7390;     /* secondary text */
  --gold: #24245c;      /* primary action = brand navy (var name kept for reuse) */
  --gold-soft: #34347a; /* hover */
  --accent: #4a5db0;
  --paleblue: #bbd2e8;

  --stage-prospect: #8a93b5;
  --stage-mandate: #4a5db0;
  --stage-negotiation: #c98a2b;
  --stage-executed: #2fa37a;

  --radius: 14px;
  --shadow: 0 16px 38px -20px rgba(36, 36, 92, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(187,210,232,.45), transparent 60%),
    radial-gradient(900px 520px at 5% 0%, rgba(36,36,92,.06), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

/* Subtle star dust in brand navy (very faint on light bg) */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(36,36,92,.10), transparent),
    radial-gradient(1.5px 1.5px at 70% 60%, rgba(36,36,92,.08), transparent),
    radial-gradient(2px 2px at 40% 80%, rgba(36,36,92,.07), transparent),
    radial-gradient(1.5px 1.5px at 90% 20%, rgba(36,36,92,.06), transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(36,36,92,.07), transparent),
    radial-gradient(2px 2px at 15% 70%, rgba(36,36,92,.06), transparent);
  background-size: 100% 100%;
  opacity: .7;
}

.site-header, .site-main, .site-footer { position: relative; z-index: 1; }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 40px;
  background: rgba(255,255,255,.85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; text-decoration: none; }
/* Logo PNG has built-in vertical whitespace; negative margins trim the
   visual gap so the header stays compact while the logo reads large. */
.brand-logo { height: 120px; width: auto; display: block; margin: -22px 0; }
.site-nav { display: flex; align-items: center; gap: 10px; }
.nav-user { color: var(--muted); font-size: 13px; margin-right: 6px; }
.nav-link {
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; transition: .15s;
}
.nav-link:hover { border-color: var(--line); background: var(--panel-2); }
.nav-cta { background: var(--gold); color: #fff; font-weight: 600; }
.nav-cta:hover { background: var(--gold-soft); border-color: transparent; }
.nav-admin { border-color: var(--line); color: var(--gold-soft); }
.nav-admin:hover { border-color: var(--gold); background: var(--panel); }

/* language switch */
.lang-switch { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-right: 4px; }
.lang-switch .lang-active, .lang-switch .lang-opt {
  font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 4px 9px; border-radius: 999px; text-decoration: none; line-height: 1;
}
.lang-switch .lang-active { background: var(--gold); color: #fff; }
.lang-switch .lang-opt { color: var(--muted); }
.lang-switch .lang-opt:hover { color: var(--text); background: var(--panel-2); }

/* Main */
.site-main { max-width: 1240px; margin: 0 auto; padding: 48px 40px 80px; }

.hero { text-align: center; margin-bottom: 44px; }
.hero-slogan {
  font-family: "Sora", sans-serif; text-transform: uppercase; letter-spacing: .42em;
  font-size: 13px; font-weight: 600; color: var(--accent); margin: 0 0 10px; padding-left: .42em;
}
.hero h1 {
  font-family: "Sora", sans-serif; font-size: 40px; margin: 0 0 12px;
  background: linear-gradient(120deg, var(--navy), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--muted); max-width: 620px; margin: 0 auto; font-size: 16px; }

/* Deal grid */
.deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.deal-card {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  aspect-ratio: 4 / 3;
}
.deal-card:hover {
  transform: translateY(-6px);
  border-color: var(--navy);
  box-shadow: 0 26px 56px -22px rgba(36,36,92,.5);
}

.deal-thumb { position: absolute; inset: 0; }
.deal-thumb img { width: 100%; height: 100%; object-fit: cover; }
.deal-thumb-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy-deep), var(--navy) 55%, var(--accent));
  position: relative;
}
.deal-thumb-fallback::after {
  content: "✦"; position: absolute; right: 14px; bottom: 10px; color: rgba(255,255,255,.18); font-size: 40px;
}
.deal-thumb-fallback span {
  font-family: "Sora", sans-serif; font-size: 56px; font-weight: 700; color: rgba(255,255,255,.85);
  letter-spacing: .05em;
}

/* gradient scrim so text reads on any photo */
.deal-thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,14,26,.05) 30%, rgba(10,14,26,.85));
}

.stage-badge {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; color: #fff;
  background: var(--muted);
}
.private-badge {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  background: rgba(36,36,92,.9); color: #fff; border-radius: 999px;
  width: 26px; height: 26px; display: grid; place-items: center; font-size: 13px;
}
.stage-prospect .stage-badge { background: var(--stage-prospect); color: #fff; }
.stage-mandate .stage-badge { background: var(--stage-mandate); color: #fff; }
.stage-negotiation .stage-badge { background: var(--stage-negotiation); }
.stage-executed .stage-badge { background: var(--stage-executed); color: #06231a; }

/* base label (always visible) — sits on the dark photo scrim, so text is light */
.deal-base {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 18px; transition: opacity .2s; color: #fff;
}
.deal-base .deal-name { margin: 0 0 2px; font-size: 18px; font-family: "Sora", sans-serif; color: #fff; }
.deal-loc { color: rgba(255,255,255,.8); font-size: 13px; }
.deal-card:hover .deal-base { opacity: 0; }

/* hover panel (slides up) */
.deal-hover {
  position: absolute; inset: 0; z-index: 4;
  padding: 22px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(180deg, rgba(12,16,30,.35), rgba(12,16,30,.94));
  opacity: 0; transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease;
}
.deal-card:hover .deal-hover { opacity: 1; transform: translateY(0); }
.deal-hover, .deal-hover .deal-name { color: #fff; }
.deal-hover .deal-name { margin: 0 0 12px; font-size: 20px; font-family: "Sora", sans-serif; }

.deal-facts { margin: 0 0 12px; display: grid; gap: 7px; }
.deal-facts > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.18); padding-bottom: 6px; }
.deal-facts dt { color: rgba(255,255,255,.7); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 0; }
.deal-facts dd { margin: 0; font-weight: 600; font-size: 14px; text-align: right; color: #fff; }
.deal-summary { color: rgba(255,255,255,.85); font-size: 13px; margin: 0 0 12px; }
.deal-cta { color: var(--paleblue); font-weight: 600; font-size: 14px; }

/* empty state */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-hint a { color: var(--gold); }

/* messages */
.messages { list-style: none; padding: 0; margin: 0 0 24px; }
.msg { padding: 12px 16px; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--panel); }
.msg-error { border-color: #b3475a; }
.msg-success { border-color: var(--stage-executed); }

/* detail page */
.back-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link:hover { color: var(--gold); }
.deal-detail { margin-top: 18px; }
.detail-header {
  display: flex; gap: 24px; align-items: flex-end;
  border-radius: var(--radius); overflow: hidden; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); margin-bottom: 24px;
}
.detail-photo { width: 220px; height: 150px; object-fit: cover; border-radius: 10px; }
.detail-head-text h1 { font-family: "Sora", sans-serif; margin: 10px 0 0; font-size: 32px; }
.detail-summary { color: var(--muted); margin: 8px 0 0; }
.detail-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: 0 0 28px; }
.detail-facts > div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.detail-facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.detail-facts dd { margin: 6px 0 0; font-size: 18px; font-weight: 600; }
.detail-body { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 24px; }
.detail-body h2 { font-family: "Sora", sans-serif; margin-top: 0; }
.detail-locked { color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; }

/* logout button styled as nav link */
.logout-form { display: inline; margin: 0; }
.nav-logout { background: none; border: 1px solid transparent; cursor: pointer; font: inherit; }
.nav-logout:hover { border-color: var(--line); background: var(--panel); }

/* auth pages */
.auth-wrap { display: flex; justify-content: center; padding: 30px 0; }
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 36px; box-shadow: var(--shadow);
}
.auth-logo { display: block; width: 200px; max-width: 70%; height: auto; margin: 0 auto 22px; }
.visibility-field { border: none; padding: 0; margin: 0 0 16px; }
.visibility-field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.visibility-field ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.visibility-field li { display: flex; align-items: flex-start; gap: 8px; }
.visibility-field label { font-size: 14px; color: var(--text); cursor: pointer; }
.visibility-field input[type=radio] { margin-top: 3px; accent-color: var(--navy); }
.auth-card-center { text-align: center; }
.auth-icon {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: rgba(231,185,100,.15); color: var(--gold); border: 1px solid var(--gold);
}
.auth-icon-bad { background: rgba(179,71,90,.15); color: #e98aa0; border-color: #b3475a; }
.auth-title { font-family: "Sora", sans-serif; margin: 0 0 6px; font-size: 26px; }
.auth-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.auth-alt { color: var(--muted); font-size: 14px; margin: 20px 0 0; text-align: center; }
.auth-alt a, .field-help a { color: var(--gold); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); font: inherit;
}
.field input:focus { outline: none; border-color: var(--gold); }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field-help { color: var(--muted); font-size: 12px; margin: -6px 0 16px; line-height: 1.4; }
.field-help ul, .field ul.errorlist { margin: 6px 0 0; padding-left: 16px; }
ul.errorlist { color: #e98aa0; font-size: 12.5px; list-style: none; padding-left: 0; margin: 6px 0 0; }
.form-errors, .form-errors ul { color: #e98aa0; font-size: 13.5px; margin: 0 0 18px; }
.form-errors ul { list-style: none; padding: 0; }

.btn-primary {
  display: inline-block; width: 100%; text-align: center;
  background: var(--gold); color: #fff; font-weight: 600; font-size: 15px;
  border: none; border-radius: 10px; padding: 12px 18px; cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn-primary:hover { background: var(--gold-soft); }

/* detail: two-column docs + comments */
.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.panel h2 { font-family: "Sora", sans-serif; margin: 0 0 16px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.panel h2 .count {
  font-family: "Inter", sans-serif; font-size: 12px; font-weight: 600;
  background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px;
}
.muted-note { color: var(--muted); font-size: 14px; }

/* documents */
.doc-list { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.doc-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.doc-ext {
  flex: 0 0 auto; text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  background: var(--accent); color: #fff; padding: 6px 8px; border-radius: 6px; min-width: 42px; text-align: center;
}
.doc-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doc-name { color: var(--text); font-weight: 600; text-decoration: none; word-break: break-word; }
.doc-name:hover { color: var(--gold); }
.doc-note { color: var(--gold-soft); font-size: 13px; }
.doc-sub { color: var(--muted); font-size: 12px; }

.upload-form, .comment-form { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.upload-form .field input, .comment-form .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; background: var(--bg-2);
  border: 1px solid var(--line); color: var(--text); font: inherit;
}
.upload-form input[type=file] { padding: 9px; cursor: pointer; }
.comment-form textarea { resize: vertical; }
.btn-inline { width: auto; justify-self: start; }

/* comments */
.comment-list { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 12px; }
.comment { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.comment-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.comment-author { font-weight: 600; font-size: 14px; }
.comment-time { color: var(--muted); font-size: 12px; }
.comment-body { margin: 0; font-size: 14px; }
.comment-body p { margin: 0 0 6px; }

@media (max-width: 760px) { .detail-cols { grid-template-columns: 1fr; } }

/* deal summary modal */
.summary-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.summary-modal[hidden] { display: none; }
.summary-backdrop { position: absolute; inset: 0; background: rgba(6, 9, 18, .72); backdrop-filter: blur(3px); }
.summary-dialog {
  position: relative; z-index: 1;
  width: 92vw; max-width: 1100px;   /* roomy on desktop */
  height: 90vh;                     /* tall, but never the full window */
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9);
  overflow: hidden;
}
.summary-dialog-body { font-size: 15.5px; }
/* center the reading column on very wide screens so lines aren't too long */
.summary-dialog-body > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.summary-dialog-head, .summary-dialog-foot {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.summary-dialog-foot { border-bottom: none; border-top: 1px solid var(--line); }
.summary-dialog-head h2 { font-family: "Sora", sans-serif; font-size: 18px; margin: 0; }
.summary-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.summary-close:hover { background: var(--bg-2); color: var(--text); }
.summary-source { color: var(--muted); font-size: 12px; }
.summary-dialog-body {
  flex: 1 1 auto; overflow-y: auto;   /* the scroll feature */
  -webkit-overflow-scrolling: touch;
  padding: 22px; line-height: 1.6;
}
.summary-dialog-body h2 { font-family: "Sora", sans-serif; font-size: 20px; margin: 18px 0 8px; color: var(--gold-soft); }
.summary-dialog-body h3 { font-size: 17px; margin: 16px 0 6px; }
.summary-dialog-body h4 { font-size: 15px; margin: 14px 0 4px; color: var(--muted); }
.summary-dialog-body p { margin: 0 0 10px; }
.summary-dialog-body ul, .summary-dialog-body ol { margin: 0 0 12px; padding-left: 22px; }
.summary-dialog-body li { margin: 3px 0; }
.summary-table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 14px; }
.summary-table th, .summary-table td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.summary-table th { background: var(--bg-2); }

@media (max-width: 720px) {
  .summary-modal { padding: 0; }
  .summary-dialog { max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; border: none; }
}

/* footer */
.site-footer {
  border-top: 1px solid var(--line); padding: 22px 40px; text-align: center;
  color: var(--muted); font-size: 13px; display: flex; gap: 10px; justify-content: center;
}
.footer-dot { opacity: .5; }

@media (max-width: 640px) {
  .site-header, .site-main, .site-footer { padding-left: 18px; padding-right: 18px; }
  .hero h1 { font-size: 30px; }
  .detail-header { flex-direction: column; align-items: stretch; }
  .detail-photo { width: 100%; height: 200px; }
}

/* --- Narrow / phone header: centered logo, then a tidy nav row --- */
@media (max-width: 900px) {
  .site-header { flex-direction: column; align-items: stretch; padding: 4px 16px 12px; gap: 8px; }
  .brand { justify-content: center; }
  .brand-logo { height: 92px; margin: -14px 0 -8px; }
  .site-nav { width: 100%; flex-wrap: wrap; justify-content: center; gap: 8px 6px; }
  .nav-link { padding: 7px 12px; font-size: 13px; }
  /* email is noise on a phone — hide it; logout stays */
  .nav-user { display: none; }
  .logout-form { margin-left: auto; }
  .site-main { padding: 28px 16px 60px; }
  .deal-grid { gap: 16px; }
  .hero { margin-bottom: 28px; }
  .detail-facts { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px; }
  /* small screens are touch — reveal deal facts (no hover available) */
  .deal-card { aspect-ratio: auto; min-height: 300px; }
  .deal-card .deal-hover { opacity: 1; transform: none; overflow-y: auto; justify-content: flex-start; }
  .deal-card .deal-base { display: none; }
  .deal-card .stage-badge { display: none; }
}

/* --- Touch devices can't hover: always reveal the deal facts --- */
@media (hover: none) {
  .deal-card { aspect-ratio: auto; min-height: 300px; }
  .deal-card .deal-hover { opacity: 1; transform: none; overflow-y: auto; justify-content: flex-start; }
  .deal-card .deal-base { display: none; }
  .deal-card .stage-badge { display: none; }
  .deal-card:active { transform: scale(0.99); }
  .deal-card:hover { transform: none; box-shadow: var(--shadow); border-color: var(--line); }
}
