/* =====================================================================
   Radnor Consulting CRM — brand stylesheet
   Palette lifted from radnorconsulting.net for visual consistency.
   ===================================================================== */
:root {
  --ink:        #1a1814;
  --ink-light:  #3d3a34;
  --parchment:  #f5f2ec;
  --warm-white: #faf8f4;
  --gold:       #b8922a;
  --gold-light: #d4aa4e;
  --mid:        #7a756e;
  --border:     rgba(26, 24, 20, 0.12);
  --border-dark: rgba(255, 255, 255, 0.09);
  --radius:     2px;
  --sidebar-w:  256px;

  /* Re-tint Bootstrap to the Radnor palette */
  --bs-primary: var(--gold);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--warm-white);
  --bs-link-color: var(--ink);
  --bs-link-hover-color: var(--gold);
  --bs-border-radius: var(--radius);
  --bs-border-radius-sm: var(--radius);
  --bs-border-radius-lg: var(--radius);
}

body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--warm-white);
  color: var(--ink);
  font-size: 0.93rem;
}

h1, h2, h3, h4, h5, .serif {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.01em;
}

a { text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------------------------------------------------------------- Layout */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: rgba(245, 242, 236, 0.72);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, transform 0.25s ease;
}

.sidebar .brand {
  padding: 1.6rem 1.5rem 1.3rem;
  border-bottom: 1px solid var(--border-dark);
}
.sidebar .brand .brandmark {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.4rem;
  letter-spacing: 0.22em;
  color: var(--warm-white);
  font-weight: 500;
}
.sidebar .brand .brand-logo {
  display: block;
  width: 100%;
  max-width: 190px;
  margin: 0 auto;
  background: #faf8f4;
  border-radius: 4px;
  padding: 0.7rem 0.85rem;
}
.sidebar .brand .rule {
  width: 34px;
  height: 2px;
  background: var(--gold);
  margin: 0.6rem 0 0.55rem;
}
.sidebar .brand .tag {
  font-size: 0.68rem;
  line-height: 1.5;
  color: rgba(245, 242, 236, 0.42);
  font-weight: 300;
}

.sidebar .nav-section {
  padding: 1.1rem 1.5rem 0.35rem;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(212, 170, 78, 0.85);
}

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 1.5rem;
  color: rgba(245, 242, 236, 0.66);
  font-size: 0.88rem;
  border-left: 2px solid transparent;
}
.sidebar a.nav-link:hover {
  color: var(--warm-white);
  background: rgba(255, 255, 255, 0.04);
}
.sidebar a.nav-link.active {
  color: var(--warm-white);
  border-left-color: var(--gold);
  background: rgba(184, 146, 42, 0.10);
}
.sidebar .nav-link .ico { width: 18px; text-align: center; opacity: 0.8; }

.sidebar .userbox {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-dark);
  font-size: 0.8rem;
}
.sidebar .userbox .who { color: var(--warm-white); }
.sidebar .userbox a { color: var(--gold-light); font-size: 0.78rem; }

/* Main column */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

.topbar {
  height: 64px;
  background: rgba(250, 248, 244, 0.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.9rem;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}
.topbar .page-title {
  font-size: 1.18rem;
  margin: 0;
  color: var(--ink);
}
.topbar .eyebrow {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--mid);
}

.content { padding: 1.9rem; }

/* ---------------------------------------------------------------- Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(26, 24, 20, 0.03);
}
.card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
}

/* KPI tiles */
.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  height: 100%;
}
.kpi .label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--mid);
}
.kpi .value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.9rem;
  color: var(--ink);
  line-height: 1.1;
  margin-top: 0.3rem;
}
.kpi .value.sm { font-size: 1.35rem; }

/* Pipeline columns */
.pipe-col {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--parchment);
  padding: 0.85rem 0.95rem;
  height: 100%;
}
.pipe-col .stage { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-light); }
.pipe-col .amt { font-family: "Fraunces", Georgia, serif; font-size: 1.25rem; margin-top: 0.25rem; }
.pipe-col .cnt { font-size: 0.72rem; color: var(--mid); }

