@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --brand-primary: #2563eb;
  --brand-primary-soft: rgba(44, 110, 242, 0.12);
  --brand-secondary: #0f172a;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --text-main: #111827;
  --text-soft: #334155;
  --text-muted: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.07);
}

* {
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  background: #f4f6f8;
  color: var(--text-main);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.95rem;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.bg-light {
  background-color: #f4f6f8 !important;
}

a {
  color: var(--brand-primary);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--brand-secondary);
  font-weight: 700;
  line-height: 1.22;
}

p {
  color: var(--text-soft);
}

.text-muted {
  color: var(--text-muted) !important;
}

.container-fluid {
  max-width: 1440px;
  padding-right: clamp(1rem, 2vw, 2rem);
  padding-left: clamp(1rem, 2vw, 2rem);
}

.flex-fill > .container-fluid {
  padding-top: 1.65rem !important;
  padding-bottom: 2.25rem !important;
}

.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:not(:disabled):not(.disabled).active,
.btn-primary.show,
.btn-primary.dropdown-toggle.show {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline-primary {
  color: var(--brand-primary);
}

.btn {
  border-radius: 0.45rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.52rem 0.86rem;
}

.btn-sm {
  padding: 0.38rem 0.68rem;
}

.btn-outline-secondary {
  border-color: #cbd5e1;
  color: #475569;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1f2937;
}

.navbar {
  min-height: 68px;
  box-shadow: var(--shadow-sm);
}

.navbar .input-group {
  max-width: 640px;
}

.navbar,
.offcanvas,
.card,
.table-responsive,
.drop-zone,
.form-control,
.form-select {
  border-color: var(--border);
}

.sidebar {
  min-width: 236px;
  max-width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.sidebar a.fs-4 {
  color: var(--brand-secondary) !important;
  font-size: 1.28rem !important;
  letter-spacing: 0;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.68rem 0.9rem;
  border-radius: 0.5rem;
  margin-bottom: 0.12rem;
  transition: background 0.18s ease, color 0.18s ease;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

.sidebar .nav-link .bi {
  width: 1.15rem;
  color: #64748b;
  font-size: 1rem;
  text-align: center;
}

.sidebar .nav-link.active .bi,
.sidebar .nav-link:hover .bi {
  color: var(--brand-primary);
}

.page-title {
  font-size: clamp(1.55rem, 1.6vw, 2rem);
  letter-spacing: 0;
}

.page-title + p {
  max-width: 680px;
}

.breadcrumb {
  font-size: 0.82rem;
  font-weight: 600;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--brand-primary);
}

.card-hero {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.card-hero h6,
.section-card h5 {
  font-size: 0.88rem;
}

.card-hero h3 {
  font-size: clamp(1.25rem, 1.4vw, 1.55rem);
}

.card-hero p,
.section-card p {
  font-size: 0.9rem;
}

.table thead {
  background: var(--surface-muted);
}

.table thead th {
  border-bottom: 1px solid var(--border);
  color: #475569;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.table tbody td {
  color: #1f2937;
  font-size: 0.91rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.table-hover tbody tr:hover {
  background: rgba(44, 110, 242, 0.06);
}

.badge-paid {
  background: #d1fae5;
  color: #047857;
}

.badge-draft {
  background: #f3f4f6;
  color: #475569;
}

.badge-overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-sent {
  background: #dbeafe;
  color: #1d4ed8;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.section-card .card-body {
  padding: clamp(1rem, 1.5vw, 1.45rem);
}

.form-label {
  color: #334155;
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.42rem;
}

.form-label .text-danger {
  margin-left: 0.15rem;
}

.input-group-text {
  background: var(--surface-muted);
  color: #475569;
  border-color: var(--border);
}

.form-control,
.form-select,
.input-group-text {
  min-height: 2.58rem;
  border-radius: 0.45rem;
  font-size: 0.93rem;
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
}

.dropdown-menu {
  border-color: var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
}

.dropdown-item {
  font-size: 0.92rem;
}

.badge {
  border-radius: 999px;
  font-weight: 700;
  padding: 0.42em 0.68em;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone.dragover {
  border-color: var(--brand-primary);
  background: rgba(44, 110, 242, 0.05);
}

.drop-zone p {
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

.drop-zone .bi {
  font-size: 2rem;
  color: var(--brand-primary);
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  background: var(--surface-muted);
  z-index: 1;
}

.badge-status {
  min-width: 4.5rem;
}

.rtl-input {
  direction: rtl;
  text-align: right;
}

.app-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1080;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  color: #ffffff;
  background: #0f172a;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  font-size: 0.92rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(0.75rem);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.invoice-preview {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.invoice-paper {
  width: min(100%, 920px);
  min-height: 1120px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  padding: clamp(1.5rem, 4vw, 3rem);
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #0f172a;
}

.invoice-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.invoice-brand img {
  width: 180px;
  max-width: 42vw;
  height: auto;
}

.invoice-brand h2 {
  margin: 0;
  font-size: 1.35rem;
}

.invoice-brand p,
.invoice-title-block p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}

.invoice-title-block {
  text-align: right;
}

.invoice-title-block h1 {
  margin: 0;
  color: #2563eb;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: 0;
}

.invoice-meta-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 0.8fr;
  gap: 1.25rem;
  margin: 2rem 0;
}

.invoice-meta-grid > div {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.invoice-meta-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-meta-grid strong {
  display: block;
  margin-top: 0.25rem;
  color: #0f172a;
}

.invoice-meta-grid p {
  margin: 0.45rem 0 0;
}

.invoice-lines {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.invoice-lines th {
  background: #0f172a;
  color: #ffffff;
  font-size: 0.78rem;
  padding: 0.85rem;
  text-transform: uppercase;
}

.invoice-lines td {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0.85rem;
  vertical-align: top;
}

.invoice-lines p {
  margin: 0.25rem 0 0;
}

.invoice-bottom {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  margin-top: 2rem;
}

.invoice-notes {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.invoice-notes h6 {
  margin-bottom: 0.5rem;
}

.invoice-notes p {
  margin: 0;
}

.invoice-totals {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.invoice-totals div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.invoice-totals div:last-child {
  border-bottom: 0;
}

.invoice-total {
  background: #2563eb;
  color: #ffffff;
  font-size: 1.08rem;
}

.invoice-total span,
.invoice-total strong {
  color: #ffffff;
}

.invoice-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media print {
  .sidebar,
  .navbar,
  .invoice-screen-actions {
    display: none !important;
  }

  body,
  .bg-light {
    background: #ffffff !important;
  }

  .flex-fill > .container-fluid {
    max-width: none;
    padding: 0 !important;
  }

  .invoice-paper {
    width: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 991.98px) {
  .sidebar {
    display: none;
  }

  .invoice-meta-grid,
  .invoice-bottom {
    grid-template-columns: 1fr;
  }

  .invoice-title-block {
    text-align: left;
  }

  .invoice-header {
    flex-direction: column;
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 0.92rem;
  }

  .top-actions {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }

  .top-actions .btn,
  .top-actions a.btn {
    width: 100%;
  }

  .section-card .card-body {
    padding: 1rem;
  }
}
