/* ================================================================
   CustomerPaymentApp - site.css
   Theme: Dark (default) + Light mode via [data-theme="light"]
   Font: IBM Plex Sans + IBM Plex Mono
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---- Reset ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }

/* ================================================================
   DARK THEME (default)
   ================================================================ */
:root,
[data-theme="dark"] {
  --bg:          #0f1117;
  --bg2:         #161b27;
  --bg3:         #1e2535;
  --bg4:         #253047;
  --border:      #2a3347;
  --border2:     #3a4a67;
  --text:        #e2e8f4;
  --text2:       #8a9bbf;
  --text3:       #5a6a8a;
  --text4:       #3a4a67;
  --accent:      #3b82f6;
  --accent-h:    #2563eb;
  --accent2:     #60a5fa;
  --green:       #22c55e;
  --green-bg:    rgba(34,197,94,.12);
  --green-bd:    rgba(34,197,94,.25);
  --red:         #ef4444;
  --red-bg:      rgba(239,68,68,.12);
  --red-bd:      rgba(239,68,68,.25);
  --yellow:      #f59e0b;
  --yellow-bg:   rgba(245,158,11,.12);
  --shadow:      0 1px 3px rgba(0,0,0,.5);
  --icon-dark-display:  inline;
  --icon-light-display: none;
  --toggle-bg:         #1e2535;
  --toggle-border:     #3a4a67;
  --toggle-color:      #8a9bbf;
  --toggle-hover-bg:   #253047;
}

/* ================================================================
   LIGHT THEME
   ================================================================ */
[data-theme="light"] {
  --bg:          #f0f2f7;
  --bg2:         #ffffff;
  --bg3:         #f5f7fb;
  --bg4:         #e8ecf5;
  --border:      #d0d7e8;
  --border2:     #b0bdd6;
  --text:        #1a2035;
  --text2:       #4a5a7a;
  --text3:       #7a8aaa;
  --text4:       #b0bdd6;
  --accent:      #2563eb;
  --accent-h:    #1d4ed8;
  --accent2:     #1d4ed8;
  --green:       #16a34a;
  --green-bg:    rgba(22,163,74,.08);
  --green-bd:    rgba(22,163,74,.25);
  --red:         #dc2626;
  --red-bg:      rgba(220,38,38,.08);
  --red-bd:      rgba(220,38,38,.25);
  --yellow:      #d97706;
  --yellow-bg:   rgba(217,119,6,.08);
  --shadow:      0 1px 3px rgba(0,0,0,.10);
  --icon-dark-display:  none;
  --icon-light-display: inline;
  --toggle-bg:         #e8ecf5;
  --toggle-border:     #b0bdd6;
  --toggle-color:      #4a5a7a;
  --toggle-hover-bg:   #d0d7e8;
}

/* ---- Smooth transitions on theme switch ----------------------- */
body, .app-header, .panel, .grid-panel, .summary-item,
.data-table th, .data-table td, input, select, textarea,
.btn, .badge, .alert, .delete-card, .tab-btn {
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

/* ---- Base ----------------------------------------------------- */
body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header --------------------------------------------------- */
.app-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
}
.header-inner {
  max-width: 1500px; margin: 0 auto; padding: 0 28px;
  display: flex; align-items: center; height: 54px; gap: 0;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: 32px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; letter-spacing: -.5px;
}
.brand-name { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.3px; }
.brand-name span { color: var(--accent2); }
.main-nav { display: flex; gap: 2px; }
.nav-link {
  padding: 6px 14px; border-radius: 4px; color: var(--text2);
  font-size: 13px; font-weight: 500; text-decoration: none;
  border: 1px solid transparent; transition: all .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.nav-link.active { color: var(--accent2); background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.2); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px;
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text2);
  font-family: 'IBM Plex Mono', monospace;
}

/* ---- Theme Toggle Button -------------------------------------- */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 6px;
  background: var(--toggle-bg); border: 1px solid var(--toggle-border);
  color: var(--toggle-color); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: background .15s, border-color .15s, color .15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--toggle-hover-bg); color: var(--text); border-color: var(--border2); }
.theme-icon-dark  { display: var(--icon-dark-display); }
.theme-icon-light { display: var(--icon-light-display); }

/* ---- Main ----------------------------------------------------- */
.app-main { max-width: 1500px; margin: 0 auto; padding: 28px; }

