/* Kotio design system — calm, light, Scandinavian.
   Tokens are final (hi-fi) — sourced from the Kotio design handoff (README Design Tokens). */

@import url('fonts.css');   /* self-hosted — see static/fonts */

:root {
  /* Surfaces */
  --bg: #f0ece3;              /* app page background */
  --bg-marketing: #f3efe7;    /* landing / auth background */
  --panel: #faf8f3;           /* cards, top bars, panels */
  --panel-recessed: #f6f1e8;  /* inputs, segmented controls */
  --input-bg: #f6f1e8;
  --border: #e7dfd0;
  --hairline: #e6ddce;
  --input-border: #e6dcc7;
  --row-divider: #efe8da;

  /* Text */
  --text-primary: #26231f;
  --text-secondary: #3f3a32;
  --text-muted: #6e6657;
  --text-faint: #736b58;
  --text-mono: #6f6754;       /* mono eyebrow / KPI caption — keep >=4.5:1 on --panel */

  /* Accents */
  --accent: #5b7c99;          /* primary / investment blue */
  --accent-light: #7d9bb4;
  --accent-deep: #435f76;     /* buttons, dark panels */
  --home: #4f7d74;            /* residential green-teal */
  --home-form: #5c8f86;
  --positive: #6f8560;        /* good */
  --warning: #bd913f;         /* warn / in-purchase */
  --negative: #bd6a52;        /* alert / destructive */
  --info: #5b7c99;
  --purple: #8a7fa8;          /* plan */

  --stage-planning: #8a7fa8;
  --stage-purchase: #bd913f;
  --stage-owned: #6f8560;
  --stage-sold: #5b7c99;
  --stage-abandoned: #c2b7a3;

  --role-owner: #bd913f;
  --role-manager: #5b7c99;
  --role-member: #6f8560;
  --role-viewer: #8a7fa8;
  --role-admin: #435f76;

  /* Semantic pill / badge tints */
  --tint-home-bg: #e4efe9;    --tint-home-bd: #cfe1da;
  --tint-invest-bg: #eef1f4;  --tint-invest-bd: #eaeff3;
  --tint-warn-bg: #f7efdd;    --tint-warn-bd: #ecdfc0;
  --tint-plan-bg: #f1eef6;    --tint-plan-bd: #e2dced;

  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'PingFang SC', 'Microsoft YaHei', monospace;

  --radius-card: 16px;
  --radius-card-lg: 18px;
  --radius-card-sm: 14px;
  --radius-input: 10px;
  --radius-chip: 7px;
  --shadow-hover: 0 24px 60px -34px rgba(50,42,30,.4);
  --shadow-dropdown: 0 14px 34px rgba(60,50,30,.16);
}

* , *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
}

.mono { font-family: var(--font-mono); }

a { color: inherit; }

/* ── Top nav ─────────────────────────────────────────────────────────────── */

.r-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px;
  height: 58px;
  background: rgba(11,13,18,0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  white-space: nowrap;
}

.r-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: 22px;
  flex-shrink: 0;
  text-decoration: none;
}
.r-nav .nav-logo-tile {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg,var(--accent),var(--accent-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--bg);
  flex-shrink: 0;
}
.r-nav .nav-logo-tile { color: #fff; }
.r-nav .nav-word { font-weight: 700; font-size: 14.5px; color: var(--text-primary); letter-spacing: -0.01em; }

.nvbtn {
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  height: 58px;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.nvbtn:hover { color: var(--text-primary); }
.nvbtn.active { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--accent); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.pf-switcher-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  cursor: pointer; white-space: nowrap; max-width: 220px;
}
.pf-switcher-btn span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-switcher-btn span.caret { color: var(--text-faint); }

.pf-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; z-index: 200; box-shadow: var(--shadow-dropdown);
}
.pf-menu .pf-heading {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding: 8px 10px 6px;
}
.pf-menu a.pf-item {
  width: 100%; display: block; background: transparent; border: none; border-radius: 8px;
  padding: 9px 11px; cursor: pointer; font-family: inherit; text-align: left;
  font-size: 13px; color: var(--text-primary); text-decoration: none;
}
.pf-menu a.pf-item:hover { background: var(--panel-recessed); }
.pf-menu hr { border: none; height: 1px; background: var(--border); margin: 6px 4px; }
.pf-menu a.pf-new { color: var(--accent); font-size: 12.5px; padding: 8px 11px; display: block; text-decoration: none; }

.btn-add-property {
  background: var(--accent); color: #fff; border: none;
  padding: 8px 15px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
  display: inline-block;
}

.nav-signout {
  font-size: 12.5px; color: var(--text-faint); text-decoration: none; white-space: nowrap;
}
.nav-signout:hover { color: var(--text-secondary); }

