/* TNS CRM - Base styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Verdana, sans-serif; background: #f4f6fa; color: #1f2937; font-size: 14px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #0f172a; color: #cbd5e1; padding: 20px 0; }
.sidebar .brand { text-align: center; padding: 0 15px 20px; border-bottom: 1px solid #1e293b; }
.sidebar .brand img { max-width: 60px; margin-bottom: 8px; }
.sidebar .brand .logo-text { font-size: 26px; font-weight: 700; color: #fff; background: #2563eb; width: 60px; height: 60px; line-height: 60px; margin: 0 auto 8px; border-radius: 10px; }
.sidebar .brand-name { font-weight: 600; color: #fff; font-size: 13px; }
.sidebar nav { display: flex; flex-direction: column; margin-top: 15px; }
.sidebar nav a { padding: 11px 22px; color: #cbd5e1; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: #1e293b; color: #fff; text-decoration: none; border-left-color: #2563eb; }

.main { flex: 1; display: flex; flex-direction: column; }
.topbar { background: #fff; padding: 14px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.05); display: flex; justify-content: space-between; align-items: center; }
.topbar .page-title { font-size: 18px; font-weight: 600; }
.user-menu { display: flex; align-items: center; gap: 12px; }
.pill { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 10px; font-size: 11px; margin-left: 4px; }
.content { padding: 24px; flex: 1; }
.footer { padding: 12px 24px; text-align: center; color: #6b7280; font-size: 12px; border-top: 1px solid #e5e7eb; background: #fff; }

/* Alerts */
.alert { padding: 12px 16px; margin: 12px 24px; border-radius: 6px; font-size: 13px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Cards & Grids */
.card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.04); margin-bottom: 20px; }
.card h2 { font-size: 16px; margin-bottom: 14px; color: #111827; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; padding: 18px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat .label { color: #6b7280; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 22px; font-weight: 700; color: #111827; margin-top: 6px; }
.stat.pos .value { color: #059669; }
.stat.warn .value { color: #d97706; }
.stat.danger .value { color: #dc2626; }

/* Forms */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 12px; }
label { display: block; font-size: 12px; color: #374151; margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; background: #fff; color: #111827;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 70px; resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; background: #2563eb; color: #fff; display: inline-block; }
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-success { background: #059669; }
.btn-success:hover { background: #047857; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: #374151; border: 1px solid #d1d5db; }
.btn-ghost:hover { background: #f3f4f6; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Table */
table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
table.data th { background: #f9fafb; color: #374151; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
table.data tbody tr:hover { background: #f9fafb; }
table.data .actions a { margin-right: 8px; font-size: 12px; }

/* Status badges */
.badge { padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; display: inline-block; }
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-interested { background: #ede9fe; color: #6b21a8; }
.badge-demo { background: #fce7f3; color: #9d174d; }
.badge-won, .badge-paid, .badge-active, .badge-approved { background: #d1fae5; color: #065f46; }
.badge-lost, .badge-unpaid, .badge-rejected, .badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-partial, .badge-pending { background: #fef3c7; color: #92400e; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); }
.login-box { background: #fff; padding: 34px; border-radius: 10px; width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.login-box h1 { font-size: 22px; margin-bottom: 6px; color: #111827; text-align: center; }
.login-box .subtitle { color: #6b7280; text-align: center; margin-bottom: 22px; font-size: 13px; }
.login-box .form-row { display: block; margin-bottom: 12px; }
.login-box .btn { width: 100%; padding: 10px; font-size: 14px; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.toolbar .search { flex: 1; max-width: 300px; }

/* Invoice preview */
.invoice-box { background: #fff; max-width: 900px; margin: 20px auto; padding: 40px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.invoice-box .head { display: flex; justify-content: space-between; margin-bottom: 30px; align-items: flex-start; }
.invoice-box .head img.logo { max-height: 80px; }
.invoice-box .title { font-size: 32px; color: #2563eb; letter-spacing: 2px; font-weight: 700; }
.invoice-box .meta { text-align: right; font-size: 13px; }
.invoice-box .bill-to { margin: 20px 0; font-size: 13px; }
.invoice-box table.items { width: 100%; border-collapse: collapse; margin: 20px 0; }
.invoice-box table.items th { background: #2563eb; color: #fff; padding: 10px; text-align: left; font-size: 12px; }
.invoice-box table.items td { padding: 10px; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
.invoice-box .totals { width: 320px; margin-left: auto; font-size: 13px; }
.invoice-box .totals .row { display: flex; justify-content: space-between; padding: 6px 0; }
.invoice-box .totals .grand { border-top: 2px solid #111827; font-weight: 700; font-size: 15px; margin-top: 8px; padding-top: 10px; }
.invoice-box .footer-strip { display: flex; justify-content: space-between; margin-top: 40px; align-items: flex-end; }
.invoice-box .qr { text-align: center; font-size: 11px; }
.invoice-box .qr img { display: block; margin-bottom: 4px; }
.invoice-box .signature { text-align: center; font-size: 12px; }
.invoice-box .signature img { max-height: 60px; border-bottom: 1px solid #111; padding-bottom: 4px; margin-bottom: 4px; }
.invoice-box .notes { font-size: 12px; color: #6b7280; margin-top: 30px; border-top: 1px solid #e5e7eb; padding-top: 15px; }
.no-print { }
@media print {
  body { background: #fff; }
  .app, .sidebar, .topbar, .footer, .no-print { display: none !important; }
  .invoice-box { box-shadow: none; margin: 0; padding: 20px; max-width: 100%; }
  .content { padding: 0; }
}

/* Small helpers */
.mt-10 { margin-top: 10px; } .mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; } .mb-20 { margin-bottom: 20px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: #6b7280; font-size: 12px; }
