/* ── TBGG Client Portal Styles ───────────────────────────────────────────── */
:root {
  --tbgg-primary: #1A3C5E;
  --tbgg-accent:  #2459A0;
  --tbgg-gold:    #C9A84C;
  --tbgg-bg:      #f7f6f3;
  --tbgg-card:    #ffffff;
  --tbgg-border:  #e8e6e1;
  --tbgg-text:    #1a1917;
  --tbgg-muted:   #8c8880;
  --tbgg-success: #1a7a4a;
  --tbgg-warning: #8b5a00;
  --tbgg-danger:  #9b1c1c;
  --tbgg-radius:  12px;
  --tbgg-shadow:  0 4px 20px rgba(0,0,0,.07);
}

/* ── Portal Shell ────────────────────────────────────────────────────────── */
.tbgg-portal { display: flex; min-height: 100vh; background: var(--tbgg-bg); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif; color: var(--tbgg-text); }

/* ── Sidebar Nav ─────────────────────────────────────────────────────────── */
.tbgg-nav { width: 240px; background: var(--tbgg-primary); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .25s; }
.tbgg-nav-logo { padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.tbgg-nav-logo img { max-height: 44px; }
.tbgg-nav-logo .firm-name { font-size: 15px; font-weight: 700; color: #fff; }
.tbgg-nav-logo .client-name { font-size: 11px; color: rgba(255,255,255,.6); margin-top: 2px; }
.tbgg-nav-links { flex: 1; padding: 12px 0; overflow-y: auto; }
.tbgg-nav-link { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(255,255,255,.75); font-size: 13px; font-weight: 500; text-decoration: none; cursor: pointer; transition: all .15s; border-left: 3px solid transparent; }
.tbgg-nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.tbgg-nav-link.active { color: #fff; background: rgba(255,255,255,.12); border-left-color: var(--tbgg-gold); }
.tbgg-nav-link .icon { font-size: 16px; width: 20px; text-align: center; }
.tbgg-nav-link .badge { margin-left: auto; background: var(--tbgg-gold); color: #1a1917; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; }
.tbgg-nav-bottom { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.tbgg-nav-bottom a { color: rgba(255,255,255,.6); font-size: 12px; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.tbgg-nav-bottom a:hover { color: #fff; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.tbgg-main { margin-left: 240px; flex: 1; min-width: 0; }
.tbgg-topbar { background: #fff; border-bottom: 1px solid var(--tbgg-border); padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.tbgg-topbar .page-title { font-size: 16px; font-weight: 700; color: var(--tbgg-primary); }
.tbgg-topbar-right { display: flex; align-items: center; gap: 16px; }
.tbgg-notif-btn { position: relative; background: none; border: none; cursor: pointer; font-size: 20px; padding: 4px; }
.tbgg-notif-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; background: #ef4444; border-radius: 50%; }
.tbgg-topbar-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--tbgg-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.tbgg-content { padding: 28px 32px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.tbgg-card { background: var(--tbgg-card); border: 1px solid var(--tbgg-border); border-radius: var(--tbgg-radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--tbgg-shadow); }
.tbgg-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tbgg-card-header h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--tbgg-primary); text-transform: uppercase; letter-spacing: .04em; }

/* ── Stats ──────────────────────────────────────────────────────────────── */
.tbgg-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tbgg-stat-card { background: var(--tbgg-card); border: 1px solid var(--tbgg-border); border-radius: var(--tbgg-radius); padding: 20px; box-shadow: var(--tbgg-shadow); }
.tbgg-stat-card .s-label { font-size: 11px; color: var(--tbgg-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.tbgg-stat-card .s-value { font-size: 24px; font-weight: 800; color: var(--tbgg-primary); line-height: 1; }
.tbgg-stat-card .s-sub   { font-size: 12px; color: var(--tbgg-muted); margin-top: 4px; }
.tbgg-stat-card.highlight { background: var(--tbgg-primary); }
.tbgg-stat-card.highlight .s-label,
.tbgg-stat-card.highlight .s-value,
.tbgg-stat-card.highlight .s-sub { color: #fff; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.tbgg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .15s; font-family: inherit; }
.tbgg-btn-primary { background: var(--tbgg-primary); color: #fff; }
.tbgg-btn-primary:hover { background: var(--tbgg-accent); color: #fff; }
.tbgg-btn-outline { background: transparent; border: 1.5px solid var(--tbgg-primary); color: var(--tbgg-primary); }
.tbgg-btn-outline:hover { background: var(--tbgg-primary); color: #fff; }
.tbgg-btn-success { background: var(--tbgg-success); color: #fff; }
.tbgg-btn-ghost { background: transparent; border: 1px solid var(--tbgg-border); color: var(--tbgg-muted); }
.tbgg-btn-ghost:hover { border-color: var(--tbgg-primary); color: var(--tbgg-primary); }
.tbgg-btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.tbgg-btn-pay { background: linear-gradient(135deg, var(--tbgg-primary), var(--tbgg-accent)); color: #fff; padding: 12px 28px; font-size: 14px; border-radius: 10px; width: 100%; justify-content: center; margin-top: 8px; }
.tbgg-btn-pay:hover { opacity: .9; color: #fff; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.tbgg-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.tbgg-badge-paid, .tbgg-badge-success, .tbgg-badge-done, .tbgg-badge-both_signed { background: #dcfce7; color: #166534; }
.tbgg-badge-pending, .tbgg-badge-draft { background: #f3f4f6; color: #374151; }
.tbgg-badge-sent, .tbgg-badge-partial, .tbgg-badge-invited { background: #fef3c7; color: #92400e; }
.tbgg-badge-overdue, .tbgg-badge-blocked { background: #fee2e2; color: #991b1b; }
.tbgg-badge-active { background: #dbeafe; color: #1e40af; }
.tbgg-badge-firm_signed, .tbgg-badge-client_signed { background: #ede9fe; color: #5b21b6; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.tbgg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbgg-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--tbgg-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--tbgg-border); background: #faf9f7; }
.tbgg-table td { padding: 13px 14px; border-bottom: 1px solid var(--tbgg-border); vertical-align: middle; }
.tbgg-table tr:last-child td { border-bottom: none; }
.tbgg-table tr:hover td { background: #faf9f7; }

/* ── Progress ────────────────────────────────────────────────────────────── */
.tbgg-progress { height: 8px; background: var(--tbgg-border); border-radius: 4px; overflow: hidden; }
.tbgg-progress .fill { height: 100%; background: var(--tbgg-primary); border-radius: 4px; transition: width .4s ease; }
.tbgg-progress.green .fill { background: var(--tbgg-success); }

/* ── Phase + Task ────────────────────────────────────────────────────────── */
.tbgg-phase { border: 1px solid var(--tbgg-border); border-radius: var(--tbgg-radius); margin-bottom: 12px; overflow: hidden; }
.tbgg-phase-hdr { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: #faf9f7; cursor: pointer; }
.tbgg-phase-hdr .ph-name { font-size: 14px; font-weight: 700; color: var(--tbgg-primary); }
.tbgg-phase-hdr .ph-meta { font-size: 12px; color: var(--tbgg-muted); }
.tbgg-task { display: flex; align-items: flex-start; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--tbgg-border); }
.tbgg-task .t-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--tbgg-border); flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.tbgg-task.done .t-check { background: var(--tbgg-success); border-color: var(--tbgg-success); color: #fff; }
.tbgg-task.done .t-title { text-decoration: line-through; color: var(--tbgg-muted); }
.tbgg-task .t-title { font-size: 13px; font-weight: 500; }
.tbgg-task .t-meta { font-size: 11px; color: var(--tbgg-muted); margin-top: 3px; }

/* ── KPI Impact Card ─────────────────────────────────────────────────────── */
.tbgg-kpi-impact { background: var(--tbgg-card); border: 1px solid var(--tbgg-border); border-radius: var(--tbgg-radius); padding: 20px; box-shadow: var(--tbgg-shadow); }
.tbgg-kpi-impact .ki-name { font-size: 14px; font-weight: 700; color: var(--tbgg-primary); margin-bottom: 12px; }
.tbgg-kpi-impact .ki-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 13px; }
.tbgg-kpi-impact .ki-label { width: 70px; font-size: 11px; color: var(--tbgg-muted); font-weight: 600; text-transform: uppercase; }
.tbgg-kpi-impact .ki-val { font-size: 18px; font-weight: 800; color: var(--tbgg-primary); }
.tbgg-kpi-impact .ki-current { color: var(--tbgg-success); }

/* ── Document Card ────────────────────────────────────────────────────────── */
.tbgg-doc-card { background: var(--tbgg-card); border: 1px solid var(--tbgg-border); border-radius: var(--tbgg-radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--tbgg-shadow); }
.tbgg-doc-card .d-icon { font-size: 28px; }
.tbgg-doc-card .d-name { font-size: 13px; font-weight: 600; word-break: break-word; }
.tbgg-doc-card .d-meta { font-size: 11px; color: var(--tbgg-muted); }
.tbgg-doc-card .d-sign-alert { font-size: 11px; font-weight: 700; color: var(--tbgg-warning); background: #fef3c7; padding: 4px 8px; border-radius: 4px; }

/* ── Invoice Detail ──────────────────────────────────────────────────────── */
.tbgg-inv-header { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.tbgg-inv-from, .tbgg-inv-to { font-size: 13px; line-height: 1.7; }
.tbgg-inv-from strong, .tbgg-inv-to strong { color: var(--tbgg-primary); font-size: 14px; display: block; margin-bottom: 4px; }
.tbgg-inv-items { width: 100%; border-collapse: collapse; margin: 20px 0; }
.tbgg-inv-items th { background: var(--tbgg-primary); color: #fff; padding: 10px 14px; text-align: left; font-size: 12px; }
.tbgg-inv-items td { padding: 11px 14px; border-bottom: 1px solid var(--tbgg-border); font-size: 13px; }
.tbgg-inv-totals { display: flex; justify-content: flex-end; }
.tbgg-inv-totals table { min-width: 220px; font-size: 13px; }
.tbgg-inv-totals td { padding: 5px 10px; }
.tbgg-inv-totals .grand-total td { font-weight: 800; font-size: 15px; color: var(--tbgg-primary); border-top: 2px solid var(--tbgg-primary); }

/* ── Payment methods ─────────────────────────────────────────────────────── */
.tbgg-pay-methods { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.tbgg-pay-method { border: 1.5px solid var(--tbgg-border); border-radius: 8px; padding: 12px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 13px; transition: all .15s; }
.tbgg-pay-method:hover, .tbgg-pay-method.selected { border-color: var(--tbgg-primary); background: #f0f5ff; }
.tbgg-pay-method .pm-logo { font-size: 20px; }
.tbgg-pay-method .pm-label { font-weight: 600; color: var(--tbgg-primary); }
.tbgg-pay-method .pm-desc { font-size: 11px; color: var(--tbgg-muted); }

/* ── Auth Pages ──────────────────────────────────────────────────────────── */
.tbgg-auth { min-height: 100vh; background: var(--tbgg-bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
.tbgg-auth-box { background: #fff; border: 1px solid var(--tbgg-border); border-radius: 16px; padding: 40px; width: 100%; max-width: 440px; box-shadow: 0 8px 40px rgba(0,0,0,.1); }
.tbgg-auth-logo { text-align: center; margin-bottom: 28px; }
.tbgg-auth-logo img { max-height: 48px; }
.tbgg-auth-logo .firm { font-size: 18px; font-weight: 800; color: var(--tbgg-primary); }
.tbgg-auth h2 { font-size: 20px; font-weight: 800; color: var(--tbgg-primary); margin: 0 0 6px; }
.tbgg-auth .subtitle { font-size: 13px; color: var(--tbgg-muted); margin-bottom: 24px; }
.tbgg-form-group { margin-bottom: 14px; }
.tbgg-form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--tbgg-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.tbgg-form-group input, .tbgg-form-group select, .tbgg-form-group textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--tbgg-border); border-radius: 8px; font-size: 14px; color: var(--tbgg-text); transition: border-color .15s; box-sizing: border-box; font-family: inherit; }
.tbgg-form-group input:focus, .tbgg-form-group select:focus { outline: none; border-color: var(--tbgg-primary); box-shadow: 0 0 0 3px rgba(26,60,94,.08); }
.tbgg-auth-submit { width: 100%; padding: 12px; background: var(--tbgg-primary); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 8px; transition: background .15s; font-family: inherit; }
.tbgg-auth-submit:hover { background: var(--tbgg-accent); }
.tbgg-error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; }
.tbgg-auth-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--tbgg-muted); }
.tbgg-auth-footer a { color: var(--tbgg-primary); font-weight: 600; text-decoration: none; }

/* ── Notification dropdown ────────────────────────────────────────────────── */
.tbgg-notif-panel { position: absolute; top: 50px; right: 16px; width: 320px; background: #fff; border: 1px solid var(--tbgg-border); border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.12); display: none; z-index: 200; }
.tbgg-notif-panel.open { display: block; }
.tbgg-notif-header { padding: 14px 16px; border-bottom: 1px solid var(--tbgg-border); display: flex; justify-content: space-between; align-items: center; }
.tbgg-notif-header h4 { margin: 0; font-size: 13px; font-weight: 700; }
.tbgg-notif-item { padding: 12px 16px; border-bottom: 1px solid var(--tbgg-border); cursor: pointer; }
.tbgg-notif-item:last-child { border-bottom: none; }
.tbgg-notif-item.unread { background: #f0f5ff; }
.tbgg-notif-item .n-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.tbgg-notif-item .n-body  { font-size: 12px; color: var(--tbgg-muted); }
.tbgg-notif-item .n-time  { font-size: 11px; color: var(--tbgg-muted); margin-top: 3px; }

/* ── Signature canvas ────────────────────────────────────────────────────── */
.tbgg-sig-canvas { border: 2px dashed var(--tbgg-border); border-radius: 10px; width: 100%; touch-action: none; background: #fafaf9; display: block; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.tbgg-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99999; align-items: center; justify-content: center; padding: 16px; }
.tbgg-modal-overlay.open { display: flex; }
.tbgg-portal-modal { background: #fff; border-radius: 16px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.tbgg-portal-modal.lg { max-width: 720px; }
.tbgg-modal-hdr { padding: 18px 22px; border-bottom: 1px solid var(--tbgg-border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 1; }
.tbgg-modal-hdr h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--tbgg-primary); }
.tbgg-modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--tbgg-muted); }
.tbgg-modal-body { padding: 22px; }
.tbgg-modal-foot { padding: 16px 22px; border-top: 1px solid var(--tbgg-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#tbgg-portal-toast { position: fixed; bottom: 24px; right: 24px; z-index: 999999; display: flex; flex-direction: column; gap: 8px; }
.tbgg-portal-toast-item { background: #1a1917; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: tbggSlideIn .25s ease; }
.tbgg-portal-toast-item.success { background: var(--tbgg-success); }
.tbgg-portal-toast-item.error   { background: var(--tbgg-danger); }
@keyframes tbggSlideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
.tbgg-mobile-toggle { display: none; position: fixed; top: 14px; left: 14px; z-index: 200; background: var(--tbgg-primary); border: none; border-radius: 8px; padding: 8px 10px; cursor: pointer; color: #fff; font-size: 18px; }
@media (max-width: 768px) {
  .tbgg-mobile-toggle { display: flex; }
  .tbgg-nav { transform: translateX(-100%); }
  .tbgg-nav.open { transform: none; }
  .tbgg-main { margin-left: 0; }
  .tbgg-content { padding: 16px; }
  .tbgg-topbar { padding: 0 16px 0 52px; }
  .tbgg-stats { grid-template-columns: 1fr 1fr; }
  .tbgg-inv-header { grid-template-columns: 1fr; }
}
