/* Paver Block ERP — styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #b91c1c;
  --primary-dark: #7f1d1d;
  --primary-light: #fef2f2;
  --accent: #f59e0b;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.success-msg { color: var(--success); font-size: 13px; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* === LOGIN === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
  padding: 20px;
}
.login-card {
  background: white;
  padding: 40px 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  text-align: center;
}
.login-logo { margin-bottom: 16px; display: flex; justify-content: center; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; color: var(--text); }
.login-card form { margin-top: 24px; text-align: left; }
.login-card label {
  display: block; font-size: 13px; color: var(--text-muted);
  margin-bottom: 6px; font-weight: 500;
}
.login-card input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 8px;
  outline: none; transition: border-color .15s;
}
.login-card input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; padding: 12px; margin-top: 16px;
  background: var(--primary); color: white;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.login-hint { margin-top: 20px; font-size: 12px; }

/* === APP SHELL === */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 50; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand-sub { font-size: 12px; opacity: .85; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.sync-pill {
  background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.btn-ghost {
  background: rgba(255,255,255,0.12); color: white;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.only-mobile { display: none; }

.sidenav {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  z-index: 40;
}
.nav-btn {
  background: transparent; border: none; padding: 12px 14px;
  text-align: left; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text); transition: all .15s;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-btn .hi { font-size: 11px; color: var(--text-muted); }
.nav-btn:hover { background: var(--primary-light); }
.nav-btn.active { background: var(--primary); color: white; }
.nav-btn.active .hi { color: rgba(255,255,255,0.85); }

.main-content {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 20px; min-height: calc(100vh - var(--topbar-h));
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-title small { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* === KPI CARDS === */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); padding: 18px 20px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-card.profit .kpi-value { color: var(--success); }
.kpi-card.loss .kpi-value { color: var(--danger); }
.kpi-card.due .kpi-value { color: var(--warn); }

.row-cols { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 880px) { .row-cols { grid-template-columns: 1fr; } }

/* === CARDS === */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 15px; font-weight: 600; margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}

/* === TABLES === */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  background: #f9fafb; padding: 10px 12px; text-align: left;
  font-weight: 600; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:hover td { background: #f9fafb; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { white-space: nowrap; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.tag-due { background: #fef3c7; color: #92400e; }
.tag-paid { background: #d1fae5; color: #065f46; }
.tag-partial { background: #fef3c7; color: #92400e; }
.tag-cat {
  background: #e0e7ff; color: #3730a3;
}

/* === BUTTONS === */
.btn {
  background: var(--primary); color: white; border: none;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: background .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-icon {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 4px 8px;
  border-radius: 6px; cursor: pointer; font-size: 12px;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* === FORMS === */
.form-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group label .hi { font-weight: 400; opacity: .8; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px;
  outline: none; background: white;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(185,28,28,0.1);
}
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px; flex-wrap: wrap;
}
.full-width { grid-column: 1 / -1; }

/* === FILTERS BAR === */
.filters-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; align-items: center;
}
.filters-bar input, .filters-bar select {
  padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: white; outline: none;
}
.filters-bar input { min-width: 200px; }

/* === MODAL === */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  animation: fadein .15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white; border-radius: 12px;
  width: 100%; max-width: 600px; max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--text-muted); padding: 0; width: 32px; height: 32px;
  border-radius: 6px;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 22px; }

/* === TOAST === */
#toast-root {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text); color: white; padding: 12px 18px;
  border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
  min-width: 240px;
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); color: #111; }

/* === CHARTS === */
.bar-chart {
  display: flex; gap: 8px; align-items: flex-end;
  min-height: 200px; padding: 12px 0;
  overflow-x: auto;
}
.bar {
  flex: 1; min-width: 30px; background: var(--primary);
  border-radius: 4px 4px 0 0; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; min-height: 4px;
  transition: opacity .15s;
}
.bar:hover { opacity: .8; }
.bar .bar-label {
  position: absolute; bottom: -22px; font-size: 10px;
  color: var(--text-muted); white-space: nowrap;
}
.bar .bar-value {
  position: absolute; top: -18px; font-size: 10px;
  color: var(--text); font-weight: 600; white-space: nowrap;
}
.bar.exp { background: var(--accent); }

/* === MOBILE === */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidenav {
    width: 240px; transform: translateX(-100%); transition: transform .2s;
  }
  .sidenav.open { transform: translateX(0); box-shadow: 0 8px 25px rgba(0,0,0,0.2); }
  .main-content { margin-left: 0; padding: 14px; }
  .only-mobile { display: inline-flex; }
  .topbar-actions .btn-ghost:not(.only-mobile) span { display: none; }
  .filters-bar input { min-width: 140px; flex: 1; }
  table.data th, table.data td { padding: 8px 10px; font-size: 12px; }
  .topbar { padding: 0 12px; }
  .brand-sub { display: none; }
}

/* === PRINT === */
@media print {
  .topbar, .sidenav, .filters-bar, .form-actions, .actions, #toast-root, button { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; }
}

.print-challan {
  background: white; padding: 30px; max-width: 700px; margin: 20px auto;
  border: 2px solid #333; font-family: 'Courier New', Courier, monospace;
}
.print-header { text-align: center; border-bottom: 2px solid #333; padding-bottom: 12px; margin-bottom: 16px; }
.print-header h1 { font-size: 22px; margin-bottom: 2px; }
.print-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dotted #ccc; font-size: 14px; }
.print-row strong { min-width: 180px; display: inline-block; }
.print-footer { text-align: center; margin-top: 20px; font-size: 12px; color: #666; }
.print-actions { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
@media print {
  .print-actions { display: none; }
  body * { visibility: hidden; }
  .print-challan, .print-challan * { visibility: visible; }
  .print-challan { position: absolute; left: 0; top: 0; border: none; }
}

/* utilities */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-end { justify-content: flex-end; }
.items-center { align-items: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.w-full { width: 100%; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.font-bold { font-weight: 700; }
