/* ============================================================
   MERSYS Partner Portal – "airy MERSYS"
   Brand palette from the V3 app (media/v3/css/app.css); spacing,
   type scale and softness from the www.mersys.lv site.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --border: #e6e9ef;
  --border-strong: #d6dae3;
  --ink: #0b1530;
  --ink-2: #1f2a44;
  --ink-3: #475067;
  --muted: #6b7385;
  --muted-2: #9aa1b1;

  --brand-deep: #0b1530;
  --brand-deep-2: #122144;
  --brand: #1d63e0;
  --brand-600: #1655c5;
  --brand-700: #1146a3;
  --brand-50: #eef4ff;
  --brand-100: #dbe7ff;
  --brand-bright: #1f8bff;
  --grad: linear-gradient(135deg, #1d63e0 0%, #4f46e5 100%);

  --green: #16a34a;
  --green-50: #ecfdf5;
  --amber: #b45309;
  --amber-50: #fff8eb;
  --red: #dc2626;
  --red-50: #fef2f2;

  --shadow-sm: 0 1px 2px rgba(11, 21, 48, .05);
  --shadow-md: 0 1px 2px rgba(11, 21, 48, .04), 0 6px 18px rgba(11, 21, 48, .06);
  --shadow-lg: 0 20px 44px rgba(11, 21, 48, .10);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --max-w: 1160px;
  --font-display: "Manrope", "Inter", system-ui, sans-serif;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 .5rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- Shell ---------- */
.pp-shell { display: flex; flex-direction: column; min-height: 100vh; }
.pp-main { flex: 1; width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 40px 28px 64px; }
.pp-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.pp-page-head .sub { color: var(--muted); margin: 0; }

/* ---------- Top navigation ---------- */
.pp-topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.pp-topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 64px;
}
.pp-brand { display: flex; align-items: center; gap: 10px; }
.pp-brand img { width: 30px; height: 30px; }
.pp-brand .word { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--brand-deep); letter-spacing: -0.01em; }
.pp-brand .tag {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--brand); background: var(--brand-50); border-radius: 999px; padding: 2px 9px;
}
.pp-nav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.pp-nav a {
  color: var(--ink-3);
  font-weight: 600;
  font-size: .92rem;
  padding: 8px 13px;
  border-radius: 999px;
}
.pp-nav a:hover { color: var(--brand); background: var(--brand-50); text-decoration: none; }
.pp-nav a.active { color: var(--brand-700); background: var(--brand-50); }
.pp-user { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.pp-user .name { color: var(--ink-2); font-weight: 600; }

/* ---------- User chip & dropdown (platform-style) ---------- */
.pp-user-host { position: relative; }
.pp-user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 4px; border-radius: 999px;
  background: transparent; border: 0; cursor: pointer; font: inherit;
  user-select: none;
}
.pp-user-chip:hover { background: var(--brand-50); }
.pp-user-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pp-user-chip .caret { color: var(--muted-2); display: grid; place-items: center; transition: transform .15s ease; }
.pp-user-chip[aria-expanded="true"] .caret { transform: rotate(180deg); }
.pp-user-chip:hover .caret { color: var(--brand-700); }
.pp-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-bright) 100%);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .8rem; letter-spacing: .04em; flex-shrink: 0;
}
.pp-avatar.big { width: 40px; height: 40px; font-size: .9rem; }
.pp-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 260px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.pp-dropdown-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin: -6px -6px 6px;
  background: #fbfcfe; border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.pp-dropdown-head .who { display: flex; flex-direction: column; min-width: 0; }