/* ---------------------------------------------------------------- Tables */
.table { font-size: 0.88rem; }
.table thead th {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mid);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.table-hover tbody tr:hover { background: var(--parchment); cursor: pointer; }
.table td { vertical-align: middle; }

/* ---------------------------------------------------------------- Buttons */
.btn { border-radius: var(--radius); font-size: 0.86rem; }
.btn-primary, .btn-gold {
  background-color: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.btn-primary:hover, .btn-gold:hover {
  background-color: #a07f22;
  border-color: #a07f22;
  color: #fff;
}
.btn-dark { background-color: var(--ink); border-color: var(--ink); }
.btn-outline-secondary { color: var(--ink-light); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--ink); border-color: var(--ink); }

/* ---------------------------------------------------------------- Badges */
.badge { font-weight: 600; border-radius: var(--radius); letter-spacing: 0.02em; }

/* ---------------------------------------------------------------- Detail */
.detail-grid dt { color: var(--mid); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.detail-grid dd { color: var(--ink); margin-bottom: 0.85rem; }

.timeline .item { border-left: 2px solid var(--border); padding: 0 0 1rem 1rem; position: relative; }
.timeline .item::before {
  content: ""; position: absolute; left: -5px; top: 4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.timeline .meta { font-size: 0.72rem; color: var(--mid); }

/* ---------------------------------------------------------------- Forms */
.form-label { font-size: 0.76rem; font-weight: 600; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.04em; }
.form-control, .form-select { border-radius: var(--radius); border-color: var(--border); font-size: 0.9rem; }
.form-control:focus, .form-select:focus { border-color: var(--gold); box-shadow: 0 0 0 0.18rem rgba(184, 146, 42, 0.15); }

/* ---------------------------------------------------------------- Login */
.login-wrap { min-height: 100vh; display: flex; }
.login-aside {
  flex: 1;
  background: linear-gradient(160deg, rgba(20, 18, 14, 0.78), rgba(18, 16, 11, 0.93)), url("../img/board-web.jpg");
  background-size: cover;
  background-position: center;
  color: var(--warm-white);
  padding: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-aside .brandmark { font-family: "Fraunces", Georgia, serif; font-size: 1.7rem; letter-spacing: 0.22em; }
.login-aside .lede { font-family: "Fraunces", Georgia, serif; font-size: 1.7rem; line-height: 1.4; font-weight: 300; }
.login-aside .gold { color: var(--gold-light); }
.login-logo-card { background: rgba(250, 248, 244, 0.96); border-radius: 4px; padding: 1.4rem 1.6rem; align-self: flex-start; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28); }
.login-logo { display: block; width: 250px; max-width: 60vw; height: auto; }
.login-form-col { width: 440px; max-width: 100%; padding: 3.5rem; display: flex; flex-direction: column; justify-content: center; background: var(--warm-white); }

/* Brand mini-mark — only visible when the rail is collapsed. */
.brand-mini { display: none; font-family: "Fraunces", Georgia, serif; font-size: 1.5rem; color: #faf8f4; text-align: center; }

/* Off-canvas backdrop (mobile drawer). */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10, 9, 6, 0.5); z-index: 25; opacity: 0; transition: opacity 0.25s ease; }

/* Collapsed icon rail — desktop only. */
@media (min-width: 992px) {
  [data-sidebar="collapsed"] .sidebar { width: 68px; }
  [data-sidebar="collapsed"] .main { margin-left: 68px; }
  [data-sidebar="collapsed"] .sidebar .tag,
  [data-sidebar="collapsed"] .sidebar .rule,
  [data-sidebar="collapsed"] .sidebar .nav-section,
  [data-sidebar="collapsed"] .sidebar .nav-link .lbl,
  [data-sidebar="collapsed"] .sidebar .brand-logo,
  [data-sidebar="collapsed"] .sidebar .userbox .who,
  [data-sidebar="collapsed"] .sidebar .userbox .mt-1 { display: none; }
  [data-sidebar="collapsed"] .sidebar .brand { padding: 1.3rem 0.4rem; text-align: center; }
  [data-sidebar="collapsed"] .sidebar .brand-mini { display: block; }
  [data-sidebar="collapsed"] .sidebar a.nav-link { justify-content: center; padding: 0.6rem 0; border-left-width: 0; }
  [data-sidebar="collapsed"] .sidebar a.nav-link.active { box-shadow: inset 3px 0 0 var(--gold); }
  [data-sidebar="collapsed"] .sidebar .nav-link .ico { font-size: 1.1rem; opacity: 0.95; }
  [data-sidebar="collapsed"] .sidebar .userbox { text-align: center; padding: 1rem 0.4rem; }
}

/* Mobile & tablet: the sidebar becomes a slide-in drawer. */
@media (max-width: 991px) {
  .sidebar { width: 272px; transform: translateX(-100%); z-index: 60; }
  [data-mobilenav="open"] .sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, 0.5); }
  .main { margin-left: 0; }
  .sidebar-backdrop { display: block; visibility: hidden; }
  [data-mobilenav="open"] .sidebar-backdrop { visibility: visible; opacity: 1; }
  .content { padding: 1.1rem; }
  .topbar { padding: 0 1rem; }
  .page-title { font-size: 1.06rem; }
  /* Branded login on phones too: stack the panel above the form. */
  .login-wrap { flex-direction: column; }
  .login-aside { flex: none; padding: 2.2rem 1.6rem; gap: 1.2rem; }
  .login-form-col { width: 100%; padding: 2.2rem 1.6rem; }
}