/* ---- Alerts --------------------------------------------------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 8px; margin-bottom: 20px;
  font-size: 13px; border: 1px solid; animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.alert-success { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.alert-error   { background: var(--red-bg);   border-color: var(--red-bd);   color: var(--red); }
.alert-icon    { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.alert-close   { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 16px; line-height: 1; padding: 0 2px; }
.alert-close:hover { opacity: 1; }

/* ---- Page header ---------------------------------------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title  { font-size: 22px; font-weight: 600; letter-spacing: -.5px; line-height: 1.2; }
.page-subtitle { font-size: 12px; color: var(--text2); margin-top: 3px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ---- Breadcrumb ----------------------------------------------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text2); margin-bottom: 18px; }
.breadcrumb a { color: var(--accent2); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text4); font-size: 10px; }
.breadcrumb-current { color: var(--text); }

/* ---- Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 4px;
  font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1; transition: all .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: var(--bg4); }
.btn-danger    { background: transparent; color: var(--red); border-color: var(--red-bd); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost     { background: transparent; color: var(--text2); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-sm  { padding: 5px 11px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; }
.btn-icon { padding: 7px 9px; }

/* ---- Search bar ----------------------------------------------- */
.search-form  { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; }
.search-wrap  { position: relative; flex: 1; max-width: 400px; }
.search-icon  { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 14px; pointer-events: none; }
.search-input { width: 100%; background: var(--bg2); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 8px 12px 8px 32px; font-family: 'IBM Plex Sans', sans-serif; font-size: 13px; transition: border-color .15s; outline: none; }
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }
.search-count { font-size: 12px; color: var(--text2); white-space: nowrap; }

/* ---- Grid / Table --------------------------------------------- */
.grid-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table   { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--bg3); }
.data-table th {
  padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase; color: var(--text2);
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.data-table th a { color: var(--text2); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.data-table th a:hover { color: var(--text); }
.data-table th.sorted a { color: var(--accent2); }
.sort-arrow { font-size: 9px; opacity: .7; }
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; cursor: pointer; }
.data-table tbody tr:hover td { background: rgba(59,130,246,.04); }
.col-name    { font-weight: 500; }
.col-mono    { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text2); }
.col-amt     { font-family: 'IBM Plex Mono', monospace; font-weight: 500; color: var(--green); }
.col-actions { white-space: nowrap; }
.col-actions .btn + .btn { margin-left: 3px; }
.check-yes { color: var(--green); font-weight: 600; font-size: 14px; }
.check-no  { color: var(--text4); }
.empty-state { text-align: center; padding: 64px 20px; }
.empty-icon {
  width: 48px; height: 48px; border-radius: 50%; background: var(--bg3);
  border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; margin: 0 auto 16px; font-size: 20px; color: var(--text3);
}
.empty-state h3 { font-size: 15px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; color: var(--text3); }

/* ---- Badges --------------------------------------------------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-blue   { background: rgba(59,130,246,.15); color: var(--accent2);  border: 1px solid rgba(59,130,246,.25); }
.badge-green  { background: var(--green-bg);      color: var(--green);    border: 1px solid var(--green-bd); }
.badge-yellow { background: var(--yellow-bg);     color: var(--yellow);   border: 1px solid rgba(245,158,11,.25); }
.badge-red    { background: var(--red-bg);        color: var(--red);      border: 1px solid var(--red-bd); }
.badge-gray   { background: var(--bg3);           color: var(--text2);    border: 1px solid var(--border); }
.badge-purple { background: rgba(168,85,247,.12); color: #a855f7;         border: 1px solid rgba(168,85,247,.25); }

/* ---- Summary bar ---------------------------------------------- */
.summary-bar { display: flex; gap: 1px; flex-wrap: wrap; background: var(--border); border-radius: 8px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 22px; }
.summary-item { flex: 1; min-width: 130px; background: var(--bg2); padding: 16px 20px; }
.summary-label { font-size: 10px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text3); margin-bottom: 6px; }
.summary-value { font-size: 22px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; line-height: 1; }
.summary-value.green  { color: var(--green); }
.summary-value.blue   { color: var(--accent2); }
.summary-value.yellow { color: var(--yellow); }
.summary-value.text   { font-family: 'IBM Plex Sans', sans-serif; font-size: 14px; font-weight: 500; }

/* ---- Panel ---------------------------------------------------- */
.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 22px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.panel-title    { font-size: 13px; font-weight: 600; }
.panel-subtitle { font-size: 12px; color: var(--text2); margin-top: 2px; }
.panel-body     { padding: 22px; }
.panel-footer   { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; background: var(--bg3); }

