<!-- ===================== ACCOUNT TAB ===================== -->
<div class="tab-pane <?= ($requested_tab === 'account') ? 'active' : '' ?>" id="tab-account">
  <div class="card" style="max-width:960px">
    <div class="card-header"><span class="card-title">Account Settings</span></div>
    <div class="card-body">
      <div class="account-kpi-grid" style="margin-bottom:16px">
        <div class="card" style="padding:12px;background:var(--bg-base)"><div class="text-xs text-muted">Current User</div><strong><?= htmlspecialchars($current_user_full['name'] ?? '') ?></strong><div class="text-xs"><?= htmlspecialchars($current_user_full['email'] ?? '') ?></div></div>
        <div class="card" style="padding:12px;background:var(--bg-base)"><div class="text-xs text-muted">WhatsApp Sent</div><strong><?= number_format($wa_count) ?></strong></div>
        <div class="card" style="padding:12px;background:var(--bg-base)"><div class="text-xs text-muted">SMS Sent</div><strong><?= number_format($sms_count) ?></strong></div>
        <div class="card" style="padding:12px;background:var(--bg-base)"><div class="text-xs text-muted">Emails Sent</div><strong><?= number_format($email_count) ?></strong></div>
      </div>
      <form id="accountForm">
        <div class="form-grid">
          <div class="form-group">
            <label class="form-label">Client Name</label>
            <input type="text" name="client_name" class="form-control" value="<?= htmlspecialchars($account['client_name']) ?>">
          </div>
          <div class="form-group">
            <label class="form-label">Business Name</label>
            <input type="text" name="business_name" class="form-control" value="<?= htmlspecialchars($account['business_name']) ?>">
          </div>
          <div class="form-group">
            <label class="form-label">Phone</label>
            <input type="text" name="phone" class="form-control" value="<?= htmlspecialchars($account['phone']) ?>">
          </div>
          <div class="form-group">
            <label class="form-label">Email</label>
            <input type="email" name="email" class="form-control" value="<?= htmlspecialchars($account['email']) ?>">
          </div>
          <div class="form-group">
            <label class="form-label">Currency</label>
            <select name="currency" class="form-control">
              <?php foreach (['USD','EUR','GBP','AED','SAR','LBP','QAR'] as $c): ?>
              <option value="<?= $c ?>" <?= $account['currency']===$c?'selected':'' ?>><?= $c ?></option>
              <?php endforeach; ?>
            </select>
          </div>
          <div class="form-group">
            <label class="form-label">Price Decimals</label>
            <select name="price_decimals" class="form-control">
              <option value="2" <?= (int)($account['price_decimals'] ?? 2) === 2 ? 'selected' : '' ?>>Show 0.00</option>
              <option value="0" <?= (int)($account['price_decimals'] ?? 2) === 0 ? 'selected' : '' ?>>Show 0</option>
            </select>
            <div class="text-xs text-muted" style="margin-top:6px">Controls all price display in lists, pipeline, quotations and invoices.</div>
          </div>
          <div class="form-group">
            <label class="form-label">Default Leads View</label>
            <select name="default_leads_view" class="form-control">
              <option value="list" <?= (($account['default_leads_view'] ?? 'list') === 'list') ? 'selected' : '' ?>>List</option>
              <option value="pipeline" <?= (($account['default_leads_view'] ?? 'list') === 'pipeline') ? 'selected' : '' ?>>Pipeline</option>
            </select>
            <div class="text-xs text-muted" style="margin-top:6px">When opening Leads from the menu, choose list or pipeline by default.</div>
          </div>
          <div class="form-group">
            <label class="form-label">Status</label>
            <select name="status" class="form-control">
              <option value="active" <?= $account['status']==='active'?'selected':'' ?>>Active</option>
              <option value="inactive" <?= $account['status']==='inactive'?'selected':'' ?>>Inactive</option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-label">Business Logo</label>
            <?php if (!empty($account['logo'])): ?>
              <div style="margin-bottom:8px"><img src="<?= htmlspecialchars($account['logo']) ?>" alt="Logo" style="max-width:140px;max-height:70px;object-fit:contain;border:1px solid var(--border);border-radius:8px;padding:6px;background:#fff"></div>
            <?php endif; ?>
            <input type="file" name="logo" class="form-control" accept="image/*">
            <div class="text-xs text-muted" style="margin-top:6px">This logo appears on quotation/invoice print pages.</div>
          </div>
        </div>
        <button type="button" class="btn btn-primary" onclick="saveAccount()">Save Changes</button>
      </form>
    </div>
  </div>
</div>

<style>.account-kpi-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}@media(max-width:760px){.account-kpi-grid{grid-template-columns:1fr}}</style>
