/* =========================================================
   ROOT / RESET
   ========================================================= */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --background: #f5f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
  --sidebar-text: #d1d5db;
  --success: #15803d;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--background);
  color: var(--text);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-layout {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
}

.app-main {
  margin-left: 250px;
  width: calc(100% - 250px);
  min-width: 0;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar-logo {
  height: 72px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  color: #fff;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary);
  display: grid;
  place-items: center;
  font-size: 13px;
}

.logo-text {
  font-size: 16px;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 25px;
}

.nav-section-title {
  padding: 0 12px;
  margin-bottom: 7px;
  color: #6b7280;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 14px;
  margin-bottom: 3px;
  transition: .15s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.sidebar-user {
  padding: 15px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar,
.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #374151;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}

.sidebar-user-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-user-info strong {
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info small {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 11px;
}

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
  min-height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 30px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.page-heading {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
}

.page-description {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-toggle {
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 21px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
  background: var(--primary);
}

.topbar-user-details {
  display: flex;
  flex-direction: column;
}

.topbar-user-details strong {
  font-size: 13px;
}

.topbar-user-details span {
  color: var(--muted);
  font-size: 11px;
}

.logout-link {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

/* =========================================================
   CONTENT
   ========================================================= */
.page-content {
  padding: 30px;
  max-width: 1600px;
  margin: 0 auto;
}

.dashboard-section {
  margin-top: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: 16px;
}

.section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.section-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

/* =========================================================
   STATISTICS
   ========================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 24px;
  line-height: 1;
}

/* =========================================================
   QUICK ACTIONS
   ========================================================= */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  align-items: center;
  gap: 13px;
  transition: .15s ease;
}

.quick-action:hover {
  border-color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.quick-action-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #eff6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 19px;
}

.quick-action strong {
  display: block;
  font-size: 13px;
}

.quick-action small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   TABLES
   ========================================================= */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  background: #f9fafb;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.table-subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.transaction-type {
  font-size: 12px;
  font-weight: 600;
}

.quantity-positive {
  color: var(--success);
  font-weight: 700;
}

.quantity-negative {
  color: var(--danger);
  font-weight: 700;
}

/* =========================================================
   EMPTY STATE
   ========================================================= */
.empty-state {
  padding: 50px 20px;
  text-align: center;
}

.empty-state strong {
  display: block;
  font-size: 14px;
}

.empty-state p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* =========================================================
   BREADCRUMB
   ========================================================= */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb a {
  color: var(--primary);
  font-weight: 600;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* =========================================================
   PAGE HEADER
   ========================================================= */
.page-section-header {
  margin-bottom: 22px;
}

.page-section-header .btn {
  white-space: nowrap;
}

/* =========================================================
   BUTTONS (consolidated — last-occurrence values win)
   ========================================================= */
.btn {
  height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: .7;
  cursor: not-allowed;
}

.btn-light {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-light:hover {
  background: #f9fafb;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn-small {
  min-height: 35px;
  padding: 7px 11px;
  font-size: 12px;
}

.form-actions-full .btn {
  width: 100%;
}

/* =========================================================
   INSTALLATION FILTERS (legacy)
   ========================================================= */
.installation-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  display: grid;
  grid-template-columns:
    minmax(240px, 2fr) repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
}

.filter-search {
  position: relative;
}

.filter-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.filter-search input,
.filter-group select,
.filter-group input,
.table-toolbar select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.filter-search input {
  padding: 0 12px 0 38px;
}

.filter-group select,
.filter-group input {
  padding: 0 11px;
}

.filter-search input:focus,
.filter-group select:focus,
.filter-group input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

/* =========================================================
   TABLE TOOLBAR
   ========================================================= */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-toolbar select {
  width: auto;
  min-width: 65px;
  height: 34px;
  padding: 0 8px;
}

.table-result-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.table-result-count strong {
  color: var(--text);
}

/* =========================================================
   SEARCH INPUT WRAPPER (consolidated — last wins)
   ========================================================= */
.search-input-wrapper {
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-input-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

/* =========================================================
   TABLE ACTIONS
   ========================================================= */
.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Link-style action (legacy) */
.table-action {
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
}

/* Icon-style action (button) */
.table-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--primary);
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: .15s ease;
  font-weight: 600;
  font-size: 12px;
}

.table-action svg {
  width: 16px;
  height: 16px;
}

.table-action:hover {
  background: #eff6ff;
}

.table-action-danger {
  color: var(--danger);
}

.table-action-danger:hover {
  background: #fef2f2;
}

/* =========================================================
   PAGINATION CONTAINER (legacy)
   ========================================================= */
.pagination-container {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.pagination-info {
  color: var(--muted);
  font-size: 12px;
}

/* =========================================================
   MODAL
   ========================================================= */
body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, .55);
  backdrop-filter: blur(2px);
}

.modal-backdrop[hidden] {
  display: none;
}

/* Support both `.show` and `[hidden]` mechanisms */
.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
  animation: modalIn .15s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(5px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 17px;
}

.modal-icon svg {
  width: 22px;
  height: 22px;
}

.modal-icon-danger {
  background: #fef2f2;
  color: var(--danger);
}

.modal-icon-success {
  background: #e6f7ee;
  color: #16a34a;
}

.modal-icon-error {
  background: #fdecea;
  color: #dc2626;
}

.modal-icon-warning {
  background: #fef6e7;
  color: #d97706;
}

.modal-icon-info {
  background: #e8f1fd;
  color: #2563eb;
}

.modal h2,
.modal-content h2 {
  margin: 0;
  font-size: 18px;
}

.modal-description,
.modal-content p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-description strong {
  color: var(--text);
}

.modal-warning {
  margin-top: 13px;
  padding: 11px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.5;
}

.modal-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

/* =========================================================
   FORM CARDS
   ========================================================= */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.form-card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.form-card-header h2 {
  font-size: 16px;
  margin: 0;
}

.form-card-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-card-body {
  padding: 22px;
}

/* =========================================================
   FORM GRID
   ========================================================= */
.form-grid {
  display: grid;
  gap: 18px;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* =========================================================
   FORM GROUP
   ========================================================= */
.form-group {
  margin-bottom: 18px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.required {
  color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-group input,
.form-group select {
  height: 42px;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.form-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   READONLY INSTALLER
   ========================================================= */
.readonly-field {
  min-height: 42px;
  border: 1px solid var(--border);
  background: #f9fafb;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.readonly-field strong {
  font-size: 13px;
}

.readonly-field span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   TRACKER INPUTS
   ========================================================= */
.tracker-input-row {
  margin-bottom: 12px;
}

.input-with-status {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-status .tracker-input {
  padding-right: 42px;
}

.remove-tracker {
  position: absolute;
  right: 7px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: #fee2e2;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.remove-tracker:hover {
  background: #fecaca;
}

.tracker-help {
  margin-top: 12px;
}

.tracker-list {
  display: flex;
  column-gap: 16px;
}

/* =========================================================
   FORM MESSAGES
   ========================================================= */
.form-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.form-message-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.form-message-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* =========================================================
   FORM ACTIONS
   ========================================================= */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 5px;
}

/* =========================================================
   PRELOADER
   ========================================================= */
.page-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, visibility .15s ease;
}

.page-preloader.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.preloader-box {
  width: 220px;
  padding: 24px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .10);
  text-align: center;
}

.preloader-box strong {
  display: block;
  margin-top: 14px;
  font-size: 14px;
}

.preloader-box span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.preloader-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: preloaderSpin .7s linear infinite;
}

@keyframes preloaderSpin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   INPUT ERROR
   ========================================================= */
.input-error {
  border-color: var(--danger) !important;
  background: #fff7f7 !important;
}

/* =========================================================
   INSTALLATION TOOLBAR (consolidated — flexbox wins)
   ========================================================= */
.installation-toolbar-card {
  margin-bottom: 18px;
}

.installation-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: flex-start;
  align-items: flex-end;
  padding: 18px;
}

.installation-toolbar>div {
  flex: 0 0 130px;
}

.installation-toolbar>.filter-lg {
  flex: 0 0 200px;
}

.installation-toolbar>.filter-md {
  flex: 0 0 180px;
}

.installation-toolbar> :first-child {
  grid-column: span 2;
}

.installation-search {
  min-width: 0;
}

.filter-label {
  display: block;
  margin-bottom: 6px;
  color: #4b5563;
  font-size: 11px;
  font-weight: 700;
}

.filter-control {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
}

.filter-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.filter-reset-wrapper {
  display: flex;
  align-items: flex-end;
}

.installation-toolbar .filter-reset-wrapper {
  display: flex;
  gap: 20px;
}

/* =========================================================
   TABLE NUMBER / CODE
   ========================================================= */
.table-number {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table-code {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  font-size: 11px;
  color: #374151;
}

/* =========================================================
   TABLE FOOTER
   ========================================================= */
.table-footer {
  min-height: 64px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.table-count {
  color: var(--muted);
  font-size: 11px;
}

/* =========================================================
   PAGINATION (consolidated — last wins)
   ========================================================= */
.pagination {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pagination-button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #374151;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pagination-button:hover:not(:disabled) {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary);
}

.pagination-button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.pagination-button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* =========================================================
   TABLE LOADER
   ========================================================= */
.installation-table-card,
.installer-table-card,
.stock-table-card {
  position: relative;
}

.table-loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(1px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
}

.table-loader[hidden] {
  display: none;
}

.loader-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: installation-spin .7s linear infinite;
}

@keyframes installation-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   DETAILS GRID / CARDS / BADGES
   ========================================================= */
.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row .k {
  color: var(--muted);
}

.detail-row .v {
  font-weight: 600;
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.badge-danger {
  background: #fceded;
  color: var(--danger);
  border-color: currentColor;
}

.badge.badge-success {
  background: #edfcf3;
  color: var(--success);
  border-color: currentColor;
}

.badge.badge-info {
  background: #eef2fc;
  color: var(--primary);
  border-color: currentColor;
}

.badge.badge-warning {
  background: #ffffff;
  color: var(--warning);
  border-color: currentColor;
}

/* =========================================================
   REPORTS — BAR BREAKDOWNS
   ========================================================= */
.report-toolbar {
  padding: 18px;
  display: grid;
  grid-template-columns:
    minmax(160px, 1fr) minmax(140px, 160px) minmax(140px, 160px) repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.report-toolbar[data-custom="false"] .report-date-field {
  display: none;
}

.report-range-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 18px;
}

.report-range-label strong {
  color: var(--text);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 140px) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.bar-row .bar-label {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 8px;
  border-radius: 5px;
  background: #f0f1f3;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--primary);
}

.bar-value {
  color: var(--muted);
  font-weight: 700;
  min-width: 28px;
  text-align: right;
}

.status-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 50px;
  background: #f9fafb;
  border: 1px solid var(--border);
  font-size: 12px;
}

.status-pill strong {
  font-size: 13px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =========================================================
   AUTH PAGES (login / register)
   ========================================================= */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--background);
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 24px;
}

.auth-logo .logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.auth-logo .logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-card-header {
  padding: 26px 28px 0;
  text-align: center;
}

.auth-card-header h1 {
  font-size: 20px;
  margin: 0;
}

.auth-card-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-card-body {
  padding: 26px 28px 28px;
}

.auth-divider {
  margin: 20px 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.auth-divider a {
  color: var(--primary);
  font-weight: 600;
}

.auth-card-footer {
  padding: 0 28px 26px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.auth-card-footer a {
  color: var(--primary);
  font-weight: 600;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.password-toggle:hover {
  background: #f3f4f6;
  color: var(--text);
}

.password-toggle svg {
  width: 17px;
  height: 17px;
}

/* =========================================================
   NOTIFICATION
   ========================================================= */
.notification-bell {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: .15s ease;
}

.notification-bell:hover {
  background: #f3f4f6;
  color: var(--text);
}

.notification-bell svg {
  width: 20px;
  height: 20px;
}

.notification-bell.has-unseen {
  color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 50px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notification-badge[hidden] {
  display: none;
}

/* =========================================================
   SEARCHABLE COMBOBOX
   ========================================================= */
.combobox {
  position: relative;
}

.combobox-input {
  width: 100%;
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.combobox-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .10);
}

.combobox-dropdown[hidden] {
  display: none;
}

.combobox-option {
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.combobox-option:hover,
.combobox-option.is-active {
  background: #eff6ff;
}

.combobox-option-sub {
  font-size: 11px;
  color: var(--muted);
}

.combobox-option-create {
  color: var(--primary);
  font-weight: 600;
  border-top: 1px solid var(--border);
}

.combobox-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.combobox-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}

.combobox-clear:hover {
  background: #d1d5db;
  color: #374151;
}

.combobox-clear[hidden] {
  display: none;
}

/* =========================================================
   TABLE MIN-WIDTHS
   ========================================================= */
.stock-history-table-card .data-table,
.activity-log-table-card .data-table {
  min-width: 1200px;
}

.installation-table-card .data-table {
  min-width: 1500px;
}

.notes-table-card .data-table {
  min-width: 1100px;
}

.user-table-card .data-table {
  min-width: 1000px;
}

.maintenance-table-card .data-table {
  min-width: 1400px;
}

.installer-table-card .data-table,
.stock-table-card .data-table {
  min-width: 850px;
}

/* =========================================================
   TABLE COLUMN WIDTHS
   ========================================================= */
.th-xsm {
  width: 60px;
}

.th-sm {
  width: 120px;
}

.th-md {
  width: 180px;
}

.th-lg {
  width: 200px;
}

.th-xl {
  width: 300px;
}

.th-2xl {
  width: 300px;
}

/* =========================================================
   UTILITIES
   ========================================================= */
@media (min-width: 768px) {
  .maxw-50-md {
    max-width: calc(50% - 16px);
  }
}

/* =========================================================
   RESPONSIVE — merged by breakpoint
   ========================================================= */

/* 1250px */
@media (max-width: 1250px) {
  .installation-toolbar {
    grid-template-columns: repeat(3, 1fr);
  }

  .installation-search {
    grid-column: span 3;
  }

  .report-toolbar {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 1200px */
@media (max-width: 1200px) {
  .installation-filters {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

/* 1100px */
@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* 800px */
@media (max-width: 800px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
    width: 100%;
  }

  .sidebar-toggle {
    display: block;
  }

  .topbar {
    padding: 12px 18px;
  }

  .topbar-user-details {
    display: none;
  }

  .page-content {
    padding: 20px 16px;
  }

  .installation-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .installation-search {
    grid-column: span 2;
  }

  .filter-reset-wrapper {
    grid-column: span 2;
  }

  .filter-reset-wrapper .btn {
    width: 100%;
  }

  .table-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* 700px */
@media (max-width: 700px) {
  .installation-filters {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination-container {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .modal {
    padding: 22px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-card-body {
    padding: 18px;
  }

  .form-card-header {
    padding: 16px 18px;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn {
    width: 100%;
  }

  .report-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .filter-reset-wrapper {
    grid-column: span 2;
  }

  .filter-reset-wrapper .btn {
    width: 100%;
  }
}

/* 600px */
@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .topbar-right {
    gap: 10px;
  }

  .page-heading {
    font-size: 18px;
  }
}

/* 500px */
@media (max-width: 500px) {
  .installation-toolbar {
    grid-template-columns: 1fr;
  }

  .installation-search,
  .filter-reset-wrapper {
    grid-column: auto;
  }

  .pagination {
    width: 100%;
    justify-content: center;
  }
}

/* 480px */
@media (max-width: 480px) {

  .auth-card-header,
  .auth-card-body,
  .auth-card-footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .auth-divider {
    margin-left: 20px;
    margin-right: 20px;
  }
}

/* 440px */
@media (max-width: 440px) {
  .installation-toolbar>.filter-lg {
    flex: 0 0 100%;
  }

  .installation-toolbar>div {
    flex: 1 0 150px;
  }
}

/* =========================================================
   LANDING PAGE
   ========================================================= */
.landing-page {
  min-height: 100vh;
  background: var(--background);
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 30px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.landing-nav .logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.landing-nav-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.landing-hero {
  max-width: 780px;
  margin: 0 auto;
  padding: 90px 24px 60px;
  text-align: center;
}

.landing-hero h1 {
  font-size: 34px;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.landing-hero p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 auto 30px;
  max-width: 560px;
}

.landing-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.landing-features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 90px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.landing-feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.landing-feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.landing-feature-card h3 {
  font-size: 14px;
  margin: 0 0 6px;
}

.landing-feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.landing-footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .landing-features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .landing-nav {
    padding: 16px 18px;
  }

  .landing-hero {
    padding: 60px 18px 40px;
  }

  .landing-hero h1 {
    font-size: 26px;
  }

  .landing-features {
    grid-template-columns: 1fr;
    padding: 0 18px 60px;
  }
}

.entry-row{display:grid;grid-template-columns:28px minmax(0,1fr) minmax(0,1fr) 150px 42px;gap:12px;align-items:end;margin-bottom:14px}
.entry-row .form-group{margin-bottom:0}
.entry-index{height:42px;line-height:42px;text-align:center;color:var(--muted);font-size:12px;font-weight:700}
.entry-remove{width:42px;height:42px;border:0;border-radius:8px;background:#fee2e2;color:var(--danger);font-size:20px;line-height:1;cursor:pointer}
.entry-remove:hover{background:#fecaca}
.entry-chips{display:flex;flex-wrap:wrap;gap:6px;max-width:560px}
.entry-chip{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border:1px solid var(--border);border-radius:6px;background:#f9fafb;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:11px;color:#374151}
.entry-chip small{color:var(--muted);font-weight:700}
.entry-chip-more{background:#eff6ff;border-color:#bfdbfe;color:var(--primary);font-family:inherit;font-weight:600}
a.pagination-button{display:inline-flex;align-items:center;justify-content:center}
.data-table tfoot td{padding:14px 16px;background:#f9fafb;border-top:1px solid var(--border);font-weight:700}
@media (max-width:800px){
  .entry-row{grid-template-columns:1fr 1fr}
  .entry-index{grid-column:1/-1;height:auto;line-height:1.2;text-align:left}
  .entry-remove{justify-self:end}
}

.check-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.check-box{display:flex;align-items:flex-start;gap:12px;padding:14px 16px;border:1px solid var(--border);border-radius:10px;background:#fff;cursor:pointer}
.check-box input{width:18px;height:18px;margin-top:2px;accent-color:var(--primary);flex-shrink:0}
.check-box strong{display:block;font-size:13px}
.check-box small{display:block;margin-top:3px;color:var(--muted);font-size:11px;line-height:1.5}
.receipt-cell{display:flex;flex-direction:column;gap:8px}
.receipt-check{display:flex;align-items:flex-start;gap:7px;font-size:12px;cursor:pointer;white-space:nowrap}
.receipt-check input{width:15px;height:15px;margin-top:1px;accent-color:var(--primary)}
.receipt-check small{display:block;color:var(--muted);font-size:10px}
@media (max-width:700px){.check-grid{grid-template-columns:1fr}}