/* ============================================================ Top-bar tools */
.iconbtn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 38px; height: 38px;
  color: var(--ink-light);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer;
}
.iconbtn:hover { border-color: var(--gold); color: var(--gold); }
.rem-badge {
  position: absolute; top: -6px; right: -6px;
  background: var(--gold); color: #fff; font-size: .62rem;
  min-width: 17px; height: 17px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.rem-head { padding: .7rem 1rem; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--border); }
.rem-list { max-height: 340px; overflow: auto; }
.rem-item { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--border); color: var(--ink); }
.rem-item:hover { background: var(--parchment); }
.rem-item .t { font-size: .73rem; color: var(--mid); }
.rem-item.overdue { border-left: 3px solid #dc3545; }
.rem-foot { display: block; padding: .55rem 1rem; font-size: .8rem; text-align: center; border-top: 1px solid var(--border); }
.linklike { background: none; border: 0; padding: 0; color: var(--gold-light); font-size: .78rem; cursor: pointer; font: inherit; }
.linklike:hover { color: var(--gold); text-decoration: underline; }

/* ============================================================ Calendar */
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-grid th { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--mid); padding: .5rem .4rem; text-align: left; border-bottom: 1px solid var(--border); }
.cal-cell { border: 1px solid var(--border); height: 116px; vertical-align: top; padding: .35rem .4rem; overflow: hidden; }
.cal-cell.outside { background: var(--parchment); }
.cal-cell.today { outline: 2px solid var(--gold); outline-offset: -2px; }
.cal-cell.today .cal-daynum { color: var(--gold); }
.cal-daynum { font-size: .78rem; color: var(--ink-light); font-weight: 600; }
.cal-ev { display: block; font-size: .69rem; padding: .12rem .35rem; border-radius: var(--radius); margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.cal-ev.task { background: rgba(184,146,42,.16); border-left: 3px solid var(--gold); }
.cal-ev.meeting { background: rgba(13,110,253,.14); border-left: 3px solid #0d6efd; }
.cal-ev.call { background: rgba(25,135,84,.14); border-left: 3px solid #198754; }

/* ============================================================ Settings */
.settings-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--mid); margin-bottom: .35rem; }
.form-control-color { width: 56px; height: 38px; padding: .2rem; }

/* ============================================================ Dark theme */
[data-theme="dark"] {
  --warm-white: #17150f;
  --parchment:  #221f19;
  --ink:        #ece8e0;
  --ink-light:  #cfcabf;
  --mid:        #9b958a;
  --border:     rgba(255,255,255,0.11);
  --bs-body-bg: #17150f;
  --bs-body-color: #ece8e0;
}
[data-theme="dark"] body { background: #17150f; color: #ece8e0; }
/* The sidebar is intentionally dark in both themes; pin it so the flipped
   --ink/--warm-white vars don't lighten it or hide the wordmark. */
[data-theme="dark"] .sidebar { background: #100e0a; }
[data-theme="dark"] .sidebar .brand .brandmark,
[data-theme="dark"] .sidebar a.nav-link:hover,
[data-theme="dark"] .sidebar a.nav-link.active,
[data-theme="dark"] .sidebar .userbox .who { color: #faf8f4; }
[data-theme="dark"] .btn-dark { background: #3a352b; border-color: #3a352b; }
[data-theme="dark"] .card,
[data-theme="dark"] .kpi { background: #201d17; }
[data-theme="dark"] .topbar { background: rgba(23,21,15,0.92); }
[data-theme="dark"] .pipe-col { background: #262219; }
[data-theme="dark"] .table { color: #ece8e0; --bs-table-color: #ece8e0; --bs-table-bg: transparent; }
[data-theme="dark"] .table-hover tbody tr:hover { background: #2b271e; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background: #1c1a14; color: #ece8e0; }
[data-theme="dark"] .form-control::placeholder { color: #8a857b; }
[data-theme="dark"] .list-group-item { background: #201d17; color: #ece8e0; }
[data-theme="dark"] .list-group-item-action:hover { background: #2b271e; }
[data-theme="dark"] .dropdown-menu { background: #201d17; color: #ece8e0; border-color: var(--border); }
[data-theme="dark"] .dropdown-item { color: #ece8e0; }
[data-theme="dark"] .dropdown-item:hover { background: #2b271e; color: #fff; }
[data-theme="dark"] .alert { background: #221f19; color: #ece8e0; border-color: var(--border); }
[data-theme="dark"] .page-link { background: #201d17; border-color: var(--border); color: #ece8e0; }
[data-theme="dark"] .toast { background: #201d17; color: #ece8e0; }
[data-theme="dark"] hr { border-color: var(--border); opacity: 1; }
[data-theme="dark"] .text-muted { color: #9b958a !important; }
[data-theme="dark"] .cal-ev { color: #ece8e0; }

/* ============================================================ Density */
[data-density="compact"] body { font-size: .875rem; }
[data-density="compact"] .content { padding: 1.15rem; }
[data-density="compact"] .card-body { padding: .85rem; }
[data-density="compact"] .table td, [data-density="compact"] .table th { padding-top: .3rem; padding-bottom: .3rem; }
[data-density="compact"] .cal-cell { height: 92px; }

/* ============================================================ Kanban board */
.board { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: 1rem; }
.board-col { flex: 0 0 262px; background: var(--parchment); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.board-col h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: .7rem .8rem .2rem; margin: 0; display: flex; justify-content: space-between; align-items: center; }
.board-col .coltotal { padding: 0 .8rem .55rem; font-size: .74rem; color: var(--mid); border-bottom: 1px solid var(--border); }
.board-col .drop { padding: .6rem; min-height: 140px; flex: 1; }
.board-card { background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: var(--radius); padding: .55rem .65rem; margin-bottom: .55rem; cursor: grab; }
.board-card:active { cursor: grabbing; }
.board-card .nm { font-weight: 600; font-size: .84rem; }
.board-card .nm a { color: var(--ink); }
.board-card .meta { font-size: .73rem; color: var(--mid); }
.board-col.dragover .drop { background: rgba(184,146,42,.08); outline: 2px dashed var(--gold); outline-offset: -6px; }
[data-theme="dark"] .board-col { background: #1c1a14; }
[data-theme="dark"] .board-card { background: #201d17; }

/* ============================================================ Integration console */
.codeblock { background: var(--ink); color: #e8e3d8; border-radius: var(--radius); padding: .9rem 1rem; font-size: .78rem; line-height: 1.55; overflow: auto; white-space: pre; margin: 0; }
.keychip { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--parchment); border: 1px solid var(--border); padding: .25rem .55rem; border-radius: var(--radius); font-size: .82rem; word-break: break-all; }
[data-theme="dark"] .keychip { background: #15130e; }
.dot-live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2bb673; margin-right: .35rem; animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