/* ---- Tabs ----------------------------------------------------- */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn { padding: 11px 18px; font-size: 13px; font-weight: 500; color: var(--text2); background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; margin-bottom: -1px; font-family: 'IBM Plex Sans', sans-serif; transition: color .15s, border-color .15s; }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent); }
.tab-btn .tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10px; font-weight: 600; margin-left: 6px; background: var(--bg3); color: var(--text2); }
.tab-btn.active .tab-count { background: rgba(59,130,246,.2); color: var(--accent2); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- Detail layout -------------------------------------------- */
.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.detail-section { margin-bottom: 24px; }
.detail-section-title { font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--accent2); margin-bottom: 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.detail-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; margin-bottom: 9px; align-items: start; }
.detail-label { font-size: 12px; color: var(--text2); padding-top: 1px; }
.detail-value { font-size: 13px; font-weight: 500; word-break: break-word; }

/* ---- Forms ---------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px 22px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full  { grid-column: 1 / -1; }
.form-group.span2 { grid-column: span 2; }
.form-section-title { grid-column: 1 / -1; font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--accent2); padding-top: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.form-section-title:first-child { padding-top: 0; }
label { font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--text2); }
.label-required::after { content: ' *'; color: var(--red); font-weight: 400; }
input[type="text"], input[type="date"], input[type="number"], input[type="tel"], input[type="email"], select, textarea {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 4px;
  padding: 8px 12px; font-family: 'IBM Plex Sans', sans-serif; font-size: 13px;
  outline: none; width: 100%; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s, background .2s, color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--border2); }
input::placeholder, textarea::placeholder { color: var(--text3); }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6a8a' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
select option { background: var(--bg3); color: var(--text); }
textarea { resize: vertical; min-height: 80px; }
input[type="number"] { font-family: 'IBM Plex Mono', monospace; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.5); cursor: pointer; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.checkbox-row label { font-size: 13px; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: 0; cursor: pointer; padding: 0; }
.field-validation-error, .field-error { font-size: 11px; color: var(--red); margin-top: 3px; display: block; }
.input-validation-error { border-color: var(--red-bd) !important; }
.validation-summary-errors { background: var(--red-bg); border: 1px solid var(--red-bd); border-radius: 4px; padding: 12px 16px; margin-bottom: 20px; color: var(--red); font-size: 13px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-errors li { margin-top: 4px; }
.validation-summary-valid { display: none; }
.form-actions { display: flex; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); align-items: center; }
.form-actions-note { font-size: 12px; color: var(--text3); margin-left: auto; }

/* ---- Delete confirm ------------------------------------------- */
.delete-page { max-width: 520px; margin: 40px auto; padding: 0 16px; }
.delete-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 36px; text-align: center; }
.delete-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--red-bg); border: 1px solid var(--red-bd); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 22px; color: var(--red); }
.delete-title   { font-size: 19px; font-weight: 600; margin-bottom: 10px; }
.delete-message { font-size: 13px; color: var(--text2); margin-bottom: 8px; line-height: 1.6; }
.delete-warning { font-size: 12px; color: var(--red); background: var(--red-bg); border: 1px solid var(--red-bd); border-radius: 4px; padding: 9px 14px; margin: 16px 0 24px; }
.delete-actions { display: flex; gap: 10px; justify-content: center; }
.delete-record-info { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 12px 16px; text-align: left; margin: 16px 0; }
.delete-record-info .info-row { display: flex; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.delete-record-info .info-row:last-child { margin-bottom: 0; }
.delete-record-info .lbl { color: var(--text2); min-width: 110px; }
.delete-record-info .val { font-weight: 500; }

/* ---- Extras --------------------------------------------------- */
.pay-total-row td { border-top: 2px solid var(--border2) !important; background: var(--bg3) !important; font-weight: 600; }
.pay-total-row .col-amt { font-size: 14px; }
.add-payment-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; }
.add-payment-panel .panel-header { background: var(--bg3); border-radius: 8px 8px 0 0; }

/* ---- Utilities ------------------------------------------------ */
.text-muted { color: var(--text2); }
.text-xs    { font-size: 11px; }
.text-sm    { font-size: 12px; }
.text-mono  { font-family: 'IBM Plex Mono', monospace; }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-yellow{ color: var(--yellow); }
.text-accent{ color: var(--accent2); }
.fw-600     { font-weight: 600; }
.mb-16      { margin-bottom: 16px; }
.mb-22      { margin-bottom: 22px; }
.ms-auto    { margin-left: auto; }

