/* ═══════════════════════════════════════════════════
   ZYPELabs Invoice — Invoicely-style Design System
   Primary: var(--c-accent) (orange)  Sidebar: #2b2c3e (dark)
═══════════════════════════════════════════════════ */

/* ── Brand Color Variables (overridden dynamically via header) ── */
:root {
  --c-primary:       #2b2c3e;   /* sidebar background          */
  --c-accent:        var(--c-accent);   /* buttons, links, highlights  */
  --c-accent-hover:  var(--c-accent-hover);   /* accent darkened on hover    */
  --c-accent-alpha:  var(--c-accent-alpha);  /* active nav bg    */
  --c-accent-light:  var(--c-accent-light);  /* input focus glow */
  --c-accent-xlight: var(--c-accent-xlight);   /* very light accent bg        */
  --c-accent-footer: var(--c-accent-footer);   /* footer hover bg             */
  --c-btn-secondary: #6c757d;   /* secondary/gray buttons      */
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px; line-height: 1.5; color: #333;
  background: #f0f0f0;
  font-weight: 400;
}
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; }
img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────── */
.app-wrap  { display: flex; min-height: 100vh; }
.sidebar   {
  width: 170px; background: var(--c-primary); flex-shrink: 0;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  overflow-y: auto;
}
.main-wrap { flex: 1; margin-left: 170px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar    {
  background: #fff; border-bottom: 1px solid #e0e0e0;
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-body { padding: 24px; flex: 1; width: 100%; }

/* ── Sidebar Brand ───────────────────────────────── */
.sidebar-brand {
  padding: 12px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  color: #fff; cursor: default;
}
.sidebar-logo-icon {
  width: 28px; height: 28px; background: var(--c-accent); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 13px; color: #fff; flex-shrink: 0;
}
.sidebar-company {
  font-size: 12px; font-weight: 500; color: #fff;
  letter-spacing: 0; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100px;
}
.sidebar-caret {
  margin-left: auto; flex-shrink: 0;
  color: rgba(255,255,255,.4);
  width: 12px; height: 12px;
}
.sidebar-upgrade {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 8px 16px;
  color: rgba(255,255,255,.45); font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  transition: color .12s;
}
.sidebar-upgrade:hover { color: rgba(255,255,255,.75); }
.sidebar-upgrade svg { width: 13px; height: 13px; flex-shrink: 0; }
/* hidden — kept as class only */
.sidebar-upgrade-hidden {
  display: block; margin: 10px 16px;
  background: var(--c-accent); color: #fff;
  text-align: center; padding: 7px; border-radius: 5px;
  font-size: 12px; font-weight: 700; transition: background .15s;
}
.sidebar-upgrade-hidden:hover { background: var(--c-accent-hover); }

/* ── Sidebar Nav ─────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 6px 0; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13px; color: rgba(255,255,255,.65);
  transition: color .12s, background .12s;
}
.nav-link svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; background: var(--c-accent-alpha); border-left: 3px solid var(--c-accent); padding-left: 13px; }
.nav-link.nav-sub { padding: 7px 16px 7px 40px; font-size: 12px; color: rgba(255,255,255,.5); }
.nav-link.nav-sub svg { width: 13px; height: 13px; }
.nav-link.nav-sub:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.05); }
.nav-link.nav-sub.active { color: #fff; background: var(--c-accent-alpha); border-left: 3px solid var(--c-accent); padding-left: 37px; }

/* ── Sidebar Footer ──────────────────────────────── */
.sidebar-footer { padding: 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-help   {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; color: rgba(255,255,255,.4); font-size: 12px;
  transition: color .12s;
}
.sidebar-help:hover { color: rgba(255,255,255,.7); }
.sidebar-help svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Topbar ──────────────────────────────────────── */
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 17px; font-weight: 700; color: #222; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date  { font-size: 12px; color: #999; }

/* ── Notification Bell ───────────────────────────── */
.notif-wrap { position: relative; }
.notif-btn  {
  position: relative; background: none; border: none; cursor: pointer;
  color: #888; padding: 4px 6px; border-radius: 4px; line-height: 1;
  transition: color .15s, background .15s;
}
.notif-btn:hover { color: var(--c-accent); background: var(--c-accent-xlight); }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--c-accent); color: #fff; border-radius: 10px;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 310px; background: #fff; border: 1px solid #e0e0e0;
  border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 999; display: none;
}
.notif-wrap.open .notif-dropdown { display: block; }
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid #f0f0f0;
  font-size: 13px; font-weight: 600; color: #222;
}
.notif-item {
  display: flex; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid #f8f8f8;
  font-size: 12px; color: #333;
  transition: background .1s;
}
.notif-item:hover { background: #fafafa; }
.notif-icon { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.notif-text { flex: 1; }
.notif-empty { padding: 20px 14px; font-size: 12px; color: #aaa; text-align: center; }
.notif-footer {
  display: block; text-align: center; padding: 10px;
  font-size: 12px; color: var(--c-accent); border-top: 1px solid #f0f0f0;
  font-weight: 600;
}
.notif-footer:hover { background: var(--c-accent-footer); }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 4px;
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  transition: all .15s; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary  { background: var(--c-accent); color: #fff; }
.btn-primary:hover  { background: var(--c-accent-hover); color: #fff; }
.btn-secondary{ background: #fff; color: #555; border: 1px solid #ccc; }
.btn-secondary:hover{ background: #f8f8f8; }
.btn-danger   { background: #fff; color: #e74c3c; border: 1px solid #f5c6cb; }
.btn-danger:hover   { background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-gray { background: #6b7280; color: #fff; }
.btn-gray:hover { background: #555; }

/* ── Cards ───────────────────────────────────────── */
.card { background: #fff; border: 1px solid #e0e0e0; border-radius: 3px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #f5f5f5; border-bottom: 1px solid #e0e0e0;
}
.card-title { font-size: 13px; font-weight: 600; color: #333; }
.card-body  { padding: 16px; }

/* ── Dashboard Panels ────────────────────────────── */
.dash-grid-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid-mid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* At a Glance */
.at-a-glance-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid #f0f0f0; }
.at-a-glance-row:last-child { border-bottom: none; }
.aag-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; }
.aag-label svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.aag-value { font-size: 13px; font-weight: 600; color: #222; }

/* Recent Activity */
.activity-row { padding: 10px 16px; border-bottom: 1px solid #f5f5f5; font-size: 12px; color: #666; }
.activity-row:last-child { border-bottom: none; }
.activity-time { color: var(--c-accent); font-weight: 600; margin-right: 4px; }
.activity-link { color: #4a9fd4; }

/* Accounts Receivable */
.ar-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 16px; border-bottom: 1px solid #f5f5f5; }
.ar-row:last-child { border-bottom: none; }
.ar-name { font-size: 13px; color: #4a9fd4; }
.ar-amount { font-size: 13px; font-weight: 600; color: #333; }

/* ── Status Badges ───────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-draft      { background: #eee; color: #666; }
.badge-sent       { background: #fff3cd; color: #856404; }
.badge-paid       { background: #d4edda; color: #155724; }
.badge-overdue    { background: #f8d7da; color: #721c24; }
.badge-due        { background: #e74c3c; color: #fff; }
.badge-cancelled  { background: #f5e6e6; color: #922; }
.badge-archived   { background: #e8eaf0; color: #555; }

/* ── Tables ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 9px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: #888; background: #fafafa; border-bottom: 1px solid #e8e8e8; text-align: left;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f5f5f5; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Filter bar ──────────────────────────────────── */
.filter-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.filter-tabs { display: flex; gap: 0; border: 1px solid #ddd; border-radius: 4px; overflow: hidden; }
.filter-tab  { padding: 6px 14px; font-size: 12px; font-weight: 600; color: #666; background: #fff; border-right: 1px solid #ddd; transition: all .1s; }
.filter-tab:last-child { border-right: none; }
.filter-tab:hover  { background: #f5f5f5; }
.filter-tab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }

/* ── Search ──────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: #aaa; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search-input { padding: 6px 10px 6px 28px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; width: 200px; }
.search-input:focus { border-color: var(--c-accent); outline: none; }

/* ── Forms ───────────────────────────────────────── */
.form-group   { margin-bottom: 14px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 4px; }
.form-input   {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd;
  border-radius: 4px; font-size: 13px; color: #333; background: #fff;
  transition: border .12s;
}
.form-input:focus { border-color: var(--c-accent); outline: none; box-shadow: 0 0 0 2px var(--c-accent-light); }
.form-textarea { resize: vertical; min-height: 72px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 26px; }

/* ── Flash messages ──────────────────────────────── */
.flash { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 4px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.flash-error   { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.flash-warning { background: #fff3cd; border-color: #ffeeba; color: #856404; }

/* ── Action icons ────────────────────────────────── */
.action-icons { display: flex; align-items: center; gap: 10px; }
.action-icon  { color: #ccc; transition: color .12s; display: flex; }
.action-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.action-icon:hover      { color: var(--c-accent); }
.action-icon.edit:hover { color: #f59e0b; }
.action-icon.delete:hover { color: #e74c3c; }
.action-icon.download:hover { color: #10b981; }
.action-icon.email:hover    { color: #3b82f6; }

/* ── Status dropdown ─────────────────────────────── */
.status-dropdown { position: relative; display: inline-block; }
.status-dropdown-menu {
  position: absolute; left: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid #ddd; border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1); min-width: 140px;
  padding: 3px; z-index: 200; display: none;
}
.status-dropdown.open .status-dropdown-menu { display: block; }
.status-dropdown-item { display: block; padding: 8px 12px; font-size: 12px; color: #333; border-radius: 3px; transition: background .1s; text-transform: capitalize; }
.status-dropdown-item:hover { background: #f5f5f5; }

/* ── Pagination ──────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid #f0f0f0; font-size: 12px; color: #888; }
.pagination-pages { display: flex; gap: 2px; }
.page-btn { padding: 4px 9px; border-radius: 3px; font-size: 12px; color: #555; border: 1px solid #ddd; background: #fff; }
.page-btn:hover  { background: #f5f5f5; }
.page-btn.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }

/* ── Empty state ─────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: #aaa; }
.empty-state p { font-size: 13px; }
.empty-state a { color: var(--c-accent); }

/* ── Invoice creator ─────────────────────────────── */
.invoice-grid { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
.ifs { background: #fff; border: 1px solid #e0e0e0; border-radius: 3px; margin-bottom: 14px; overflow: hidden; }
.ifs-head { padding: 10px 16px; background: #f5f5f5; border-bottom: 1px solid #e0e0e0; font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; justify-content: space-between; }
.ifs-body { padding: 16px; }

/* Items table */
.items-table-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.items-table th { padding: 7px 8px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #888; border-bottom: 1px solid #eee; }
.items-table td { padding: 5px 4px; vertical-align: top; }
.items-table input, .items-table select { width: 100%; padding: 6px 8px; border: 1px solid #ddd; border-radius: 3px; font-size: 12px; background: #fff; }
.items-table input:focus, .items-table select:focus { border-color: var(--c-accent); outline: none; }
.td-no    { width: 24px; color: #aaa; font-size: 11px; padding-top: 9px; }
.td-name  { min-width: 180px; }
.td-hsn   { width: 70px; }
.td-unit  { width: 65px; }
.td-qty   { width: 60px; }
.td-rate  { width: 85px; }
.td-tax   { width: 60px; }
.td-total { width: 85px; text-align: right; font-weight: 600; padding-top: 9px; font-size: 12px; }
.del-row-btn { background: none; border: none; cursor: pointer; color: #ddd; padding: 5px 3px; transition: color .12s; }
.del-row-btn:hover { color: #e74c3c; }
.del-row-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.add-row-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--c-accent); background: none; border: 1px dashed var(--c-accent); border-radius: 4px; padding: 6px 14px; cursor: pointer; margin-top: 8px; transition: background .12s; }
.add-row-btn:hover { background: rgba(var(--c-accent-rgb, 241,91,58),.05); }
.add-row-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* Catalog picker */
.catalog-select { padding: 5px 24px 5px 8px; border: 1px solid var(--c-accent); border-radius: 4px; font-size: 11px; font-weight: 700; color: var(--c-accent); background: #fff7f5; appearance: none; cursor: pointer; }
.catalog-select:focus { outline: none; }

/* Summary card */
.summary-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 3px; position: sticky; top: 68px; }
.summary-header { padding: 10px 16px; background: #f5f5f5; border-bottom: 1px solid #e0e0e0; font-size: 11px; font-weight: 700; color: #666; text-transform: uppercase; }
.summary-body   { padding: 14px 16px; }
.summary-row    { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.summary-row .label { color: #888; }
.summary-row .value { font-weight: 500; color: #333; }
.summary-divider { border: none; border-top: 1px solid #eee; margin: 8px 0; }
.summary-total  { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; color: #222; padding: 8px 0 4px; border-top: 2px solid #333; margin-top: 4px; }
.summary-words  { font-size: 11px; color: #888; font-style: italic; padding: 8px 0; border-top: 1px solid #f5f5f5; line-height: 1.4; }
.summary-actions { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 7px; }
.summary-actions .btn { justify-content: center; width: 100%; }

/* ── Client info card ────────────────────────────── */
.client-info-box { margin-top: 10px; background: #fafafa; border: 1px solid #eee; border-radius: 3px; padding: 10px 12px; font-size: 12px; line-height: 1.7; }
.client-info-box .cin { font-weight: 700; color: #222; font-size: 13px; }

/* ── Settings ────────────────────────────────────── */
.settings-wrap { display: flex; gap: 20px; }
.settings-nav  { width: 150px; flex-shrink: 0; }
.settings-tab  { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 3px; font-size: 13px; color: #555; transition: all .12s; margin-bottom: 2px; }
.settings-tab svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-tab:hover  { background: #f5f5f5; }
.settings-tab.active { background: var(--c-accent); color: #fff; }
.settings-panel { flex: 1; max-width: 600px; }

/* ── Invoice Preview / PDF style ────────────────── */
.inv-preview-wrap  { max-width: 780px; margin: 0 auto; }
.inv-preview-bar   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.inv-preview-bar-left  { display: flex; align-items: center; gap: 10px; }
.inv-preview-bar-right { display: flex; align-items: center; gap: 8px; }

/* The invoice document itself */
.inv-doc { background: #fff; border: 1px solid #ddd; border-radius: 3px; padding: 40px 44px; }
.inv-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.inv-status-title { display: flex; align-items: center; gap: 10px; }
.inv-title { font-size: 20px; font-weight: 700; color: #333; }
.inv-logo-wrap { text-align: left; }
.inv-logo-wrap img { max-height: 80px; max-width: 260px; display: block; }
.inv-logo-text { font-size: 22px; font-weight: 900; color: #555; }

/* From / To / Invoice details */
.inv-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.inv-addr-block { }
.inv-addr-label { font-size: 11px; font-weight: 600; color: #999; letter-spacing: .01em; margin-bottom: 5px; }
.inv-addr-name  { font-size: 13px; font-weight: 600; color: #333; }
.inv-addr-link  { color: #4a9fd4; font-size: 13px; font-weight: 600; }
.inv-addr-text  { font-size: 12px; color: #666; line-height: 1.6; margin-top: 2px; }
.inv-addr-tax   { font-size: 11px; color: #888; }
.inv-meta-label { font-size: 11px; font-weight: 600; color: #999; letter-spacing: .01em; }
.inv-meta-value { font-size: 13px; color: #333; font-weight: 500; margin-top: 2px; }
.inv-meta-value + .inv-meta-label { margin-top: 8px; }

/* Items table in preview */
.inv-items-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.inv-items-table thead tr { background: transparent; border-bottom: 2px solid #ddd; }
.inv-items-table th { padding: 8px 10px; font-size: 12px; font-weight: 600; color: #888; text-align: left; }
.inv-items-table th:last-child { text-align: right; }
.inv-items-table td { padding: 11px 10px; border-bottom: 1px solid #f0f0f0; font-size: 13px; vertical-align: top; }
.inv-items-table td:last-child { text-align: right; font-weight: 600; }
.inv-td-name { color: #333; font-weight: 500; }
.inv-td-link { color: #4a9fd4; font-weight: 500; }
.inv-td-desc { font-size: 11px; color: #999; margin-top: 1px; }
.inv-td-unit { font-size: 11px; color: #888; }
.inv-td-mono { font-size: 11px; color: #888; }
.inv-discount-row { font-size: 11px; color: var(--c-accent); }

/* Totals */
.inv-totals-wrap { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.inv-totals-box  { width: 420px; }
.inv-total-row   { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f5f5f5; font-size: 13px; }
.inv-total-row .tl { color: #4a9fd4; font-weight: 500; }
.inv-total-row .tr { color: #333; }
.inv-total-row.grand-total { background: #fff; padding: 8px 0; border-bottom: none; }
.inv-total-row.grand-total .tl { font-size: 14px; font-weight: 600; color: #333; }
.inv-total-row.grand-total .tr { font-size: 14px; font-weight: 400; color: #333; }
.inv-balance-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 2px solid #e74c3c; border-radius: 3px;
  margin-top: 8px;
}
.inv-balance-label { background: #e74c3c; color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 2px; }
.inv-balance-currency { font-size: 13px; color: #999; margin: 0 8px; }
.inv-balance-amount   { font-size: 16px; font-weight: 700; color: #333; }
.inv-balance-row.paid { border-color: #27ae60; }
.inv-balance-row.paid .inv-balance-label { background: #27ae60; }

/* Invoice footer notes */
.inv-footer { margin-top: 20px; border-top: 1px solid #eee; padding-top: 16px; }
.inv-footer p { font-size: 12px; color: #666; line-height: 1.7; margin-bottom: 6px; }
.inv-footer a { color: #4a9fd4; }
.inv-footer-note { font-size: 11px; color: #999; }

/* ── Utilities ───────────────────────────────────── */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }
.text-muted   { color: #888; }
.text-link    { color: #4a9fd4; }
.text-orange  { color: var(--c-accent); }
.text-red     { color: #e74c3c; }
.text-green   { color: #27ae60; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ── Invoice Create — Document style ────────────── */
.inv-create-doc {
  background: #fff; border: 1px solid #ddd; border-radius: 4px;
  padding: 36px 40px; margin-bottom: 24px;
}
.icd-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.icd-status-badge {
  display: inline-block; padding: 4px 12px; border-radius: 3px;
  font-size: 12px; font-weight: 700; background: #6c757d; color: #fff;
}
.icd-status-draft   { background: #6c757d; }
.icd-status-sent    { background: #4a9fd4; }
.icd-status-paid    { background: #27ae60; }
.icd-status-overdue { background: #e74c3c; }
.icd-title-input {
  border: 1px solid #e0e0e0; border-radius: 3px; padding: 4px 10px;
  font-size: 15px; font-weight: 600; color: #333; background: #fff;
  width: 160px;
}
.icd-title-input:focus { border-color: var(--c-accent); outline: none; }
.icd-desc-input {
  width: 100%; border: 1px solid #e8e8e8; border-radius: 3px;
  padding: 10px 12px; font-size: 13px; color: #666; resize: vertical;
  background: #fafafa;
}
.icd-desc-input:focus { border-color: var(--c-accent); outline: none; background: #fff; }
.icd-field-label {
  font-size: 11px; font-weight: 600;
  color: #888; letter-spacing: .01em; margin-bottom: 5px;
}
.icd-client-select { font-size: 13px; color: #4a9fd4; }

/* Items table */
.icd-items-wrap { border: 1px solid #e8e8e8; border-radius: 3px; overflow: hidden; margin-bottom: 0; }
.icd-items-table { width: 100%; border-collapse: collapse; }
.icd-items-table th {
  padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: #888; letter-spacing: .04em; border-bottom: 1px solid #e8e8e8;
  background: #fafafa;
}
.icd-items-table td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.icd-items-table tr:last-child td { border-bottom: none; }
.icd-td-name { min-width: 200px; }
.icd-td-num  { width: 100px; }
.icd-td-amount { text-align: right; font-weight: 600; color: #4a9fd4; font-size: 13px; }

.icd-item-name {
  width: 100%; border: none; border-bottom: 1px dashed #e0e0e0;
  padding: 4px 0; font-size: 13px; color: #222; font-weight: 500;
  background: transparent;
}
.icd-item-name:focus { outline: none; border-bottom-color: var(--c-accent); }
.icd-item-desc {
  width: 100%; border: none; padding: 3px 0; font-size: 12px;
  color: #888; background: transparent; margin-top: 2px;
}
.icd-item-desc:focus { outline: none; }
.icd-item-hsn {
  width: 80px; border: 1px solid #e8e8e8; border-radius: 3px;
  padding: 3px 6px; font-size: 11px; color: #888;
}
.icd-item-unit {
  border: 1px solid #e8e8e8; border-radius: 3px; padding: 3px 4px;
  font-size: 11px; color: #888; background: #fff;
}
.icd-num-input {
  width: 100%; border: 1px solid #e8e8e8; border-radius: 3px;
  padding: 5px 8px; font-size: 13px; background: #fff;
}
.icd-num-input:focus { border-color: var(--c-accent); outline: none; }
.icd-tax-select {
  border: 1px solid #e8e8e8; border-radius: 3px; padding: 4px 4px;
  font-size: 12px; background: #fff; width: 100%;
}

/* Totals section */
.icd-totals { max-width: 380px; margin-left: auto; margin-top: 4px; padding-top: 12px; border-top: 1px solid #e8e8e8; }
.icd-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 13px; color: #555; border-bottom: 1px solid #f5f5f5;
}
.icd-total-row span:first-child { color: #4a9fd4; font-weight: 500; }
.icd-grand {
  font-size: 14px; font-weight: 700; color: #222 !important;
  border-top: 2px solid #ddd; padding-top: 8px; margin-top: 4px;
  border-bottom: none;
}
.icd-grand span { color: #222 !important; }
.icd-balance-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #f5f5f5; border: 1px solid #ddd; border-radius: 3px;
  padding: 10px 14px; margin-top: 8px;
}
.icd-balance-label {
  background: #555; color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 12px; border-radius: 2px;
}

/* ── Client Form — pixel-perfect Invoicely ────────── */
.cl-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 0;
}
.cl-page-title { font-size: 20px; font-weight: 700; color: #1a1a2e; }

/* Section card */
.cl-section {
  background: #fff; border: 1px solid #ddd;
  border-radius: 3px; margin-bottom: 20px; overflow: hidden;
}
.cl-section-hd {
  background: #f5f5f5; border-bottom: 1px solid #ddd;
  padding: 12px 20px; font-size: 13px; font-weight: 600; color: #444;
}
.cl-section-bd { padding: 24px 20px; }

/* Avatar circle */
.cl-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: #e8e8e8; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}

/* Type list — stacked rows exactly like Invoicely */
.cl-type-list {
  border: 1px solid #ddd; border-radius: 3px; overflow: hidden;
  min-width: 200px;
}
.cl-type-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  color: #333; background: #fff; border-bottom: 1px solid #eee;
  transition: background .1s;
}
.cl-type-row:last-child { border-bottom: none; }
.cl-type-row:hover:not(.selected) { background: #fafafa; }
.cl-type-row.selected { background: #fffde8; font-weight: 600; }
.cl-type-check { color: var(--c-accent); font-weight: 700; opacity: 0; }
.cl-type-row.selected .cl-type-check { opacity: 1; }

/* Labels */
.cl-label {
  display: block; font-size: 12px; color: #888; font-weight: 500;
  margin-bottom: 6px; line-height: 1.4;
}
/* Inputs */
.cl-input {
  width: 100%; padding: 8px 10px; border: 1px solid #ccc;
  border-radius: 3px; font-size: 14px; color: #333;
  background: #fff; line-height: 1.4;
  transition: border-color .15s;
}
.cl-input:focus { border-color: var(--c-accent); outline: none; }
.cl-select { appearance: auto; }
.cl-textarea { resize: vertical; min-height: 80px; }

/* ── Invoice / Proposal List Page ────────────────── */
.inv-list-page { padding: 24px; flex: 1; width: 100%; }
.inv-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.inv-page-title { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.inv-header-actions { display: flex; align-items: center; gap: 10px; }
.inv-add-btn-wrap { }
.inv-add-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 4px;
  background: var(--c-accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  transition: background .15s; text-decoration: none; white-space: nowrap;
}
.inv-add-btn:hover { background: var(--c-accent-hover); color: #fff; }
.inv-add-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* Search / toolbar row */
.inv-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.inv-toolbar-left  { display: flex; align-items: center; gap: 8px; flex: 1; }
.inv-toolbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.inv-search-wrap   { position: relative; flex: 1; max-width: 320px; }
.inv-search-icon   {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; color: #aaa; pointer-events: none;
  stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.inv-search-input  {
  width: 100%; padding: 7px 10px 7px 30px;
  border: 1px solid #ddd; border-radius: 4px; font-size: 12px; color: #333; background: #fff;
}
.inv-search-input:focus { border-color: var(--c-accent); outline: none; }
.inv-tool-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 4px;
  background: #fff; border: 1px solid #ddd; color: #555;
  cursor: pointer; text-decoration: none; transition: all .12s;
}
.inv-tool-btn:hover { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.inv-tool-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Results count + filter tabs row */
.inv-meta-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 10px; flex-wrap: wrap;
}
.inv-results-text { font-size: 12px; color: #888; }
.inv-filter-tabs  { display: flex; gap: 0; border: 1px solid #ddd; border-radius: 4px; overflow: hidden; flex-wrap: nowrap; }
.inv-ftab {
  padding: 6px 14px; font-size: 12px; font-weight: 600; color: #666;
  background: #fff; border-right: 1px solid #ddd; transition: all .1s;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  text-decoration: none;
}
.inv-ftab:last-child { border-right: none; }
.inv-ftab:hover  { background: #f5f5f5; }
.inv-ftab.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.inv-ftab-badge  {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.12); color: inherit;
  border-radius: 10px; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 16px; padding: 0 4px;
}
.inv-ftab.active .inv-ftab-badge { background: rgba(255,255,255,.25); }
.inv-ftab-badge.badge-overdue    { background: #e74c3c; color: #fff; }

/* List card wrapper */
.inv-list-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 3px; overflow: hidden; margin-bottom: 16px; }

/* Empty state */
.inv-empty {
  text-align: center; padding: 48px 20px; color: #aaa;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.inv-empty p { font-size: 13px; }

/* Invoice row (card layout used in invoices.php) */
.inv-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid #f5f5f5;
  transition: background .1s;
}
.inv-row:last-child { border-bottom: none; }
.inv-row:hover { background: #fafafa; }
.inv-row-main  { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; }
.inv-row-date  { font-size: 11px; color: #aaa; white-space: nowrap; min-width: 72px; }
.inv-row-info  { min-width: 0; }
.inv-row-number { font-size: 13px; font-weight: 700; color: var(--c-accent); display: block; text-decoration: none; }
.inv-row-number:hover { text-decoration: underline; }
.inv-row-client { font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-row-status-wrap { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.inv-row-status-dropdown { position: relative; cursor: pointer; }
.inv-status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; white-space: nowrap; cursor: pointer;
}
.inv-status-menu {
  display: none; position: absolute; left: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid #ddd; border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1); min-width: 150px;
  padding: 3px; z-index: 200;
}
.inv-row-status-dropdown.open .inv-status-menu { display: block; }
.inv-status-menu-item {
  display: block; padding: 7px 12px; font-size: 12px; color: #333;
  border-radius: 3px; transition: background .1s; text-decoration: none;
}
.inv-status-menu-item:hover { background: #f5f5f5; }
.inv-row-due { font-size: 11px; color: #94a3b8; white-space: nowrap; }
.inv-row-amount-wrap { text-align: right; flex-shrink: 0; }
.inv-row-amount { font-size: 14px; font-weight: 700; color: #1e293b; }
.inv-row-days  { font-size: 11px; color: #94a3b8; }
.overdue-text  { color: #dc2626 !important; }
.inv-row-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.inv-act {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  color: #cbd5e1; transition: color .12s, background .12s; text-decoration: none;
}
.inv-act svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.inv-act:hover     { color: var(--c-accent); background: var(--c-accent-xlight); }
.inv-act-del:hover { color: #e74c3c; background: #fef2f2; }

/* Pagination for invoice/proposal list */
.inv-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-top: 1px solid #f0f0f0;
  background: #fff; border: 1px solid #e0e0e0; border-radius: 3px;
  flex-wrap: wrap; gap: 8px; font-size: 12px; color: #888;
}
.inv-pag-left { display: flex; align-items: center; gap: 3px; }
.pag-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 3px; font-size: 12px; color: #555;
  border: 1px solid #ddd; background: #fff; text-decoration: none; transition: all .1s;
}
.pag-btn:hover:not(.disabled):not(.active) { background: #f5f5f5; }
.pag-btn.active   { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.pag-btn.disabled { color: #ccc; pointer-events: none; }
.pag-ellipsis { display: inline-flex; align-items: center; padding: 0 4px; color: #aaa; font-size: 13px; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f5f5f5; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ════════════════════════════════════════════════════
   RESPONSIVE — Mobile First Breakpoints
════════════════════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ─────────── */
.hamburger {
  display: none; background: none; border: none;
  cursor: pointer; padding: 4px 6px; color: #555;
  border-radius: 4px; transition: background .15s;
}
.hamburger:hover { background: #f5f5f5; }
.hamburger svg { width: 20px; height: 20px; display: block; }

/* ── Sidebar overlay backdrop ─────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Tablet & Mobile ≤ 768px ─────────────────────── */
@media (max-width: 768px) {

  /* Hamburger visible */
  .hamburger { display: flex; align-items: center; justify-content: center; }

  /* Sidebar becomes a full-height drawer, hidden off-screen via transform */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 200px; z-index: 200;
    transform: translateX(-200px);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main takes full width */
  .main-wrap { margin-left: 0; }

  /* Topbar adjustments */
  .topbar { padding: 0 14px; }
  .topbar-date { display: none; }
  .topbar-title { font-size: 15px; }
  .notif-dropdown { width: 280px; right: -60px; }

  /* Page body breathing room */
  .page-body { padding: 14px; }

  /* Dashboard grids → single column */
  .dash-grid-top,
  .dash-grid-mid { grid-template-columns: 1fr; }

  /* Invoice create: form + summary side-by-side → stacked */
  .invoice-grid { grid-template-columns: 1fr; }
  .summary-card { position: static; margin-top: 0; }

  /* Items table: horizontal scroll */
  .items-table-wrap,
  .icd-items-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .items-table,
  .icd-items-table { min-width: 620px; }

  /* Invoice preview */
  .inv-doc { padding: 20px 16px; }
  .inv-top { flex-direction: column; gap: 12px; }
  .inv-logo-wrap { text-align: left; }
  .inv-addresses { grid-template-columns: 1fr; gap: 16px; }
  .inv-preview-bar { flex-wrap: wrap; gap: 8px; }
  .inv-preview-bar-right { flex-wrap: wrap; gap: 6px; }

  /* Invoice preview bar buttons shrink */
  .inv-preview-bar .btn { padding: 6px 10px; font-size: 11px; }

  /* Data tables: horizontal scroll */
  .card { overflow-x: auto; }
  .data-table { min-width: 560px; }

  /* Filter bar wraps */
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .search-wrap { width: 100%; }
  .search-input { width: 100%; }

  /* Invoice/Proposal list page */
  .inv-list-page { padding: 14px; }
  .inv-page-header { flex-wrap: wrap; gap: 8px; }
  .inv-toolbar { flex-wrap: wrap; }
  .inv-search-wrap { max-width: 100%; }
  .inv-meta-bar { flex-direction: column; align-items: flex-start; }
  .inv-filter-tabs { overflow-x: auto; width: 100%; }
  .inv-row { flex-wrap: wrap; gap: 8px; }
  .inv-row-main { min-width: 100%; }
  .inv-row-actions { flex-wrap: wrap; }

  /* Settings: tabs go horizontal on top */
  .settings-wrap { flex-direction: column; }
  .settings-nav {
    width: 100%; display: flex; flex-wrap: wrap;
    gap: 4px; margin-bottom: 4px;
  }
  .settings-tab { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
  .settings-panel { max-width: 100%; }

  /* Client form: all multi-column grids → 1 col */
  .cl-section-bd [style*="grid-template-columns"] { display: block !important; }
  .cl-section-bd [style*="grid-template-columns"] > * { margin-bottom: 14px; }
  .cl-topbar { flex-wrap: wrap; gap: 10px; }
  .cl-topbar > div:last-child { flex-wrap: wrap; gap: 6px; }

  /* Invoice create doc layout */
  .inv-create-doc { padding: 20px 16px; }
  .icd-header { flex-direction: column; gap: 10px; }
  .icd-totals { max-width: 100%; }
  .icd-half { max-width: 100% !important; }

  /* Client info topbar on invoice create */
  .cl-topbar-inner { flex-wrap: wrap; }

  /* Notification dropdown */
  .notif-dropdown { position: fixed; left: 8px; right: 8px; width: auto; top: 58px; }

  /* Hide topbar date to save space */
  .topbar-right .btn-sm span { display: none; }

  /* Cards with inline grids */
  .card-body [style*="grid-template-columns:1fr 1fr"],
  .card-body [style*="grid-template-columns: 1fr 1fr"] { display: block !important; }
  .card-body [style*="grid-template-columns:1fr 1fr"] > *,
  .card-body [style*="grid-template-columns: 1fr 1fr"] > * { margin-bottom: 12px; }
}

/* ── Small phones ≤ 480px ─────────────────────────── */
@media (max-width: 480px) {
  .topbar-title { font-size: 14px; }
  .page-body { padding: 10px; }
  .inv-doc { padding: 16px 12px; }
  .btn { font-size: 12px; padding: 6px 12px; }
  .btn-sm { font-size: 11px; padding: 4px 8px; }
  .inv-title { font-size: 16px; }
  .topbar { height: 48px; }
  .filter-tab { padding: 5px 9px; font-size: 11px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .summary-body { padding: 10px 12px; }
  .card-body { padding: 12px; }
  /* Action icons: always visible, not just on hover */
  .action-icon { color: #aaa; }
}

/* ── Print ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .inv-preview-bar, .no-print { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  body { background: #fff !important; }
  .inv-doc { border: none !important; padding: 0 !important; }
}
