
:root {
  --navy: #14304a;
  --navy-2: #1c3f5f;
  --teal: #12857a;
  --teal-soft: #e5f4f2;
  --ink: #1e2a36;
  --muted: #6b7a89;
  --line: #e3e8ee;
  --bg: #f4f6f9;
  --card: #ffffff;
  --sidebar-w: 248px;
  --bs-primary: #12857a;
  --bs-primary-rgb: 18, 133, 122;
  --bs-link-color: #0f6f66;
  --bs-link-color-rgb: 15, 111, 102;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-font-size: .9rem;
  --bs-body-color: #1e2a36;
}

body { background: var(--bg); color: var(--ink); }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--teal); --bs-btn-border-color: var(--teal); --bs-btn-hover-bg: #0e6e65; --bs-btn-hover-border-color: #0e6e65; --bs-btn-active-bg: #0b5d55; --bs-btn-disabled-bg: var(--teal); --bs-btn-disabled-border-color: var(--teal); }
.btn-outline-primary { --bs-btn-color: var(--teal); --bs-btn-border-color: var(--teal); --bs-btn-hover-bg: var(--teal); --bs-btn-hover-border-color: var(--teal); --bs-btn-active-bg: var(--teal); }
.text-bg-primary { background-color: var(--teal) !important; }
.form-control:focus, .form-select:focus { border-color: #7cc5bd; box-shadow: 0 0 0 .2rem rgba(18,133,122,.15); }
.form-label { font-weight: 600; font-size: .8rem; color: #445566; margin-bottom: .25rem; }
.form-label .req { color: #d63939; }
.form-control, .form-select { font-size: .875rem; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #c7d4e1; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--teal); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; color: #fff; }
.brand-text { font-weight: 700; line-height: 1.1; font-size: .95rem; }
.brand-text small { display: block; font-weight: 500; font-size: .7rem; color: #8fb3c9; letter-spacing: .12em; text-transform: uppercase; }
.side-nav { padding: .75rem .6rem; overflow-y: auto; flex: 1; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #7d93a8; padding: .9rem .75rem .35rem; display: flex; justify-content: space-between; align-items: center; }
.nav-label .soon { font-size: .6rem; background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 6px; letter-spacing: .04em; }
.side-nav a, .side-nav .disabled-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px; color: #c7d4e1; font-weight: 500; margin-bottom: 2px; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: var(--teal); color: #fff; }
.side-nav .disabled-link { opacity: .45; cursor: not-allowed; }
.side-nav i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-count { margin-left: auto; background: #e8590c; color: #fff; font-size: .7rem; padding: 0 7px; border-radius: 10px; font-weight: 700; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1030; }
.top-search { flex: 1; max-width: 520px; position: relative; }
.top-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: .45rem .8rem .45rem 2.2rem; font-size: .85rem; }
.top-search input:focus { outline: none; border-color: #7cc5bd; background: #fff; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.btn-icon { width: 38px; height: 38px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 1.15rem; color: #4a5a6a; border: 0; background: transparent; }
.btn-icon:hover { background: var(--bg); }
.dot-badge { position: absolute; top: 3px; right: 2px; background: #e03131; color: #fff; font-size: .62rem; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: .55rem; border: 0; padding: .25rem .5rem; border-radius: 10px; }
.user-chip:hover { background: var(--bg); }
.user-chip b { display: block; font-size: .82rem; line-height: 1.1; }
.user-chip small { display: block; font-size: .7rem; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-weight: 700; }
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: .6rem; align-items: flex-start; white-space: normal; padding: .55rem 1rem; }
.notif b { display: block; font-size: .82rem; font-weight: 600; }
.notif small { color: var(--muted); font-size: .74rem; }
.notif.due i { color: #e8590c; }
.content { padding: 1.4rem 1.5rem; flex: 1; }
.app-footer { padding: .8rem 1.5rem; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
  .content { padding: 1rem; }
}

/* ---------- Page elements ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; color: var(--navy); }
.page-head .sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; padding: .8rem 1rem; border-radius: 12px 12px 0 0 !important; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-header h6 { margin: 0; font-weight: 700; font-size: .9rem; color: var(--navy); }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--teal); font-weight: 700; margin: .25rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--line); }

.table { --bs-table-hover-bg: #f6faf9; margin-bottom: 0; }
.table > thead th { background: #f7f9fb; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6b7b; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; padding: .6rem .75rem; }
.table td { padding: .6rem .75rem; vertical-align: middle; border-color: #eef1f4; }
.table .num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.lead-link { font-weight: 600; color: var(--navy); }
.lead-link:hover { color: var(--teal); }
.tiny { font-size: .74rem; color: var(--muted); }
.nowrap { white-space: nowrap; }

.stage-badge { background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 80%, black); border: 1px solid color-mix(in srgb, var(--c) 30%, white); font-weight: 600; }

.filters { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; }
.filters .form-control, .filters .form-select { font-size: .82rem; }

/* KPI tiles */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; height: 100%; display: flex; gap: .9rem; align-items: center; color: inherit; }
a.kpi:hover { border-color: #9fd3cc; }
.kpi .ic { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.kpi .v { font-size: 1.45rem; font-weight: 700; line-height: 1.1; color: var(--navy); }
.kpi .l { font-size: .76rem; color: var(--muted); font-weight: 500; }
.ic-teal { background: var(--teal-soft); color: var(--teal); }
.ic-blue { background: #e7f0fb; color: #2463b5; }
.ic-orange { background: #fdf0e4; color: #d9640e; }
.ic-red { background: #fde8e8; color: #c92a2a; }
.ic-green { background: #e6f6ea; color: #2b8a3e; }
.ic-purple { background: #f0ebfb; color: #6741d9; }

.bar-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: .75rem; align-items: center; padding: .35rem 0; font-size: .82rem; }
.bar-track { background: #eef2f5; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--teal); }

/* Pipeline board */
.board { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.board-col { flex: 0 0 270px; background: #eaeef2; border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.board-col-head { padding: .7rem .85rem; border-top: 4px solid var(--c); border-radius: 12px 12px 0 0; background: #fff; }
.board-col-head b { font-size: .85rem; }
.board-col-head .meta { font-size: .74rem; color: var(--muted); display: flex; justify-content: space-between; margin-top: 2px; }
.board-cards { padding: .6rem; overflow-y: auto; flex: 1; min-height: 80px; }
.board-cards.drag-over { background: #dfe9ee; }
.deal { background: #fff; border-radius: 9px; padding: .65rem .75rem; margin-bottom: .55rem; border: 1px solid var(--line); cursor: grab; font-size: .8rem; }
.deal:hover { border-color: #9fd3cc; }
.deal .t { font-weight: 600; color: var(--navy); display: block; }
.deal .m { color: var(--muted); font-size: .74rem; display: flex; justify-content: space-between; margin-top: 4px; gap: .5rem; }
.deal .overdue { color: #c92a2a; font-weight: 600; }

/* Lead view */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem 1.25rem; }
.info-grid .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.info-grid .v { font-weight: 500; word-break: break-word; }
.stage-track { display: flex; gap: 4px; overflow-x: auto; }
.stage-track .st { flex: 1; min-width: 92px; text-align: center; font-size: .7rem; font-weight: 600; padding: .45rem .3rem; background: #edf1f4; color: #6b7a89; position: relative; white-space: nowrap; }
.stage-track .st:first-child { border-radius: 8px 0 0 8px; }
.stage-track .st:last-child { border-radius: 0 8px 8px 0; }
.stage-track .st.done { background: #cfe9e5; color: #0e6e65; }
.stage-track .st.cur { background: var(--teal); color: #fff; }
.stage-track .st.lost { background: #c92a2a; color: #fff; }
.stage-track .st.hold { background: #f59f00; color: #fff; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1.1rem 1.6rem; border-left: 2px solid #e3e8ee; margin-left: .45rem; }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--teal); }
.timeline .when { font-size: .74rem; color: var(--muted); }
.timeline .body { background: #f8fafb; border: 1px solid var(--line); border-radius: 9px; padding: .6rem .8rem; margin-top: .3rem; }

.nav-tabs .nav-link { color: #5b6b7b; font-weight: 600; font-size: .85rem; }
.nav-tabs .nav-link.active { color: var(--teal); border-bottom-color: #fff; }
.nav-pills .nav-link.active { background: var(--teal); }
.nav-pills .nav-link { color: #4a5a6a; font-weight: 600; font-size: .85rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.5rem; color: #b8c4cf; display: block; margin-bottom: .6rem; }

.dup-box { border: 1px solid #ffd8a8; background: #fff8ef; border-radius: 10px; padding: .7rem .9rem; font-size: .82rem; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 15% 20%, #1c4d6b 0, transparent 45%), linear-gradient(135deg, #0f2a40, #14304a 55%, #0f5f58); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .brand-mark { width: 46px; height: 46px; font-size: 1.35rem; }

/* Quotation print */
.quote-doc { background: #fff; max-width: 900px; margin: 0 auto; padding: 2rem; border: 1px solid var(--line); border-radius: 12px; }
.quote-doc table th, .quote-doc table td { font-size: .82rem; }
@media print {
  .sidebar, .topbar, .app-footer, .no-print, .alert { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .quote-doc { border: 0; padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
}

.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.items-table input, .items-table select { font-size: .8rem; padding: .3rem .45rem; }