/* ---- Scrollbar ------------------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ---- Theme toggle text labels --------------------------------- */
.theme-icon-dark,
.theme-icon-light {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ---- Alert icon fix ------------------------------------------ */
.alert-icon {
  font-size: 12px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alert-success .alert-icon {
  background: var(--green);
  color: #fff;
}
.alert-error .alert-icon {
  background: var(--red);
  color: #fff;
}

/* ---- Delete icon fix ------------------------------------------ */
.delete-icon {
  font-size: 28px;
  font-weight: 700;
  color: var(--red);
}

/* ---- Breadcrumb sep ------------------------------------------- */
.breadcrumb-sep {
  color: var(--text4);
  font-size: 12px;
  font-weight: 400;
}

/* ---- Search icon --------------------------------------------- */
.search-icon {
  font-size: 13px;
  font-style: normal;
}

/* ---- Check yes / No style ------------------------------------ */
.check-yes::before { content: "Yes"; }
.check-no::before  { content: "No";  }

/* ---- Multi-select checkbox group ----------------------------- */
.checkbox-multi {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
}
.cb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.cb-item:last-child { border-bottom: none; }
.cb-item:hover { background: var(--bg4); }
.cb-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}
.cb-item input[type="checkbox"]:checked + span {
  color: var(--accent2);
  font-weight: 500;
}

/* ---- Communication Timeline ---------------------------------- */
.comm-timeline { display: flex; flex-direction: column; gap: 10px; }

.comm-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: var(--radius2);
  padding: 14px 16px;
  transition: border-color .15s;
}
.comm-phone  { border-left-color: #3b82f6; }
.comm-email  { border-left-color: #a855f7; }
.comm-task   { border-left-color: #f59e0b; }
.comm-overdue { border-left-color: var(--red); background: rgba(239,68,68,.05); }

.comm-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 12px; margin-bottom: 6px;
}
.comm-meta   { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comm-date   { white-space: nowrap; flex-shrink: 0; }

.comm-type-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .4px;
}
.comm-phone .comm-type-badge { background: rgba(59,130,246,.15);  color: #60a5fa; border-color: rgba(59,130,246,.25); }
.comm-email .comm-type-badge { background: rgba(168,85,247,.15);  color: #c084fc; border-color: rgba(168,85,247,.25); }
.comm-task  .comm-type-badge { background: rgba(245,158,11,.15);  color: #fcd34d; border-color: rgba(245,158,11,.25); }

.comm-subject {
  font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.comm-body {
  font-size: 12px; color: var(--text2);
  line-height: 1.5; margin-bottom: 8px;
  white-space: pre-wrap;
}
.comm-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.comm-docs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}

/* ---- Document chip ------------------------------------------- */
.doc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px 10px;
  font-size: 12px;
}
.doc-chip a { color: var(--accent2); text-decoration: none; }
.doc-chip a:hover { text-decoration: underline; }
.doc-del {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 12px; padding: 0 2px;
  line-height: 1;
}
.doc-del:hover { color: var(--red); }

/* ================================================================
   v2.0 — Dashboard, Live Search, Inline Edit, Richer Detail
   ================================================================ */

/* ---- Customer avatar ------------------------------------------ */
.cust-avatar {
  width: 52px; height: 52px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  flex-shrink: 0; letter-spacing: -1px;
}

/* ---- Summary bar danger state --------------------------------- */
.summary-item-danger { background: var(--red-bg) !important; }

/* ---- KPI grid ------------------------------------------------- */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.kpi-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px;
  transition: border-color .15s;
}
.kpi-card:hover { border-color: var(--border2); }
.kpi-label {
  font-size: 10px; font-weight: 600; letter-spacing: .7px;
  text-transform: uppercase; color: var(--text3); margin-bottom: 8px;
}
.kpi-value {
  font-size: 26px; font-weight: 600; font-family: 'IBM Plex Mono', monospace;
  line-height: 1; margin-bottom: 6px;
}
.kpi-sub { font-size: 11px; color: var(--text3); }

/* ---- Dashboard two-col row ------------------------------------ */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px; margin-bottom: 22px;
}
@media (max-width: 900px) {
  .dash-row { grid-template-columns: 1fr; }
}
.dash-panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.dash-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.dash-panel-title {
  font-size: 12px; font-weight: 600; letter-spacing: .3px; color: var(--text2);
}
.dash-link { font-size: 12px; color: var(--accent2); text-decoration: none; }
.dash-link:hover { text-decoration: underline; }

/* ---- Bar chart ------------------------------------------------ */
.dash-chart-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 18px 20px 14px; height: 85%;
}
.chart-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 6px; height: 100%;
}
.chart-val {
  font-size: 10px; color: var(--text3); font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap; min-height: 14px;
}
.chart-bar-wrap {
  flex: 1; width: 100%; display: flex; align-items: flex-end; min-height: 60px;
}
.chart-bar {
  width: 100%; border-radius: 4px 4px 0 0;
  background: var(--bg4); min-height: 4px;
  transition: background .2s;
}
.chart-bar-current { background: var(--accent) !important; }
.chart-label { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ---- Dashboard list ------------------------------------------- */
.dash-list { display: flex; flex-direction: column; }
.dash-list-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; transition: background .1s;
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-item:hover { background: var(--bg3); text-decoration: none; }
.dash-list-item-danger .dli-name { color: var(--red); }
.dli-name { font-size: 13px; font-weight: 500; color: var(--text); }
.dli-meta { flex-shrink: 0; }

.dash-empty {
  padding: 32px 20px; text-align: center;
  color: var(--text3); font-size: 13px;
}
.dash-empty-icon { font-size: 24px; margin-bottom: 8px; color: var(--green); }

/* ---- Dashboard table ------------------------------------------ */
.dash-table { width: 100%; border-collapse: collapse; }
.dash-table th {
  padding: 8px 16px; font-size: 10px; font-weight: 600;
  letter-spacing: .6px; text-transform: uppercase;
  color: var(--text3); border-bottom: 1px solid var(--border);
  background: var(--bg3); text-align: left;
}
.dash-table td {
  padding: 9px 16px; font-size: 12px; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover td { background: rgba(59,130,246,.04); }

/* ---- Activity feed -------------------------------------------- */
.dash-activity { display: flex; flex-direction: column; }
.act-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  text-decoration: none; transition: background .1s;
}
.act-item:last-child { border-bottom: none; }
.act-item:hover { background: var(--bg3); text-decoration: none; }
.act-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
  background: var(--border2);
}
.act-phone { background: #3b82f6; }
.act-email { background: #a855f7; }
.act-task  { background: #f59e0b; }
.act-overdue { background: var(--red); }
.act-body { flex: 1; min-width: 0; }
.act-name { font-size: 12px; font-weight: 500; color: var(--text); }
.act-subject { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-date { font-size: 11px; color: var(--text3); flex-shrink: 0; }

/* ---- Live search v2 ------------------------------------------- */
.search-bar-v2 { margin-bottom: 18px; }
.search-wrap { position: relative; display: flex; align-items: center; max-width: 520px; }
.search-input { padding-right: 32px; }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px;
}
.search-clear:hover { color: var(--text); }
.search-filters { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.filter-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; cursor: pointer;
  transition: all .15s; user-select: none; text-transform: none; letter-spacing: 0;
}
.filter-chip:hover { border-color: var(--border2); color: var(--text); }
.filter-chip input { accent-color: var(--accent); cursor: pointer; }

/* ---- Row states ----------------------------------------------- */
.row-overdue td { background: rgba(239,68,68,.07) !important; }

/* ---- Table footer --------------------------------------------- */
.table-footer {
  padding: 8px 16px; border-top: 1px solid var(--border);
  background: var(--bg3);
}

/* ---- Inline edit ---------------------------------------------- */
.inline-edit-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}

/* ---- fw-500 utility ------------------------------------------- */
.fw-500 { font-weight: 500; }

/* ---- Pagination ----------------------------------------------- */
.pager-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 0; flex-wrap: wrap;
}
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  border-radius: var(--border-radius-md, 4px);
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--text2); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: 'IBM Plex Sans', sans-serif;
  transition: all .15s;
}
.pager-btn:hover:not(:disabled) { background: var(--bg3); border-color: var(--border2); color: var(--text); }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-btn-active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.pager-ellipsis { color: var(--text3); font-size: 12px; padding: 0 4px; }

/* ---- Auth form fields (login-field) --------------------------- */
/* Used on Login, EditUser, ChangePassword password inputs        */
.login-field { margin-bottom: 18px; }
.login-field label {
    display: block;
    font-size: 11px; font-weight: 600;
    letter-spacing: .5px; text-transform: uppercase;
    color: var(--text2); margin-bottom: 7px;
}
.login-field input {
    width: 100%; box-sizing: border-box;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'IBM Plex Sans', sans-serif;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.login-field input:hover:not(:focus) {
    border-color: var(--border2);
}
.login-field .field-validation-error {
    font-size: 11px; color: var(--red);
    margin-top: 5px; display: block;
}
