/* ─────────────────────────────────────────────────────────────────────────
   Ptera Portal — Dark-Steel Theme
   ─────────────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --surface:     #1a1f2e;
  --surface2:    #222738;
  --surface3:    #2b3250;
  --border:      #2e3454;
  --primary:     #3a7bd5;
  --primary-h:   #4e8fea;
  --accent-green:#27ae60;
  --accent-amber:#f39c12;
  --accent-red:  #e74c3c;
  --accent-blue: #2980b9;
  --text:        #dce4f5;
  --text-dim:    #8a93b2;
  --radius:      6px;
  --radius-sm:   4px;
  --font:        "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono:   "JetBrains Mono", "Fira Code", monospace;
  --nav-h:       52px;
  --shadow:      0 2px 12px rgba(0,0,0,.45);
}

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

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); text-decoration: underline; }

.muted { color: var(--text-dim); font-size: .85em; }
.empty-state { color: var(--text-dim); font-style: italic; padding: .6rem 0; text-align: center; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface3); }

/* ──────────────────────────────────────────────────────────────────────
   TOP NAV
   ────────────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}
.brand-logo {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

.nav-links { display: flex; gap: .1rem; flex: 1; }
.nav-link {
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration:none; }
.nav-link.active { color: var(--primary); background: rgba(58,123,213,.12); }

.nav-end { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.nav-user { font-size: .82rem; color: var(--text-dim); }
.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: .25rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  transition: border-color .15s, color .15s;
}
.nav-btn:hover { border-color: var(--primary); color: var(--text); }

.phone-fab {
  background: var(--primary);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: .95rem;
  box-shadow: 0 2px 8px rgba(58,123,213,.5);
  transition: background .15s;
}
.phone-fab:hover { background: var(--primary-h); }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent-red);
  color: #fff;
  border-radius: 9px;
  font-size: .72rem;
  font-weight: 700;
  vertical-align: middle;
  margin-left: .3rem;
}

/* ──────────────────────────────────────────────────────────────────────
   PHONE DRAWER
   ────────────────────────────────────────────────────────────────────── */
