:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-strong: #eef2ff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ef;
  --primary: #1d4ed8;
  --primary-strong: #1e3a8a;
  --primary-soft: #dbeafe;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 294px;
  --topbar-height: 74px;
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; min-height: 100%; margin: 0; }
body {
  background: radial-gradient(circle at top right, rgba(29, 78, 216, 0.11), transparent 30%), var(--bg);
  color: var(--text);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.app-shell { height: 100vh; min-height: 100vh; overflow: hidden; }
.shell-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  min-height: 0;
  background: transparent;
}
.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 55%, #0b1222 100%);
  color: #ffffff;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 12px 0 35px rgba(15, 23, 42, 0.16);
  overflow-y: auto;
  max-height: 100vh;
  scrollbar-gutter: stable;
}
.brand {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
}
.brand img { width: 58px; height: 58px; object-fit: contain; border-radius: 16px; background: #fff; padding: 6px; }
.brand-title { font-weight: 900; letter-spacing: 0.2px; font-size: 15px; }
.brand-subtitle { margin-top: 4px; color: rgba(255,255,255,.70); font-size: 12px; line-height: 1.45; }
.nav-section-title { color: rgba(255,255,255,.52); font-size: 12px; font-weight: 800; margin: 8px 10px 4px; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border-radius: 14px;
  color: rgba(255,255,255,.84);
  background: transparent;
  text-align: right;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.nav-button:hover { background: rgba(255,255,255,.09); transform: translateX(-2px); color: #fff; }
.nav-button.is-active { background: #ffffff; color: #0f172a; box-shadow: 0 8px 18px rgba(0,0,0,.18); }
.nav-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: rgba(255,255,255,.10); }
.nav-button.is-active .nav-icon { background: var(--primary-soft); color: var(--primary); }
.nav-label { font-weight: 800; font-size: 14px; }
.nav-badge { font-size: 11px; border-radius: 999px; padding: 3px 8px; background: rgba(255,255,255,.12); color: rgba(255,255,255,.72); }
.nav-button.is-active .nav-badge { background: #e2e8f0; color: #334155; }
.sidebar-footer { margin-top: auto; color: rgba(255,255,255,.58); font-size: 12px; padding: 10px 12px; line-height: 1.65; }
.main-shell { min-width: 0; min-height: 0; height: 100vh; overflow: hidden; display: grid; grid-template-rows: var(--topbar-height) minmax(0, 1fr); }
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255,255,255,.74);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(219, 227, 239, .85);
}
.topbar-title { display: grid; gap: 3px; }
.topbar-title strong { font-size: 18px; }
.topbar-title span { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill, .action-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 800; font-size: 12px;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(22, 163, 74, .12); }
.action-pill { background: var(--primary); color: #fff; border-color: var(--primary); }
.content-area { min-height: 0; height: calc(100vh - var(--topbar-height)); overflow-y: scroll; overflow-x: hidden; padding: 24px; overscroll-behavior: contain; scrollbar-gutter: stable both-edges; }
.content-area::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.content-area::-webkit-scrollbar-track, .sidebar::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: rgba(226, 232, 240, .75); }
.content-area::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .55); border-radius: 999px; border: 3px solid rgba(226, 232, 240, .75); }
.content-area { scrollbar-width: auto; }

