:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --sidebar: #0F172A;
  --sidebar-hover: #1E293B;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --input-border: #CBD5E1;
  --text: #0F172A;
  --muted: #64748B;
  --success: #10B981;
  --success-soft: #ECFDF5;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --danger: #EF4444;
  --danger-soft: #FEF2F2;
  --sidebar-width: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Global Form Elements */
label,
.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea,
.form-input,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background-color: #FFFFFF;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus,
.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group {
  margin-bottom: 1rem;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* App Shell & Sticky Scrollable Sidebar */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background-color: var(--sidebar);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 40;
  transition: margin-left 0.25s ease, transform 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.app-shell.sidebar-collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 1.35rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}

.sidebar-sub {
  font-size: 0.72rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748B;
  padding: 0.85rem 0.75rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #CBD5E1;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background-color: var(--sidebar-hover);
  color: #FFFFFF;
}

.nav-link.active {
  background-color: var(--primary);
  color: #FFFFFF;
}

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

.user-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #FFFFFF;
}

.role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.25);
  color: #93C5FD;
}

.btn-logout {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #CBD5E1;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-logout:hover {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
}

/* Main Content & Top Navbar */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #FFFFFF;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.menu-toggle:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
}

.page-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-content {
  padding: 1.5rem;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* Modern Pill Language Switcher */
.lang-switch {
  display: inline-flex;
  align-items: center;
  background: #F1F5F9;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.kpi-value.success {
  color: var(--success);
}

.kpi-value.warning {
  color: var(--warning);
}

.kpi-value.danger {
  color: var(--danger);
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #F8FAFC;
}

tr:last-child td {
  border-bottom: none;
}

/* Badges, Alerts & Buttons */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}

.badge-success {
  background: var(--success-soft);
  color: #047857;
}

.badge-warning {
  background: var(--warning-soft);
  color: #B45309;
}

.badge-danger {
  background: var(--danger-soft);
  color: #B91C1C;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.alert-success {
  background: var(--success-soft);
  color: #047857;
  border: 1px solid #A7F3D0;
}

.alert-danger {
  background: var(--danger-soft);
  color: #B91C1C;
  border: 1px solid #FECACA;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-sm {
  padding: 0.38rem 0.7rem;
  font-size: 0.78rem;
}

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

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

.btn-outline {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--input-border);
}

.btn-outline:hover {
  background: #F1F5F9;
}

.btn-danger-outline {
  background: #FFFFFF;
  color: var(--danger);
  border: 1px solid #FECACA;
}

.btn-danger-outline:hover {
  background: var(--danger-soft);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* POS Checkout Layout */
.pos-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.pos-products-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  max-height: 68vh;
  overflow-y: auto;
}

.pos-product-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  background: #FFFFFF;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.pos-product-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.pos-prod-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.pos-prod-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.pos-prod-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.pos-prod-price {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--primary);
}

.cart-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: #F8FAFC;
}

.cart-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.cart-item-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.tender-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.pos-summary-box {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}

.pos-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.pos-summary-row:last-child {
  margin-bottom: 0;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
}

/* Modals (Hidden by default, centered overlay when .open) */
.modal,
.modal-backdrop,
[data-modal] {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.open,
.modal-backdrop.open,
[data-modal].open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 430px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 24px 55px rgba(15, 23, 42, 0.25);
}

/* Mobile Drawer & Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 35;
}

@media (max-width: 980px) {

  .two-col,
  .pos-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    margin-left: 0 !important;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }
}

@media print {

  .sidebar,
  .topbar,
  .no-print {
    display: none !important;
  }

  .card {
    box-shadow: none !important;
    border: none !important;
  }
}

/* Interactive Field Help Popovers */
.label-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.375rem;
}

.label-row label,
.label-row .form-label {
  margin-bottom: 0;
}

.field-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.field-tip-btn {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #94A3B8;
  background: transparent;
  color: #64748B;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 5px;
  vertical-align: middle;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.field-tip-btn:hover,
.field-tip-wrap.open .field-tip-btn {
  border-color: #2563EB;
  color: #2563EB;
  background: #EFF6FF;
}

.field-tip-box {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 265px;
  max-width: calc(100vw - 3rem);
  background: #0F172A;
  color: #F8FAFC;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  z-index: 50;
}

.field-tip-wrap.open .field-tip-box {
  display: block;
}

/* Interactive Field Help Popovers */
.label-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.375rem;
}

.label-row label,
.label-row .form-label {
  margin-bottom: 0;
}

.field-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.field-tip-btn {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #94A3B8;
  background: transparent;
  color: #64748B;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 5px;
  vertical-align: middle;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.field-tip-btn:hover,
.field-tip-wrap.open .field-tip-btn {
  border-color: #2563EB;
  color: #2563EB;
  background: #EFF6FF;
}

.field-tip-box {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 265px;
  max-width: calc(100vw - 3rem);
  background: #0F172A;
  color: #F8FAFC;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  z-index: 50;
}

.field-tip-wrap.open .field-tip-box {
  display: block;
}