:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-layout.hidden,
.hidden {
  display: none !important;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 20px;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 400px;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand h2 {
  font-size: 20px;
  font-weight: 800;
  color: #111827;
}

.login-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.login-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.back-site-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.back-site-link:hover {
  text-decoration: underline;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.user-pill {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 600;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: #9ca3af;
}

.nav-menu {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 24px 32px;
  max-width: calc(100vw - 260px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h2 {
  font-size: 22px;
  font-weight: 700;
}

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards & Stats */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 20px;
}

/* Stock List */
.stock-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
}

.stock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stock-item-title {
  font-weight: 600;
  font-size: 13px;
}

.stock-item-cat {
  font-size: 11px;
  color: var(--text-muted);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f9fafb;
}

.data-table tr:hover td {
  background: #f9fafb;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
}

.badge-quote { background: #fef3c7; color: #92400e; }
.badge-reserved { background: #dbeafe; color: #1e40af; }
.badge-out { background: #ede9fe; color: #5b21b6; }
.badge-returned { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #f3f4f6; color: #4b5563; }
.badge-cat { background: #eff6ff; color: #1d4ed8; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #374151;
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-outline {
  background: #fff;
  border-color: #d1d5db;
  color: var(--text);
}
.btn-outline:hover {
  background: #f3f4f6;
}

.action-group {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.form-label-inline {
  font-size: 13px;
  font-weight: 600;
}

.form-input,
.form-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}
.input-with-btn select {
  flex: 1;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.modal-lg {
  max-width: 860px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #f9fafb;
  border-radius: 0 0 12px 12px;
}

/* Line Items inside Rental Modal */
.line-items-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  background: #f9fafb;
}

.line-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 12px;
}

.add-item-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 460px;
}

.add-item-bar select {
  flex: 1;
}

.rental-summary-footer {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 6px;
}

.summary-totals-box {
  width: 280px;
  background: #f3f4f6;
  padding: 12px 16px;
  border-radius: 8px;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.sum-row.grand {
  font-size: 16px;
  border-top: 1px solid #d1d5db;
  padding-top: 6px;
  margin-top: 6px;
  color: var(--primary);
}

.payment-banner {
  display: flex;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Document Generator Tabs & Printable Paper */
.doc-type-tabs {
  display: flex;
  background: #f3f4f6;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}

.doc-tab-btn {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}

.doc-tab-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.doc-preview-container {
  display: flex;
  justify-content: center;
  padding: 10px 0 40px;
}

.invoice-paper {
  background: #ffffff;
  width: 100%;
  max-width: 820px;
  min-height: 980px;
  padding: 48px 52px;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border);
  color: #111827;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #111827;
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.doc-biz-name {
  font-size: 22px;
  font-weight: 800;
  color: #111827;
}

.doc-biz-sub {
  font-size: 13px;
  color: #4b5563;
  font-weight: 600;
  margin-bottom: 6px;
}

.doc-biz-meta {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.4;
}

.doc-badge-box {
  text-align: right;
}

.doc-title-tag {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
}

.doc-ref-meta {
  margin-top: 10px;
  font-size: 12px;
  color: #374151;
}

.doc-info-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  background: #f9fafb;
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.doc-info-block h5 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 6px;
}

.doc-info-block p {
  font-size: 13px;
  margin-bottom: 2px;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.doc-table th {
  background: #111827;
  color: #ffffff;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  text-align: left;
}

.doc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}

.doc-totals-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 30px;
  margin-top: 16px;
}

.doc-terms-box {
  font-size: 11.5px;
  color: #4b5563;
  white-space: pre-line;
  line-height: 1.5;
}

.doc-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.doc-totals-table td {
  padding: 6px 8px;
  font-size: 13px;
}

.doc-totals-table tr.grand-row td {
  font-size: 16px;
  font-weight: 800;
  border-top: 2px solid #111827;
  border-bottom: 2px solid #111827;
  padding: 10px 8px;
}

.doc-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin-top: 56px;
  padding-top: 20px;
}

.sig-line {
  border-top: 1px solid #374151;
  padding-top: 6px;
  text-align: center;
  font-size: 12px;
  color: #4b5563;
}

.only-print {
  display: none;
}

@media print {
  body {
    background: #ffffff;
  }
  .no-print {
    display: none !important;
  }
  .only-print {
    display: block !important;
  }
  .invoice-paper {
    box-shadow: none;
    border: none;
    padding: 10px 20px;
    max-width: 100%;
    min-height: auto;
  }
}