.page { display: none; animation: fadeIn .16s ease both; }
.page.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px;
}
.page-eyebrow { color: var(--primary); font-weight: 900; font-size: 12px; margin-bottom: 6px; }
.page-title { margin: 0; font-size: 28px; line-height: 1.25; letter-spacing: -0.2px; }
.page-description { margin: 8px 0 0; color: var(--muted); line-height: 1.7; max-width: 900px; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 16px; margin-bottom: 18px; }
.card-grid.three { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.card-grid.two { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.metric-card, .panel, .placeholder-card {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(219, 227, 239, .95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.metric-card { padding: 18px; min-height: 120px; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 800; }
.metric-value { margin-top: 8px; font-size: 30px; font-weight: 900; letter-spacing: -0.4px; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-title { margin: 0 0 12px; font-size: 18px; }
.panel-subtitle { color: var(--muted); margin: -4px 0 16px; line-height: 1.7; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 900; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 14px; min-height: 44px; padding: 10px 13px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(29, 78, 216, .12); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 14px; border-radius: 13px; font-weight: 900; }
.button.primary { background: var(--primary); color: #fff; }
.button.secondary { background: #e2e8f0; color: #0f172a; }
.button.success { background: var(--success); color: #fff; }
.button.warning { background: var(--warning); color: #fff; }
.button.danger { background: var(--danger); color: #fff; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { background: #f8fafc; color: #475569; font-size: 12px; font-weight: 900; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 900; }
.badge.mvp { background: #dcfce7; color: #166534; }
.badge.phase { background: #fef3c7; color: #92400e; }
.badge.shell { background: #dbeafe; color: #1e40af; }
.placeholder-card { padding: 22px; min-height: 190px; display: grid; align-content: center; gap: 12px; }
.placeholder-card strong { font-size: 20px; }
.placeholder-card p { margin: 0; color: var(--muted); line-height: 1.75; max-width: 780px; }
.notice {
  border: 1px solid #bfdbfe; background: #eff6ff; color: #1e3a8a; padding: 13px 15px; border-radius: 16px; line-height: 1.7; margin-bottom: 16px; font-weight: 700;
}
.notice.warning { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.split-layout { display: grid; grid-template-columns: 1.35fr .85fr; gap: 16px; align-items: start; }
.cart-box { min-height: 320px; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: 12px; }
.product-tile { border: 1px solid var(--border); background: #fff; border-radius: 16px; padding: 12px; min-height: 94px; display: grid; gap: 8px; }
.product-tile strong { font-size: 14px; }
.product-tile span { color: var(--muted); font-size: 12px; }
.mobile-menu-button { display: none; }
.hidden { display: none !important; }
@media (max-width: 1100px) {
  :root { --sidebar-width: 248px; }
  .card-grid, .card-grid.three { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .shell-layout { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 20; transform: translateX(-105%); transition: transform .18s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main-shell { min-height: 100vh; height: auto; overflow: visible; }
  .topbar { padding: 0 14px; gap: 10px; }
  .mobile-menu-button { display: inline-flex; }
  .topbar-title span { display: none; }
  .content-area { height: auto; min-height: calc(100vh - var(--topbar-height)); overflow: visible; padding: 16px; }
  .page-header { display: grid; }
  .card-grid, .card-grid.three, .card-grid.two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
}

/* Step 03 — IndexedDB status UI */
.metric-value.small { font-size: 20px; line-height: 1.45; }
.db-pill { background: #eef2ff; color: #1e3a8a; border-color: #c7d2fe; }
.db-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.db-info-grid > div {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-soft);
}
.db-info-grid strong { color: var(--muted); font-size: 12px; }
.db-info-grid span { font-weight: 900; overflow-wrap: anywhere; }
.db-info-grid.compact { grid-template-columns: repeat(3, minmax(160px, 1fr)); margin-bottom: 0; }
@media (max-width: 820px) {
  .db-info-grid, .db-info-grid.compact { grid-template-columns: 1fr; }
}

/* Step 05 — Login, session and role-aware UI */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top right, rgba(212, 175, 55, .18), transparent 34%),
    linear-gradient(145deg, #07101f 0%, #111827 48%, #0f172a 100%);
}
.login-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(226, 232, 240, .9);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .25);
  border-radius: 28px;
  padding: 28px;
}
.login-card.compact { text-align: center; }
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 14px; }
.login-logo-wrap img { max-width: 150px; max-height: 94px; object-fit: contain; }
.login-heading { text-align: center; margin-bottom: 18px; }
.login-heading h1, .login-card h1 { margin: 0; font-size: 30px; }
.login-heading p, .login-card p { color: var(--muted); line-height: 1.8; margin: 8px 0 0; }
.login-form { display: grid; gap: 13px; }
.login-button { width: 100%; min-height: 48px; }
.check-line { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; font-size: 13px; }
.login-footnote { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 11px; font-weight: 800; }
.login-footnote span { padding: 5px 8px; border-radius: 999px; background: #f1f5f9; }
.loader-bar { height: 8px; overflow: hidden; border-radius: 999px; background: #e2e8f0; margin-top: 18px; }
.loader-bar span { display: block; height: 100%; width: 42%; border-radius: inherit; background: var(--primary); animation: loader-slide 1.15s infinite ease-in-out; }
@keyframes loader-slide { 0% { transform: translateX(135%); } 100% { transform: translateX(-250%); } }
.user-mini-card {
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.06);
  border-radius: 16px;
  padding: 11px 12px;
  margin: 10px 2px 16px;
}
.user-mini-card span { display: block; color: #94a3b8; font-size: 11px; font-weight: 900; margin-bottom: 5px; }
.user-mini-card strong { display: block; color: #fff; font-size: 12px; line-height: 1.6; }
.user-pill { background: #f8fafc; color: #0f172a; }
.small-button { min-height: 34px; padding: 6px 10px; border-radius: 11px; }
.permission-list { display: flex; flex-wrap: wrap; gap: 8px; }
.permission-chip { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 10px; border-radius: 999px; background: #eef2ff; color: #1e3a8a; border: 1px solid #c7d2fe; font-size: 12px; font-weight: 900; }

/* Step 06 — Products, categories and inventory */
.card-grid.four { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.stacked-form { display: grid; gap: 14px; }
.wide-field { grid-column: span 2; }
.readonly-input { background: #f8fafc; color: #475569; font-weight: 900; }
.form-actions { margin: 2px 0 0; }
.form-status { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 10px; border-radius: 999px; background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 900; }
.form-status[data-mode="success"] { background: #dcfce7; color: #166534; }
.form-status[data-mode="error"] { background: #fee2e2; color: #991b1b; }
.form-status[data-mode="info"] { background: #dbeafe; color: #1e40af; }
.category-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .65fr) auto auto; align-items: end; margin-bottom: 0; }
.product-filter-bar { align-items: stretch; }
.product-filter-bar .search-input { min-width: min(360px, 100%); flex: 1 1 320px; }
.quantity-pill { display: inline-flex; min-width: 52px; justify-content: center; padding: 5px 9px; border-radius: 999px; background: #eef2ff; color: #1e3a8a; font-weight: 900; }
.quantity-pill.danger { background: #fee2e2; color: #991b1b; }
.row-warning td { background: #fff7ed; }
@media (max-width: 1100px) {
  .card-grid.four { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .wide-field { grid-column: span 1; }
  .category-toolbar { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .card-grid.four { grid-template-columns: 1fr; }
}

/* Step 07 — Sales, invoices and stock deduction */
.sales-layout { grid-template-columns: minmax(520px, 1.05fr) minmax(420px, .95fr); }
.sales-product-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); max-height: 560px; overflow: auto; padding-left: 4px; }
.sale-product-tile { text-align: right; cursor: pointer; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease; }
.sale-product-tile:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 10px 22px rgba(15, 23, 42, .08); }
.compact-table-wrap table { min-width: 560px; }
.cart-table th, .cart-table td { padding: 10px 9px; }
.cart-qty-input { min-height: 36px; width: 86px; padding: 6px 9px; border-radius: 11px; text-align: center; font-weight: 900; }
.sales-form-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.readonly-total {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 13px;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 14px;
  font-weight: 900;
}
.primary-total { background: #eef2ff; color: #1e3a8a; border-color: #c7d2fe; }
.muted-line { color: var(--muted); font-size: 11px; margin-top: 4px; }
@media (max-width: 1220px) {
  .sales-layout { grid-template-columns: 1fr; }
  .sales-product-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); max-height: none; }
}
@media (max-width: 820px) {
  .sales-product-grid { grid-template-columns: 1fr; }
  .sales-form-grid { grid-template-columns: 1fr; }
}

/* Step 10 — Customers, suppliers and purchases */
.parties-layout, .purchases-layout { grid-template-columns: minmax(440px, 1fr) minmax(440px, 1fr); }
.purchase-product-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); max-height: 560px; overflow: auto; padding-left: 4px; }
.purchase-product-tile { text-align: right; cursor: pointer; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease; }
.purchase-product-tile:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: 0 10px 22px rgba(15, 23, 42, .08); }
.purchase-head-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
.purchase-total-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
.purchase-line-input { min-height: 36px; width: 96px; padding: 6px 9px; border-radius: 11px; text-align: center; font-weight: 900; }
.purchase-cart-table th, .purchase-cart-table td { padding: 10px 8px; }
@media (max-width: 1220px) {
  .parties-layout, .purchases-layout { grid-template-columns: 1fr; }
  .purchase-product-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); max-height: none; }
}
@media (max-width: 820px) {
  .purchase-product-grid { grid-template-columns: 1fr; }
  .purchase-head-grid, .purchase-total-grid { grid-template-columns: 1fr; }
}


/* Step 16 — Runtime stability and client testing polish */
.runtime-error-banner {
  position: fixed;
  inset-inline: 18px;
  top: 16px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 18px;
  background: rgba(254, 242, 242, 0.98);
  color: #7f1d1d;
  box-shadow: 0 18px 45px rgba(127, 29, 29, 0.18);
}
.runtime-error-banner strong,
.runtime-error-banner span,
.runtime-error-banner small { display: block; }
.runtime-error-banner small { color: #991b1b; margin-top: 4px; }
.runtime-error-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.runtime-error-actions button {
  border: 0;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}
.runtime-error-actions [data-runtime-refresh] { background: #7f1d1d; color: #fff; }
.runtime-error-actions [data-runtime-hide] { background: #fee2e2; color: #7f1d1d; }
.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 8px;
  border-radius: 999px;
  background: #64748b;
}
.health-dot.ok { background: #16a34a; }
.health-dot.warning { background: #d97706; }
.health-dot.error { background: #dc2626; }
.badge.danger { background: #fee2e2; color: #991b1b; border-color: rgba(220, 38, 38, 0.28); }
.form-status[data-mode="success"] { background: #ecfdf5; color: #065f46; border-color: rgba(5, 150, 105, 0.28); }
.form-status[data-mode="error"] { background: #fef2f2; color: #991b1b; border-color: rgba(220, 38, 38, 0.28); }
.form-status[data-mode="warning"] { background: #fffbeb; color: #92400e; border-color: rgba(217, 119, 6, 0.28); }
@media (max-width: 720px) {
  .runtime-error-banner { flex-direction: column; align-items: stretch; inset-inline: 10px; top: 10px; }
  .runtime-error-actions { justify-content: stretch; }
  .runtime-error-actions button { flex: 1; }
}


/* Step 17 — Client day simulation and final QA pass */
.qa-checklist { margin: 0; padding: 0 22px 0 0; line-height: 2; color: var(--text); }
.qa-checklist li { margin-bottom: 6px; }
.health-dot.error { background: #dc2626; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
.badge.danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.form-status[data-mode="error"] { background: #fff1f2; color: #9f1239; border-color: #fecdd3; }
.form-status[data-mode="success"] { background: #ecfdf5; color: #065f46; border-color: #bbf7d0; }
.form-status[data-mode="warning"] { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.form-status[data-mode="info"] { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }


/* Step 18 — client delivery and data safety */
.data-safety-banner {
  margin: 14px 18px 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(245, 158, 11, .45);
  background: rgba(245, 158, 11, .12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-soft);
}
.data-safety-banner[data-mode="error"] {
  border-color: rgba(239, 68, 68, .45);
  background: rgba(239, 68, 68, .12);
}
.data-safety-banner strong { white-space: nowrap; }
.danger-panel {
  border-color: rgba(239, 68, 68, .26);
  background: linear-gradient(135deg, rgba(239, 68, 68, .08), rgba(255,255,255,.03));
}
.safety-rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.safety-rule {
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--panel-muted);
}
.safety-rule strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-strong);
}
.safety-rule span { color: var(--text-muted); line-height: 1.7; }
.inline-check {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.8;
}
.inline-check input { width: auto; margin-top: 6px; }
.badge.danger {
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}
@media (max-width: 820px) {
  .safety-rules-grid { grid-template-columns: 1fr; }
  .data-safety-banner { flex-direction: column; align-items: stretch; }
}


/* Demo UI polish */
.nav-badge {
  min-width: 48px;
  text-align: center;
  background: rgba(255,255,255,.10);
}
.page-eyebrow { letter-spacing: 0; }
.badge.mvp, .badge.phase { background: #dcfce7; color: #166534; }
.release-candidate-panel {
  border-color: rgba(29, 78, 216, .20);
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(239,246,255,.96));
}
.release-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.release-checklist > div {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 13px;
}
.release-checklist strong {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.release-checklist span { color: var(--text); line-height: 1.65; font-weight: 700; }
@media (max-width: 1180px) {
  :root { --sidebar-width: 270px; }
  .nav-button { grid-template-columns: 30px 1fr auto; padding: 9px 10px; }
  .nav-icon { width: 30px; height: 30px; }
  .nav-label { font-size: 13px; }
}
@media (max-width: 820px) {
  .topbar { height: auto; min-height: var(--topbar-height); padding-top: 10px; padding-bottom: 10px; align-items: flex-start; }
  .topbar-actions { gap: 7px; }
  .status-pill, .action-pill { padding: 7px 9px; font-size: 11px; }
  .page-title { font-size: 24px; }
  .page-description { font-size: 14px; }
  .release-checklist { grid-template-columns: 1fr; }
  .table-wrap { border-radius: 14px; }
  th, td { padding: 10px 11px; }
}
@media (max-width: 540px) {
  .topbar-actions .db-pill, .topbar-actions .user-pill { display: none; }
  .metric-value { font-size: 25px; }
  .panel { padding: 14px; border-radius: 18px; }
  .button { width: 100%; }
  .toolbar .button { width: auto; }
}


/* Step 22 — Final Client Acceptance + Handover Lock */
.release-lock-panel {
  border: 1px solid rgba(13, 148, 136, 0.28);
  box-shadow: 0 18px 45px rgba(13, 148, 136, 0.08);
}
.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-main);
}
.checkbox-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
@media (max-width: 540px) {
  .release-lock-panel .toolbar { align-items: stretch; }
  .release-lock-panel .toolbar .button { width: 100%; }
}


/* Step 23 — Local-first Live Sync + readonly view user */
.inline-check { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.inline-check input { width: auto; }
.readonly-mode form { opacity: .92; }
.readonly-mode button[disabled], .readonly-mode input[disabled], .readonly-mode select[disabled], .readonly-mode textarea[disabled] { cursor: not-allowed; opacity: .62; }
.status-pill[data-sync-mini-status] { border-color: rgba(20, 83, 45, .18); background: rgba(220, 252, 231, .72); color: #14532d; }
[data-sync-form-status][data-mode="success"] { border-color: rgba(21, 128, 61, .25); background: rgba(220, 252, 231, .75); color: #14532d; }
[data-sync-form-status][data-mode="warning"] { border-color: rgba(180, 83, 9, .25); background: rgba(254, 243, 199, .8); color: #92400e; }
[data-sync-form-status][data-mode="info"] { border-color: rgba(37, 99, 235, .2); background: rgba(219, 234, 254, .65); color: #1d4ed8; }

/* step23-local-first-live-sync-foundation */

/* Step 26 — Final Client Acceptance compatibility marker */

/* Step 27 — Final Client Acceptance | step27-sync-debts-cash-digital */

/* Step 52 — Users and permissions management */
.section-mini-title { margin: 10px 0 8px; font-size: 15px; color: var(--primary-strong); }
.permissions-matrix { display: grid; gap: 8px; max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: 18px; padding: 10px; background: var(--panel-soft); }
.permission-row { display: grid; grid-template-columns: minmax(170px, 1fr) repeat(4, minmax(82px, auto)); gap: 10px; align-items: center; padding: 10px; border: 1px solid rgba(219, 227, 239, .95); border-radius: 14px; background: #fff; }
.permission-row-title { display: grid; gap: 3px; }
.permission-row-title strong { font-size: 13px; }
.permission-row-title span { color: var(--muted); font-size: 11px; font-weight: 800; }
.permission-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 900; color: #334155; }
.permission-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
@media (max-width: 900px) {
  .permission-row { grid-template-columns: 1fr 1fr; }
  .permission-row-title { grid-column: 1 / -1; }
}

/* Step 56 — Cloudflare deployment mode clarity */
.deployment-mode-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ffffff, var(--panel-soft));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}
.deployment-mode-card[data-mode="live_sync_ready"] { border-color: rgba(22, 163, 74, 0.34); background: linear-gradient(135deg, #f0fdf4, #ffffff); }
.deployment-mode-card[data-mode="live_sync_blocked"] { border-color: rgba(220, 38, 38, 0.34); background: linear-gradient(135deg, #fef2f2, #ffffff); }
.deployment-mode-card[data-mode="local_only_missing_cloud_settings"],
.deployment-mode-card[data-mode="live_sync_unverified"],
.deployment-mode-card[data-mode="live_sync_partial"] { border-color: rgba(217, 119, 6, 0.34); background: linear-gradient(135deg, #fffbeb, #ffffff); }
@media (max-width: 720px) {
  .deployment-mode-card { flex-direction: column; align-items: stretch; }
}

/* Step 62.3 — readonly invoice details before editing */
.button-row { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.invoice-details-panel { margin-top: 16px; border: 1px solid rgba(37, 99, 235, 0.18); }
.invoice-details-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.invoice-details-grid { margin-top: 12px; }
.invoice-details-notes { display: grid; gap: 6px; margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 14px; background: rgba(248, 250, 252, 0.78); }
.invoice-details-notes strong { color: var(--muted); font-size: 12px; }
.invoice-adjustments-readonly { margin-top: 16px; }
.mini-title { margin: 0 0 10px; font-size: 15px; font-weight: 900; color: var(--text); }

/* Step 62.4 — Sales invoice editing preview UI */
.invoice-edit-preview-panel {
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06), rgba(15, 23, 42, 0.02));
}
.invoice-edit-meta-grid {
  margin-top: 14px;
}
.compact-number-input {
  width: 110px;
  min-width: 90px;
  padding-inline: 8px;
}
.invoice-preview-result {
  margin-top: 16px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 16px;
  padding: 14px;
  background: rgba(59, 130, 246, 0.04);
}

.demo-login-hint{display:grid;gap:6px;margin:12px 0 4px;padding:12px 14px;border:1px solid rgba(15,23,42,.12);border-radius:16px;background:rgba(15,23,42,.05);text-align:center}.demo-login-hint strong{font-weight:900}.demo-login-hint span{font-weight:800;letter-spacing:.2px}


/* Demo presentation polish — responsive public preview */
.demo-login-hint{display:none !important;}
.demo-pill{background:linear-gradient(135deg,#fff7ed,#ecfdf3) !important;border-color:rgba(245,158,11,.34) !important;color:#14532d !important;}
body[data-demo-mode="1"] .data-safety-banner{display:none !important;}
body[data-demo-mode="1"] .nav-badge{display:none;}
body[data-demo-mode="1"] .sidebar-footer{border-top:1px solid rgba(255,255,255,.10);}
body[data-demo-mode="1"] .release-candidate-panel.demo-info-panel{border-color:rgba(22,163,74,.22);background:linear-gradient(135deg,#f0fdf4,#ffffff);}
@media (max-width: 980px){
  .topbar{height:auto;min-height:var(--topbar-height);align-items:flex-start;gap:10px;flex-wrap:wrap;padding:10px 14px;}
  .topbar-title{flex:1 1 220px;min-width:0;}
  .topbar-actions{flex:1 1 100%;justify-content:flex-start;gap:7px;}
  .status-pill,.action-pill{font-size:11px;padding:7px 9px;}
  .content-area{padding:16px;}
  .page-header{display:grid;grid-template-columns:1fr;gap:10px;}
  .card-grid,.card-grid.two,.card-grid.three,.form-grid,.split-layout{grid-template-columns:1fr !important;}
  .product-grid{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media (max-width: 540px){
  .login-screen{padding:14px;align-items:flex-start;}
  .login-card{border-radius:22px;padding:22px 16px;width:100%;margin-top:14px;}
  .login-heading h1{font-size:26px;}
  .login-logo-wrap img{max-width:112px;}
  .topbar-title strong{font-size:16px;}
  .topbar-title span{display:none;}
  .topbar-actions{display:grid;grid-template-columns:1fr;align-items:stretch;}
  .topbar-actions .button,.topbar-actions .status-pill{width:100%;justify-content:center;}
  .content-area{padding:12px;}
  .panel,.metric-card{border-radius:16px;padding:14px;}
  .metric-value{font-size:24px;}
  .product-grid{grid-template-columns:1fr;}
  .button{width:100%;}
  .toolbar .button{width:auto;}
  table{min-width:640px;}
}