/* ── Cards & layout primitives ───────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 22px;
}
.card-sm { border-radius: var(--radius-card-sm); padding: 15px 17px; }
.card-recessed { background: var(--panel-recessed); border-color: var(--hairline); }

.page { max-width: 1240px; margin: 0 auto; padding: 32px 24px; }

.r-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.r-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.r-5 { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.r-hero { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 14px; }

.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-muted);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--radius-chip); font-size: 11px; font-weight: 500;
}

.btn {
  border: none; border-radius: 9px; font-size: 12.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; padding: 8px 15px;
  background: var(--panel-recessed); color: var(--text-secondary);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-accent-deep { background: var(--accent-deep); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-danger { background: rgba(248,113,113,0.14); color: var(--negative); }

input, select, textarea {
  font-family: inherit;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #b9c6d0; background: #fbf9f4; }

input[type=range] {
  -webkit-appearance: none; appearance: none; background: transparent;
  border: none; padding: 0; cursor: pointer; height: 18px;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: var(--border); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--border); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; height: 18px; width: 18px; border-radius: 50%;
  background: var(--text-primary); margin-top: -7px;
  box-shadow: 0 0 0 4px rgba(91,124,153,0.22); border: 2px solid var(--accent);
}
input[type=range]::-moz-range-thumb {
  height: 18px; width: 18px; border-radius: 50%; background: var(--text-primary);
  box-shadow: 0 0 0 4px rgba(91,124,153,0.22); border: 2px solid var(--accent);
}

/* ── Kotio reusable primitives ──────────────────────────────────────────── */

.kt-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 20px 22px;
}
.kt-eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-mono);
}
.kt-num { font-variant-numeric: tabular-nums; }

/* KPI tile */
.kt-kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px 20px; }
.kt-kpi-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-mono); margin-bottom: 10px; }
.kt-kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kt-kpi-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }

/* Pills */
.kt-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.kt-pill-home   { color: var(--home);    background: var(--tint-home-bg);   border: 1px solid var(--tint-home-bd); }
.kt-pill-invest { color: var(--accent);  background: var(--tint-invest-bg); border: 1px solid var(--tint-invest-bd); }
.kt-pill-warn   { color: var(--warning); background: var(--tint-warn-bg);   border: 1px solid var(--tint-warn-bd); }
.kt-pill-plan   { color: var(--purple);  background: var(--tint-plan-bg);   border: 1px solid var(--tint-plan-bd); }

/* Inputs (prototype .kt-in) */
.kt-in { width: 100%; font-family: var(--font-ui); background: var(--panel-recessed); border: 1px solid var(--input-border); border-radius: var(--radius-input); padding: 11px 14px; font-size: 14.5px; color: var(--text-primary); outline: none; }
.kt-in:focus { border-color: #b9c6d0; background: #fbf9f4; }
.kt-label { font-size: 12.5px; font-weight: 600; color: #6f695d; display: block; margin-bottom: 7px; }

/* Buttons */
.kt-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 14px; padding: 11px 18px; border-radius: 11px; text-decoration: none; }
.kt-btn-accent { background: var(--accent); color: #fff; }
.kt-btn-deep { background: var(--accent-deep); color: #fff; }
.kt-btn-dark { background: var(--text-primary); color: var(--bg-marketing); }
.kt-btn-light { background: var(--panel); color: var(--text-primary); border: 1px solid var(--border); }

/* ── Responsive breakpoints (per handoff) ───────────────────────────────── */

@media (max-width: 900px) {
  .r-hero, .r-3 { grid-template-columns: 1fr; }
  .r-4, .r-5 { grid-template-columns: repeat(2,1fr); }
  .page { padding: 24px 16px; }
  .table-scroll { overflow-x: auto; }
  .table-scroll > * { min-width: 560px; }
}

@media (max-width: 560px) {
  .r-4, .r-5 { grid-template-columns: repeat(2,1fr); }
  .form-grid { grid-template-columns: 1fr !important; }
}

/* Info dot — hoverable plain-English explainer next to KPI labels.
   Markup comes from Kotio.infoDot(key) in static/js/metrics.js. */
.info-dot { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: var(--text-faint); color: var(--panel); font-size: 10px; font-weight: 700; cursor: help; font-family: var(--font-mono); position: relative; vertical-align: -2px; margin-left: 4px; text-transform: none; letter-spacing: 0; }
.info-dot .tip { visibility: hidden; opacity: 0; position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); width: 280px; background: var(--text-primary); color: var(--panel); font-size: 11.5px; font-weight: 400; line-height: 1.5; text-transform: none; letter-spacing: 0; padding: 10px 12px; border-radius: 9px; z-index: 40; box-shadow: var(--shadow-dropdown); transition: opacity 0.12s; text-align: left; }
.info-dot:hover .tip, .info-dot:focus-visible .tip { visibility: visible; opacity: 1; }
/* Under 600px the absolutely-positioned 280px bubble extends the document and
   drags the page into horizontal scroll even while hidden. Pin it to the
   bottom of the viewport instead — fixed elements don't widen the document. */
@media (max-width: 600px) {
  .info-dot .tip { position: fixed; left: 14px; right: 14px; bottom: 14px; top: auto; width: auto; transform: none; }
}

/* Keyboard focus — one visible ring everywhere, mouse clicks unaffected. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
