/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       color: #1a202c; background: #f7f8fa; display: flex; min-height: 100vh; }

a { color: #1a56db; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { width: 220px; min-height: 100vh; background: #1e293b; color: #cbd5e1;
           display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-brand { padding: 20px 18px; font-size: 15px; font-weight: 700;
                 color: #fff; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; color: #60a5fa; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-nav li a { display: block; padding: 10px 18px; font-size: 14px; color: #94a3b8;
                    transition: background .15s, color .15s; border-radius: 4px; margin: 2px 8px; }
.sidebar-nav li a:hover, .sidebar-nav li.active a { background: #334155; color: #fff; text-decoration: none; }
.sidebar-footer { padding: 16px 18px; border-top: 1px solid #334155; font-size: 13px; display: flex;
                  justify-content: space-between; align-items: center; }
.logout-link { color: #f87171; }

/* ── Main content ───────────────────────────────────────────── */
.main-content { flex: 1; padding: 28px 32px; max-width: 1200px; }

/* ── Page header ────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-title  { font-size: 24px; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 8px; border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center;
               padding: 14px 16px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.card-title { font-size: 15px; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px;
       border-radius: 5px; border: 1px solid #cbd5e1; background: #fff; color: #374151;
       font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: #1a56db; border-color: #1a56db; color: #fff; }
.btn-primary:hover { background: #1347ba; }
.btn-danger  { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase;
            color: #64748b; background: #f8fafc; border-bottom: 2px solid #e2e8f0; font-weight: 600; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.empty { text-align: center; color: #94a3b8; padding: 24px !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.actions { text-align: right; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-input { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 5px;
              font-size: 14px; background: #fff; transition: border-color .15s; }
.form-input:focus { outline: none; border-color: #1a56db; box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: #374151; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; }
.form-full  { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; padding: 16px; border-top: 1px solid #e2e8f0; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Search bar ─────────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-input { flex: 1; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 5px; margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px;
         font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-draft     { background: #f1f5f9; color: #475569; }
.badge-sent      { background: #dbeafe; color: #1d4ed8; }
.badge-accepted  { background: #d1fae5; color: #065f46; }
.badge-paid      { background: #d1fae5; color: #065f46; }
.badge-rejected  { background: #fee2e2; color: #991b1b; }
.badge-expired   { background: #fef3c7; color: #92400e; }
.badge-overdue   { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-failed    { background: #fee2e2; color: #991b1b; }

/* ── Dashboard stats ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card  { background: #fff; border-radius: 8px; padding: 20px; border: 1px solid #e2e8f0;
              box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 4px solid; }
.stat-blue  { border-left-color: #1a56db; }
.stat-green { border-left-color: #059669; }
.stat-red   { border-left-color: #dc2626; }
.stat-gray  { border-left-color: #6b7280; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 4px; }
.revenue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.revenue-card { background: #fff; border-radius: 8px; padding: 20px; border: 1px solid #e2e8f0;
                box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.revenue-label  { font-size: 13px; color: #64748b; margin-bottom: 6px; }
.revenue-amount { font-size: 28px; font-weight: 700; }
.revenue-green  { color: #059669; }
.revenue-orange { color: #d97706; }
.tables-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Detail layout ──────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }
.detail-list { padding: 16px; }
.detail-list dt { font-size: 11px; font-weight: 600; text-transform: uppercase;
                  color: #94a3b8; margin-top: 12px; margin-bottom: 2px; }
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { font-size: 14px; color: #1a202c; }

/* ── Totals bar ─────────────────────────────────────────────── */
.totals-bar { display: flex; justify-content: flex-end; gap: 28px; padding: 14px 16px;
              background: #f8fafc; border-top: 1px solid #e2e8f0; font-size: 14px; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; }
.page-btn { border: 1px solid #cbd5e1; padding: 5px 12px; border-radius: 4px; background: #fff; color: #374151; }
.page-btn:hover { background: #f1f5f9; text-decoration: none; }
.page-info { color: #64748b; }

/* ── Auth page ──────────────────────────────────────────────── */
.auth-page { display: flex; justify-content: center; align-items: center;
             min-height: 100vh; background: #f7f8fa; }
.auth-card { background: #fff; border-radius: 10px; padding: 40px; width: 100%;
             max-width: 420px; box-shadow: 0 4px 20px rgba(0,0,0,.1); }
.auth-logo { font-size: 20px; font-weight: 700; color: #1a56db; text-align: center;
             margin-bottom: 24px; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; text-align: center; }
.auth-subtitle { font-size: 14px; color: #64748b; text-align: center; margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }

/* ── Link style ─────────────────────────────────────────────── */
.link-primary { color: #1a56db; font-weight: 500; }

/* ── Kanban / Pipeline ──────────────────────────────────────── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }

.kanban-col {
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: 3px solid #94a3b8;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.kanban-col-title { font-size: 13px; font-weight: 700; color: #1a202c; }
.kanban-col-count {
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

.kanban-cards {
  min-height: 160px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background .15s;
}

.kanban-cards.drag-over { background: #eff6ff; border-color: #93c5fd; }

.kanban-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

.kanban-card:hover       { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.kanban-card.dragging    { opacity: .45; cursor: grabbing; }
.kanban-card:active      { cursor: grabbing; }

.kanban-card-num  { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.kanban-card-num a { color: #1a56db; }
.kanban-card-client { font-size: 13px; color: #1a202c; font-weight: 500; margin-bottom: 8px; line-height: 1.3; }

.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
}
.kanban-card-total { font-size: 12px; }

.kanban-card-warning {
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.kanban-card-warning.expired  { background: #fee2e2; color: #991b1b; }
.kanban-card-warning.expiring { background: #fef3c7; color: #92400e; }

.kanban-empty {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
  padding: 24px 8px;
  border: 1px dashed #e2e8f0;
  border-radius: 6px;
}

/* Toast */
.kanban-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: #1e293b;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 999;
}
.kanban-toast.show { opacity: 1; transform: translateY(0); }
.kanban-toast.success { background: #065f46; }
.kanban-toast.error   { background: #991b1b; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .stats-grid, .revenue-grid, .tables-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-col { flex: 0 0 auto; width: 100%; }
}