.phone-drawer {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  width: 360px;
  height: calc(100vh - var(--nav-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  box-shadow: -4px 0 20px rgba(0,0,0,.5);
}
.phone-drawer[hidden] { display: none; }
.phone-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.phone-drawer-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

/* ──────────────────────────────────────────────────────────────────────
   PAGE WRAP + HEADER
   ────────────────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  flex: 1;
}
.back-link { color: var(--text-dim); font-size: .85rem; }

/* ──────────────────────────────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface3); border-color: var(--text-dim); text-decoration:none; color:var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); color:#fff; }
.btn-danger { background: var(--accent-red); border-color: var(--accent-red); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-sm { padding: .28rem .6rem; font-size: .8rem; }
.btn-xs { padding: .18rem .48rem; font-size: .76rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.float-right { float: right; }

/* ──────────────────────────────────────────────────────────────────────
   FLASH MESSAGES
   ────────────────────────────────────────────────────────────────────── */
.flash {
  padding: .6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
}
.flash--error, .flash--danger { background: rgba(231,76,60,.15); color:#e74c3c; border:1px solid #e74c3c44; }
.flash--success { background: rgba(39,174,96,.15); color:#27ae60; border:1px solid #27ae6044; }
.flash--warning { background: rgba(243,156,18,.15); color:#f39c12; border:1px solid #f39c1244; }

/* ──────────────────────────────────────────────────────────────────────
   TOOLBAR (search + filters row)
   ────────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: .4rem .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .88rem;
  outline: none;
}
.search-input:focus { border-color: var(--primary); }
.filter-select {
  padding: .38rem .65rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--primary); outline: none; }

/* ──────────────────────────────────────────────────────────────────────
   DATA TABLE
   ────────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.data-table th {
  text-align: left;
  padding: .55rem .85rem;
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,.03); }

/* ──────────────────────────────────────────────────────────────────────
   STAT GRID
   ────────────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  text-align: center;
}
.stat-val {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}
.stat-label { font-size: .78rem; color: var(--text-dim); margin-top: .35rem; }

.accent-green .stat-val { color: var(--accent-green); }
.accent-amber  .stat-val { color: var(--accent-amber); }
.accent-red    .stat-val { color: var(--accent-red); }
.accent-blue   .stat-val { color: var(--accent-blue); }

/* ──────────────────────────────────────────────────────────────────────
   PANELS + DASH COLUMNS
   ────────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel-title {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  margin-bottom: .75rem;
}
.panel-link { font-size: .82rem; color: var(--primary); }

.dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ──────────────────────────────────────────────────────────────────────
   ACTIVITY FEED
   ────────────────────────────────────────────────────────────────────── */
.activity-feed, .activity-feed-tall {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  font-size: .85rem;
}
.activity-icon { font-size: 1rem; flex-shrink:0; margin-top:.1rem; }
.activity-body { flex:1; }
.activity-summary { display:block; }
.activity-client { font-size:.8rem; color: var(--text-dim); }
.activity-time { font-size: .78rem; color: var(--text-dim); white-space:nowrap; }

/* ──────────────────────────────────────────────────────────────────────
   RENEWAL LIST
   ────────────────────────────────────────────────────────────────────── */
.renewal-list { list-style: none; display:flex; flex-direction:column; gap:.5rem; }
.renewal-item { display:flex; align-items:center; gap:.6rem; font-size:.88rem; }
.renewal-name { flex:1; }
.renewal-lob  { flex-shrink:0; }
.renewal-date { flex-shrink:0; }

/* ──────────────────────────────────────────────────────────────────────
   STAGE / LOB BADGES
   ────────────────────────────────────────────────────────────────────── */
.stage-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .03em;
  background: var(--surface3);
  color: var(--text-dim);
}
.stage-prospect         { background: #1a3a6e; color: #6fa8dc; }
.stage-quoted           { background: #3a2f1a; color: #f1c40f; }
.stage-bound            { background: #1a3a25; color: #2ecc71; }
.stage-active           { background: #0e3328; color: #27ae60; }
.stage-up-for-renewal   { background: #3a2a0a; color: #f39c12; }
.stage-lapsed           { background: #3a1a1a; color: #e74c3c; }
.stage-cancelled        { background: #2e1a2e; color: #9b59b6; }
.stage-dnc              { background: #2a1a1a; color: #c0392b; }
.stage-pending          { background: #1e2a3a; color: #5dade2; }
.stage-received         { background: #1a3a1a; color: #58d68d; }
.stage-declined         { background: #3a1a1a; color: #e74c3c; }
.stage-converted        { background: #0e3328; color: #27ae60; }

.tag {
  display: inline-block;
  padding: .12rem .45rem;
  border-radius: var(--radius-sm);
  font-size: .74rem;
  font-weight: 600;
  background: var(--surface3);
  color: var(--text-dim);
}
.tag--auto       { background:#13304d; color:#5dade2; }
.tag--home       { background:#1a3014; color:#58d68d; }
.tag--life       { background:#2d1a4a; color:#af7ac5; }
.tag--commercial { background:#3a2a0a; color:#f0b27a; }
.tag--umbrella   { background:#1a2a4a; color:#85c1e9; }
.tag--renters    { background:#1a3028; color:#76d7c4; }
.tag--flood      { background:#0d2a3a; color:#5dade2; }
.tag--other      { background:#2a2a2a; color:#aaa; }

/* ──────────────────────────────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 800px;
}
.form-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  margin: 1.1rem 0 .65rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .35rem;
}
.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  flex: 1;
  min-width: 160px;
  font-size: .85rem;
  color: var(--text-dim);
}
.form-group--wide { flex: 2; min-width: 320px; }
.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .4rem .7rem;
  font-size: .88rem;
  outline: none;
  font-family: var(--font);
  width: 100%;
}
.form-input:focus { border-color: var(--primary); }
.form-input--sm { padding: .22rem .5rem; font-size: .82rem; }
textarea.form-input { resize: vertical; }
select.form-input { cursor: pointer; }
.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}
.form-error { color: var(--accent-red); font-size: .85rem; margin-top: .5rem; }

/* ──────────────────────────────────────────────────────────────────────
   PAGER
   ────────────────────────────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1rem;
  justify-content: center;
}

/* ──────────────────────────────────────────────────────────────────────
   ITEM LIST (generic small list)
   ────────────────────────────────────────────────────────────────────── */
.item-list { list-style:none; display:flex; flex-direction:column; gap:.4rem; }
.item-list-row {
  display:flex;
  align-items:center;
  gap:.6rem;
  font-size:.85rem;
  padding:.35rem .5rem;
  border-radius:var(--radius-sm);
  background:var(--surface2);
}
.task-done { opacity: .5; text-decoration: line-through; }

/* ──────────────────────────────────────────────────────────────────────
   DETAIL LIST
   ────────────────────────────────────────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: .35rem .75rem;
  font-size: .86rem;
}
.detail-list dt { color: var(--text-dim); font-weight: 600; align-self: start; }
.detail-list .note-text { white-space: pre-wrap; }

/* ──────────────────────────────────────────────────────────────────────
   POLICY CARDS
   ────────────────────────────────────────────────────────────────────── */
.policy-cards { display:flex; flex-direction:column; gap:.5rem; }
.policy-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .84rem;
}
.pc-lob { flex-shrink:0; }
.pc-info { flex:1; display:flex; flex-direction:column; gap:.15rem; }
.pc-dates { font-size:.78rem; }

/* ──────────────────────────────────────────────────────────────────────
   MODAL
   ────────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  z-index: 500;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 96vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.modal-close {
  background:transparent; border:none; cursor:pointer;
  color:var(--text-dim); font-size:1.4rem; line-height:1;
}

/* ──────────────────────────────────────────────────────────────────────
   LOGIN
   ────────────────────────────────────────────────────────────────────── */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  width: 380px;
  max-width: 94vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-brand .brand-logo {
  width: 48px; height: 48px;
  font-size: 1.4rem;
  margin: 0 auto .5rem;
}
.login-brand h1 { font-size: 1.4rem; font-weight: 800; }
.login-form { display:flex; flex-direction:column; gap:.75rem; }
.login-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: .82rem;
  margin: 1rem 0;
  position: relative;
}
.login-divider::before, .login-divider::after {
  content:''; position:absolute; top:50%;
  width:42%; height:1px; background:var(--border);
}
.login-divider::before { left:0; }
.login-divider::after  { right:0; }

/* ──────────────────────────────────────────────────────────────────────
   CLIENT 360 — base
   ────────────────────────────────────────────────────────────────────── */
.c360-header { align-items: flex-start; }
.c360-actions { display:flex; gap:.5rem; flex-wrap:wrap; }

.c360-grid {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .c360-grid { grid-template-columns: 1fr 1fr; }
  .c360-policies { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .c360-grid { grid-template-columns: 1fr; }
}

/* ──────────────────────────────────────────────────────────────────────
   COMPOSE
   ────────────────────────────────────────────────────────────────────── */
.compose-tabs { display:flex; gap:.25rem; margin-bottom:.75rem; }
.compose-tab {
  padding:.3rem .8rem;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  background:var(--surface2);
  color:var(--text-dim);
  cursor:pointer; font-size:.82rem;
}
.compose-tab.active { background:var(--primary); border-color:var(--primary); color:#fff; }
.compose-status { font-size:.82rem; margin-top:.4rem; height:1rem; }

/* ──────────────────────────────────────────────────────────────────────
   ADMIN GRID
   ────────────────────────────────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

/* ──────────────────────────────────────────────────────────────────────
   PHONE LINK
   ────────────────────────────────────────────────────────────────────── */
.phone-link { color: var(--accent-green); }
.phone-link:hover { color:#2ecc71; }
.client-link { font-weight:600; }

@media (max-width: 900px) {
  .dash-columns { grid-template-columns: 1fr; }
  .admin-grid   { grid-template-columns: 1fr; }
}