.pp-dropdown-head .name { font-weight: 700; color: var(--ink); }
.pp-dropdown-head .sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pp-dropdown-info {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 6px 12px; font-size: .85rem;
}
.pp-dropdown-info span:first-child { color: var(--muted); }
.pp-dropdown-info span:last-child { color: var(--ink-2); font-weight: 600; text-align: right; }
.pp-dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }
.pp-dropdown-item {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 600; font-size: .9rem;
}
.pp-dropdown-item:hover { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.pp-dropdown-item.danger { color: var(--red); }
.pp-dropdown-item.danger:hover { background: var(--red-50); color: var(--red); }

/* ---------- Cards & grids ---------- */
.pp-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 26px;
  margin-bottom: 24px;
}
.pp-card > h2:first-child, .pp-card > h3:first-child { margin-bottom: 16px; }
.pp-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 28px; }
.pp-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}
.pp-stat .label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.pp-stat .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; color: var(--ink); margin-top: 6px; }
.pp-stat .hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.pp-stat.accent { background: var(--grad); border: 0; color: #fff; }
.pp-stat.accent .label, .pp-stat.accent .hint { color: rgba(255, 255, 255, .82); }
.pp-stat.accent .value { color: #fff; }
.pp-grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .pp-grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.pp-table-wrap { overflow-x: auto; }
.pp-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.pp-table th {
  text-align: left; color: var(--muted); font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px; border-bottom: 1px solid var(--border-strong);
}
.pp-table td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pp-table tr:last-child td { border-bottom: 0; }
.pp-table tr:hover td { background: #fbfcfe; }
.pp-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.pp-badge {
  display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 999px;
  padding: 3px 11px; white-space: nowrap;
}
.pp-badge.pilot, .pp-badge.demo, .pp-badge.contacted { background: var(--brand-50); color: var(--brand-700); }
.pp-badge.active, .pp-badge.won, .pp-badge.paid, .pp-badge.done { background: var(--green-50); color: var(--green); }
.pp-badge.at_risk, .pp-badge.accrued, .pp-badge.planned { background: var(--amber-50); color: var(--amber); }
.pp-badge.suspended, .pp-badge.new, .pp-badge.reviewed { background: #eef1f6; color: var(--ink-3); }
.pp-badge.churned, .pp-badge.lost, .pp-badge.declined { background: var(--red-50); color: var(--red); }
.pp-badge.approved { background: var(--brand-100); color: var(--brand-700); }

/* ---------- Buttons & forms ---------- */
.pp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: .92rem; font-family: inherit;
  border-radius: 999px; padding: 10px 22px; border: 1px solid transparent;
  cursor: pointer; transition: background .15s ease, box-shadow .15s ease;
}
.pp-btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.pp-btn.primary:hover { background: var(--brand-600); text-decoration: none; }
.pp-btn.ghost { background: transparent; color: var(--brand-700); border-color: var(--border-strong); }
.pp-btn.ghost:hover { background: var(--brand-50); text-decoration: none; }
.pp-btn.small { padding: 6px 14px; font-size: .85rem; }

.pp-form { display: grid; gap: 16px; max-width: 560px; }
.pp-form label { font-weight: 600; font-size: .9rem; color: var(--ink-2); display: block; margin-bottom: 6px; }
.pp-form input[type="text"], .pp-form input[type="email"], .pp-form input[type="password"],
.pp-form select, .pp-form textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 14px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.pp-form input:focus, .pp-form select:focus, .pp-form textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100);
}
.pp-form .errors { color: var(--red); font-size: .88rem; margin-top: 4px; }
.pp-form-errors {
  background: var(--red-50); color: var(--red); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: .92rem;
}

/* ---------- Filters ---------- */
.pp-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.pp-filters a {
  font-size: .85rem; font-weight: 600; color: var(--ink-3);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 14px;
}
.pp-filters a:hover { background: var(--brand-50); text-decoration: none; }
.pp-filters a.active { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.pp-filters .count { color: var(--muted-2); font-weight: 500; }
.pp-filters a.active .count { color: rgba(255,255,255,.7); }

/* ---------- Empty states ---------- */
.pp-empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.pp-empty .icon { font-size: 2rem; margin-bottom: 10px; }
.pp-empty p { margin-bottom: 18px; }

/* ---------- Activity feed ---------- */
.pp-feed { list-style: none; margin: 0; padding: 0; }
.pp-feed li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pp-feed li:last-child { border-bottom: 0; }
.pp-feed .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-bright); margin-top: 7px; flex: none; }
.pp-feed .when { color: var(--muted-2); font-size: .82rem; }

/* ---------- Auth pages (login / agreement / reset) ---------- */
.pp-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 820px) { .pp-auth { grid-template-columns: 1fr; } .pp-auth-hero { display: none; } }
.pp-auth-hero {
  background: var(--brand-deep);
  background-image: radial-gradient(at 20% 20%, rgba(31, 139, 255, .28) 0, transparent 55%),
                    radial-gradient(at 80% 90%, rgba(79, 70, 229, .30) 0, transparent 55%);
  color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px; position: relative; isolation: isolate; overflow: hidden;
}
.pp-auth-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("../images/auth-hero-network-v2.webp") center bottom / cover no-repeat;
  opacity: .42; mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(to bottom, transparent 24%, rgba(0, 0, 0, .18) 44%, #000 72%);
  mask-image: linear-gradient(to bottom, transparent 24%, rgba(0, 0, 0, .18) 44%, #000 72%);
}
.pp-auth-hero .word { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: #fff; }
.pp-auth-hero h1 { color: #fff; font-size: 2.1rem; max-width: 420px; }
.pp-auth-hero .lede { color: rgba(255, 255, 255, .75); max-width: 400px; }
.pp-auth-panel { display: flex; align-items: center; justify-content: center; padding: 48px 28px; background: var(--bg); }
.pp-auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 36px; }
.pp-auth-card h2 { margin-bottom: 20px; }
.pp-auth-card .pp-btn { width: 100%; justify-content: center; }
.pp-auth-links { margin-top: 18px; font-size: .9rem; text-align: center; }

/* ---------- Footer ---------- */
.pp-footer { border-top: 1px solid var(--border); background: var(--panel); }
.pp-footer-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 18px 28px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: .85rem;
}
.pp-footer select { font: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px 8px; color: var(--ink-3); background: #fff; }

/* ---------- Help page ---------- */
.pp-help { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .pp-help { grid-template-columns: 1fr; } .pp-help-toc { position: static; } }
.pp-help-toc { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; }
.pp-help-toc h3 { margin-bottom: 10px; }
.pp-help-toc a { color: var(--ink-3); font-weight: 600; font-size: .9rem; padding: 6px 10px; border-radius: var(--radius-sm); }
.pp-help-toc a:hover { background: var(--brand-50); color: var(--brand-700); text-decoration: none; }
.pp-help-body section { scroll-margin-top: 84px; }
.pp-help-body h2 { margin-bottom: 12px; }
.pp-help-body ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.pp-help-body li { color: var(--ink-2); }

/* ---------- Trend chart ---------- */
.pp-trend { width: 100%; height: 220px; }
.pp-trend-tip { font-size: .82rem; color: var(--muted); }

/* ---------- Detail lists ---------- */
.pp-def { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 8px 20px; font-size: .95rem; }
.pp-def dt { color: var(--muted); }
.pp-def dd { margin: 0; color: var(--ink-2); font-weight: 500; }

@media (max-width: 640px) {
  .pp-main { padding: 24px 16px 48px; }
  .pp-topbar-inner { padding: 0 16px; }
  h1 { font-size: 1.4rem; }
  .pp-def { grid-template-columns: 1fr; gap: 2px 0; }
  .pp-def dt { margin-top: 10px; }
}
