:root {
  color-scheme: light;
  --primary: #1a56db;
  --primary-soft: #eaf1ff;
  --page-bg: #f6f8fb;
  --surface: #ffffff;
  --text: #171b26;
  --muted: #667085;
  --border: #e2e7ef;
  --danger: #c62828;
  --radius-lg: 20px;
  --radius-md: 15px;
  --touch-target: 48px;
  font-family: "Tajawal", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page-bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
a { color: var(--primary); }

.page-shell {
  width: min(100%, 960px);
  margin-inline: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: var(--primary);
  color: #fff;
  font-size: 25px;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(21px, 5vw, 29px); line-height: 1.3; }
h2 { margin-bottom: 12px; font-size: clamp(22px, 5vw, 30px); line-height: 1.35; }

.status-pill {
  margin-inline-start: auto;
  padding: 6px 10px;
  border: 1px solid #cfdcff;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #1748ae;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.welcome-panel {
  padding: 24px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.welcome-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 15px;
  place-items: center;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 28px;
  font-weight: 900;
}

.lead {
  margin-bottom: 18px;
  color: #454d5b;
  font-size: 16px;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #edf0f5;
}

.progress-track span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.status-note { margin: 9px 0 0; color: var(--muted); font-size: 13px; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.module-item {
  display: flex;
  min-width: 0;
  min-height: 142px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.module-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: #f2f5fa;
  color: var(--primary);
  font-size: 26px;
  font-weight: 800;
}

.module-item strong { font-size: 17px; }
.module-item small { color: var(--muted); font-size: 13px; }

.signature {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 20px;
  padding: 14px 4px 0;
  color: var(--muted);
  font-size: 12px;
}

.signature strong { color: #344054; }

.primary-button {
  display: inline-flex;
  min-height: var(--touch-target);
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.error-panel { margin-top: 22vh; }

@media (min-width: 680px) {
  .page-shell { padding-inline: 24px; padding-top: 28px; }
  .welcome-panel { padding: 30px; }
  .quick-grid { gap: 16px; }
  .module-item { min-height: 160px; padding: 22px; }
}

@media (max-width: 380px) {
  .page-shell { padding-inline: 12px; }
  .status-pill { font-size: 11px; padding-inline: 7px; }
  .quick-grid { gap: 9px; }
  .module-item { min-height: 132px; padding: 13px; }
  .module-item strong { font-size: 15px; }
}


/* Authenticated ERP shell */
.app-frame { min-height: 100vh; min-height: 100dvh; }
.app-main { min-width: 0; }
.app-main.with-sidebar { min-width: 0; }
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
}
.topbar-title { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.topbar-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.topbar-title small { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-actions form { margin: 0; }
.icon-button {
  display: inline-flex;
  flex: 0 0 var(--touch-target);
  width: var(--touch-target);
  height: var(--touch-target);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  color: #283247;
  text-decoration: none;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}
.icon-button:active { background: var(--primary-soft); }
.menu-trigger { border-color: transparent; background: transparent; }
.logout-trigger { color: #7b3333; }
.brand-inline { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; }
.brand-inline strong { font-size: 16px; }

.page-content {
  width: min(100%, 1180px);
  min-width: 0;
  margin-inline: auto;
  padding: 18px 14px 28px;
}
.page-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-heading-row h1 { font-size: clamp(23px, 5vw, 30px); }
.heading-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.content-card {
  min-width: 0;
  margin-bottom: 14px;
  padding: 18px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.section-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 13px; }
.section-title h2 { margin: 0; font-size: 19px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.section-title-spaced { margin-top: 23px; }

.dashboard-welcome { display: flex; align-items: center; justify-content: space-between; gap: 14px; overflow: hidden; }
.dashboard-welcome-copy { min-width: 0; }
.dashboard-welcome h2 { margin: 0 0 8px; font-size: clamp(21px, 5vw, 28px); }
.dashboard-welcome p:last-child { margin: 0; color: #596273; }
.dashboard-emblem {
  display: grid;
  flex: 0 0 66px;
  width: 66px;
  height: 66px;
  place-items: center;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 35px;
}
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.module-card {
  display: flex;
  min-width: 0;
  min-height: 150px;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 15px 13px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: #fff;
}
.module-card-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: #f0f4fa;
  color: var(--primary);
  font-size: 25px;
}
.module-card strong { font-size: 16px; line-height: 1.35; }
.module-card small { color: var(--muted); font-size: 12px; }
.module-status { margin-top: auto; color: #53627a; font-size: 11px; }

.sidebar {
  position: fixed;
  z-index: 45;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  width: 264px;
  flex-direction: column;
  border-left: 1px solid #dfe5ee;
  background: #fff;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 16px 13px; border-bottom: 1px solid var(--border); }
.sidebar-brand img { flex: 0 0 42px; border-radius: 12px; }
.sidebar-brand-copy { display: flex; min-width: 0; flex-direction: column; }
.sidebar-brand-copy strong { font-size: 14px; line-height: 1.45; }
.sidebar-brand-copy span { color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.sidebar-close { display: none; margin-inline-start: auto; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 13px; border-bottom: 1px solid var(--border); }
.avatar-mark, .account-avatar {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #cbd9f7;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 20px;
  font-weight: 900;
}
.sidebar-user-copy { display: flex; min-width: 0; flex-direction: column; }
.sidebar-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.sidebar-user-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.tree-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 9px 14px; }
.tree-section { margin-bottom: 8px; border: 1px solid #e3e8f0; border-radius: 13px; overflow: hidden; background: #fff; }
.tree-section.is-open { border-color: #bfd0f6; }
.tree-heading {
  display: flex;
  width: 100%;
  min-height: 49px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  background: #f8faff;
  color: #253047;
  text-align: right;
  cursor: pointer;
}
.tree-section.is-open .tree-heading { background: #edf3ff; color: #1748ae; }
.nav-symbol { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; border-radius: 8px; background: #fff; border: 1px solid #e2e8f0; font-size: 17px; }
.tree-heading-title { flex: 1; font-size: 14px; font-weight: 800; }
.tree-chevron { display: inline-block; font-size: 24px; line-height: 1; transition: transform .16s ease; }
.tree-section.is-open .tree-chevron { transform: rotate(-90deg); }
.tree-children { padding: 6px; border-top: 1px solid #e4e9f1; background: #f9fbff; }
.tree-children[hidden] { display: none; }
.tree-link { display: flex; min-height: 42px; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; color: #414b5d; text-decoration: none; font-size: 13px; }
.tree-link:hover { background: #f0f4fb; }
.tree-link.is-active { border-inline-start: 3px solid var(--primary); background: #e8efff; color: #1748ae; font-weight: 800; }
.child-symbol { display: inline-grid; flex: 0 0 22px; width: 22px; height: 22px; place-items: center; color: #69768c; font-size: 16px; }
.pending-link { color: #798395; cursor: default; }
.pending-link small { margin-inline-start: auto; font-size: 10px; }
.sidebar-footer { display: flex; flex-direction: column; gap: 3px; padding: 13px 13px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); color: #526078; font-size: 11px; }
.sidebar-footer small { color: #788396; font-size: 10px; }
.drawer-backdrop { display: none; }

.bottom-nav { display: none; }

.auth-wrap { width: min(100%, 470px); margin: 10px auto 22px; }
.auth-card { padding: 24px 19px; border: 1px solid var(--border); border-radius: 22px; background: #fff; }
.auth-brand { margin-bottom: 20px; text-align: center; }
.auth-brand img { display: block; margin: 0 auto 12px; border-radius: 17px; }
.auth-brand .welcome-icon { margin: 0 auto 12px; }
.auth-brand h1 { margin-bottom: 8px; font-size: 26px; }
.auth-brand p:last-child { margin: 0; color: var(--muted); }
.form-stack { display: flex; flex-direction: column; gap: 15px; }
.form-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.field-label { color: #273246; font-size: 14px; font-weight: 800; }
.form-control {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #d7deea;
  border-radius: 13px;
  outline: none;
  background: #fff;
  color: #151b27;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: #8a94a4; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.field-error { color: var(--danger); font-size: 12px; font-weight: 700; }
.check-row { display: flex; min-height: 44px; align-items: center; gap: 9px; color: #4e596b; font-size: 14px; }
.check-row input { width: 19px; height: 19px; accent-color: var(--primary); }
.primary-button { cursor: pointer; }
.button-wide { width: 100%; min-height: 51px; }
.primary-button:disabled { cursor: wait; opacity: .75; }
.primary-button.is-loading::before { width: 15px; height: 15px; margin-inline-end: 9px; border: 2px solid currentColor; border-left-color: transparent; border-radius: 50%; content: ""; animation: button-spin .7s linear infinite; }
@keyframes button-spin { to { transform: rotate(360deg); } }
.text-link { display: inline-flex; min-height: 44px; align-items: center; font-weight: 800; text-decoration: none; }
.recovery-link { justify-content: center; width: 100%; margin-top: 9px; }
.auth-signature { margin: 14px 0; color: var(--muted); text-align: center; font-size: 12px; }
.inline-note { margin: 17px 0 8px; padding: 12px; border: 1px solid #dfe7f5; border-radius: 12px; background: #f7f9fd; color: #526078; font-size: 13px; }
.account-summary { display: flex; align-items: flex-start; gap: 13px; }
.account-avatar { flex-basis: 54px; width: 54px; height: 54px; font-size: 25px; }
.account-summary-text { min-width: 0; }
.account-summary h2 { margin: 0 0 4px; font-size: 20px; overflow-wrap: anywhere; }
.account-summary p { margin: 0 0 9px; color: var(--muted); }
.role-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { padding: 4px 9px; border: 1px solid #dce5f7; border-radius: 999px; background: #f5f8ff; color: #2c4f94; font-size: 11px; font-weight: 700; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 12px; }
.flash-message { padding: 12px 13px; border: 1px solid var(--border); border-radius: 12px; background: #fff; font-size: 14px; }
.flash-success { border-color: #b7e2c8; background: #f1fbf4; color: #155b31; }
.flash-error { border-color: #f0c0c0; background: #fff5f5; color: #8e1c1c; }
.flash-info { border-color: #c9d9fa; background: #f2f6ff; color: #214b9b; }
.flash-warning { border-color: #ecd8a4; background: #fffaf0; color: #7c5200; }
.signed-note { display: flex; flex-direction: column; gap: 4px; color: #657084; font-size: 12px; }
.signed-note strong { color: #344054; }

@media (min-width: 901px) {
  .app-main.with-sidebar { margin-right: 264px; }
  .app-topbar { padding-inline: 24px; }
  .menu-trigger { display: none; }
  .page-content { padding: 24px; }
  .bottom-nav { display: none !important; }
  .sidebar-close { display: none; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(105%); transition: transform .2s ease; box-shadow: -10px 0 35px rgba(16,24,40,.12); }
  body.drawer-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 40; display: none; width: 100%; height: 100%; border: 0; background: rgba(18,27,45,.42); }
  body.drawer-open .drawer-backdrop { display: block; }
  body.drawer-open { overflow: hidden; }
  .app-main.with-sidebar { margin-right: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    min-height: calc(64px + env(safe-area-inset-bottom));
    align-items: stretch;
    justify-content: space-around;
    padding: 5px 8px max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #727e91;
    text-decoration: none;
    cursor: pointer;
  }
  .bottom-nav span { font-size: 22px; line-height: 1.15; }
  .bottom-nav small { font-size: 11px; font-weight: 700; }
  .bottom-nav .is-active { background: var(--primary-soft); color: var(--primary); }
}

@media (max-width: 380px) {
  .app-topbar { padding-inline: 10px; }
  .page-content { padding-inline: 10px; }
  .content-card { padding: 15px 13px; }
  .auth-card { padding: 21px 15px; }
  .module-grid { gap: 8px; }
  .module-card { padding: 12px 10px; }
  .module-card strong { font-size: 15px; }
  .dashboard-emblem { flex-basis: 50px; width: 50px; height: 50px; }
}


/* Dashboard refresh — phase 01: reference-aligned, mobile-first cards and SVG icons */
.dashboard-heading { align-items: center; }
.dashboard-heading h1 { font-size: clamp(23px, 5.5vw, 29px); }
.dashboard-date { display: inline-flex; flex: 0 0 auto; min-width: 52px; min-height: 44px; align-items: center; justify-content: center; padding: 6px 9px; border: 1px solid var(--border); border-radius: 13px; background: #fff; color: #354158; font-size: 12px; font-weight: 800; }
.dashboard-intro { display: flex; align-items: center; gap: 13px; padding: 15px; }
.dashboard-intro-icon { display: grid; flex: 0 0 54px; width: 54px; height: 54px; place-items: center; border: 1px solid #dce6fb; border-radius: 16px; background: #f1f5ff; color: var(--primary); }
.ui-icon { display: block; flex: 0 0 auto; }
.dashboard-intro-copy { min-width: 0; }
.dashboard-intro-copy strong { display: block; margin-bottom: 3px; font-size: 17px; }
.dashboard-intro-copy p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.quick-actions-card { padding: 16px 14px; }
.quick-actions-card .section-title { margin-bottom: 12px; }
.quick-action-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 7px; border: 1px solid #f0f2f6; border-radius: 20px; background: #fff; }
.quick-action { display: flex; min-width: 0; min-height: 48px; align-items: center; justify-content: center; gap: 5px; padding: 7px 6px; border: 1px solid var(--border); border-radius: 15px; background: #fbfcfe; color: #252d3b; font-size: 13px; font-weight: 800; text-align: center; text-decoration: none; box-shadow: 0 2px 4px rgba(20, 32, 52, .035); }
.quick-action:active { background: var(--primary-soft); }
.quick-action-plus { display: grid; flex: 0 0 19px; width: 19px; height: 19px; place-items: center; color: var(--primary); }
.dashboard-modules-section { margin-top: 19px; }
.dashboard-module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dashboard-module { display: flex; position: relative; min-width: 0; min-height: 150px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 10px; border: 1px solid var(--border); border-radius: 19px; background: #f8faff; color: var(--text); text-align: center; text-decoration: none; }
.dashboard-module.module-ready { background: #fff; }
.dashboard-module.module-ready:active { border-color: #b9cdf8; background: #f9fbff; }
.dashboard-module-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: #fff; color: #172033; }
.dashboard-module strong { font-size: 16px; line-height: 1.4; }
.dashboard-module small { color: #596579; font-size: 12px; line-height: 1.45; }
.dashboard-module.module-pending { color: #252d3b; }
.dashboard-module.module-pending .dashboard-module-icon { background: #f0f4fb; color: #26344c; }
.module-stage-label { margin-top: 1px; padding: 2px 8px; border: 1px solid #e0e6ef; border-radius: 7px; background: #fff; color: #737e8f; font-size: 10px; line-height: 1.5; }
.dashboard-signature { display: flex; flex-direction: column; gap: 3px; padding: 13px 15px; color: var(--muted); font-size: 12px; }
.dashboard-signature strong { color: #344054; font-size: 13px; }

@media (max-width: 380px) {
  .quick-actions-card { padding-inline: 10px; }
  .quick-action-list { gap: 6px; padding: 5px; }
  .quick-action { gap: 3px; padding-inline: 4px; font-size: 12px; }
  .dashboard-module-grid { gap: 8px; }
  .dashboard-module { min-height: 142px; padding: 12px 7px; }
  .dashboard-module strong { font-size: 14px; }
  .dashboard-module small { font-size: 11px; }
}


/* Shared mobile-first catalogue and dialog components */
.search-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.search-box { display: flex; flex: 1; min-width: 0; min-height: 49px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #dbe2ed; border-radius: 14px; background: #fff; color: #69768a; }
.search-box > span { font-size: 22px; line-height: 1; }
.search-box input { width: 100%; min-width: 0; min-height: 45px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.search-box input:focus { box-shadow: none; }
.secondary-button, .quiet-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 6px; padding: 9px 13px; border: 1px solid #d9e0ea; border-radius: 12px; background: #fff; color: #344054; font-size: 13px; font-weight: 800; line-height: 1.4; text-decoration: none; cursor: pointer; }
.secondary-button:active, .quiet-button:active { background: var(--primary-soft); }
.quiet-button { color: #9b3030; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.filter-chip { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; padding: 6px 12px; border: 1px solid #dfe5ee; border-radius: 11px; background: #fff; color: #4b5565; font-size: 13px; font-weight: 700; text-decoration: none; }
.filter-chip.is-selected { border-color: #c5d5fb; background: var(--primary-soft); color: #1748ae; }
.entity-list { display: grid; gap: 11px; }
.entity-card { min-width: 0; padding: 15px; border: 1px solid var(--border); border-radius: 17px; background: #fff; }
.entity-card[hidden], [data-searchable-card][hidden] { display: none !important; }
.entity-top { display: flex; min-width: 0; align-items: center; gap: 10px; }
.entity-avatar { display: grid; flex: 0 0 47px; width: 47px; height: 47px; place-items: center; border: 1px solid #dbe5f9; border-radius: 14px; background: #f1f5ff; color: var(--primary); font-size: 24px; }
.entity-main { flex: 1; min-width: 0; }
.entity-main h2 { overflow-wrap: anywhere; margin: 0 0 3px; font-size: 17px; line-height: 1.4; }
.entity-main p { overflow-wrap: anywhere; margin: 0; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; flex: 0 0 auto; align-items: center; padding: 4px 8px; border: 1px solid #e0e5ed; border-radius: 8px; background: #fff; color: #667085; font-size: 11px; font-weight: 800; }
.status-primary { border-color: #c8d8fc; background: #eef3ff; color: #1748ae; }
.status-muted { background: #f4f5f7; color: #697386; }
.price-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 13px; }
.price-summary-grid > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 9px 8px; border: 1px solid #edf0f5; border-radius: 11px; background: #fafbfe; }
.price-summary-grid small { color: #667085; font-size: 11px; line-height: 1.35; }
.price-summary-grid strong { overflow-wrap: anywhere; color: #1e293b; font-size: 14px; line-height: 1.4; }
.price-summary-grid strong small { display: inline; font-size: 10px; }
.entity-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #eef1f5; }
.entity-actions form { margin: 0; }
.empty-state { padding: 30px 16px; border: 1px dashed #d7deea; border-radius: 17px; background: rgba(255,255,255,.72); text-align: center; }
.empty-state h2 { margin: 7px 0; font-size: 18px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-symbol { color: #8290a5; font-size: 30px; }
.form-dialog { width: min(94vw, 560px); max-width: 560px; max-height: min(88dvh, 900px); overflow: auto; padding: 0; border: 1px solid #dfe5ee; border-radius: 21px; background: #fff; color: var(--text); box-shadow: 0 22px 70px rgba(20,32,52,.2); }
.form-dialog::backdrop { background: rgba(19,29,46,.48); backdrop-filter: blur(2px); }
.dialog-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px 13px; border-bottom: 1px solid #e9edf3; background: rgba(255,255,255,.97); }
.dialog-header .eyebrow { margin-bottom: 3px; }
.dialog-header h2 { margin: 0; font-size: 21px; }
.dialog-close { display: inline-flex; flex: 0 0 42px; width: 42px; height: 42px; align-items: center; justify-content: center; border: 1px solid #e0e6ef; border-radius: 13px; background: #fff; color: #555f70; font-size: 27px; text-decoration: none; cursor: pointer; }
.form-dialog > .form-stack, .form-dialog > form { padding: 17px 18px 19px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-label { color: #273246; font-size: 14px; font-weight: 800; }
.form-control { display: block; width: 100%; min-width: 0; min-height: 49px; padding: 10px 12px; border: 1px solid #d7deea; border-radius: 12px; outline: none; background: #fff; color: #151b27; font-size: 16px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
textarea.form-control { min-height: 84px; resize: vertical; }
.field-error { color: var(--danger); font-size: 12px; font-weight: 700; }
.check-row { display: flex; min-height: 44px; align-items: center; gap: 9px; color: #4e596b; font-size: 14px; }
.check-row input { width: 19px; height: 19px; accent-color: var(--primary); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.dialog-actions .button-wide { flex: 1 1 180px; }
.amount-words { display: block; min-height: 1px; color: #c62828; font-size: 12px; font-weight: 900; line-height: 1.5; overflow-wrap: anywhere; }
.amount-words[hidden] { display: none; }
.party-balance { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 10px 12px; border: 1px solid #e7ebf2; border-radius: 12px; background: #fafbfe; }
.party-balance small { color: var(--muted); font-size: 12px; }
.party-balance strong { font-size: 16px; }
.balance-debit { color: #ba2f36; }
.balance-credit { color: #16804a; }
.party-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.party-price-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.party-price-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border: 1px solid #e4e9f1; border-radius: 9px; background: #f9fbfe; color: #536075; font-size: 11px; }
.party-price-chip strong { color: #253047; font-size: 12px; }
.party-price-editor { display: grid; grid-template-columns: minmax(0,1fr) minmax(118px, .85fr); align-items: center; gap: 6px 12px; padding: 11px 0; border-bottom: 1px solid #edf0f5; }
.party-price-editor:last-child { border-bottom: 0; }
.party-price-info { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.party-price-info strong { font-size: 14px; }
.party-price-info small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.party-price-input { min-width: 0; }
.party-price-input .form-control { min-height: 43px; padding: 8px 9px; font-size: 15px; }
.party-price-input .amount-words { font-size: 10px; }
.party-price-status { grid-column: 1 / -1; color: #667085; font-size: 11px; }
.smart-select { position: relative; min-width: 0; }
.smart-select-native { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden !important; }
.smart-select-trigger { display: flex; width: 100%; min-height: 49px; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid #d7deea; border-radius: 12px; background: #fff; color: #222b3b; text-align: right; font-size: 15px; cursor: pointer; }
.smart-select-trigger::after { content: "⌄"; color: #64748b; font-size: 20px; }
.smart-select.is-open .smart-select-trigger { border-color: var(--primary); }
.smart-select-menu { position: absolute; z-index: 65; top: calc(100% + 4px); right: 0; width: 100%; max-height: 270px; overflow: hidden; border: 1px solid #d7deea; border-radius: 13px; background: #fff; color: #111827; box-shadow: 0 10px 28px rgba(18,32,58,.15); }
.smart-select-menu[hidden] { display: none; }
.smart-select-search { display: block; width: calc(100% - 16px); min-height: 42px; margin: 8px; padding: 7px 10px; border: 1px solid #dde3ed; border-radius: 9px; outline: 0; background: #fff; color: #111827; font-size: 14px; }
.smart-select-options { max-height: 210px; overflow-y: auto; padding: 0 7px 7px; }
.smart-select-option { display: block; width: 100%; min-height: 42px; padding: 9px 10px; border: 0; border-radius: 8px; background: #fff; color: #111827; text-align: right; font-size: 14px; cursor: pointer; }
.smart-select-option:hover, .smart-select-option.is-selected { background: #edf3ff; color: #1748ae; }
.smart-select-option[hidden] { display: none; }

@media (max-width: 480px) {
  .search-toolbar { align-items: stretch; flex-wrap: wrap; }
  .search-toolbar .search-box { flex-basis: 100%; }
  .search-toolbar > .secondary-button { flex: 1; }
  .entity-card { padding: 13px; }
  .price-summary-grid { gap: 5px; }
  .price-summary-grid > div { padding: 7px 6px; }
  .price-summary-grid small { font-size: 10px; }
  .price-summary-grid strong { font-size: 12px; }
  .form-row { grid-template-columns: minmax(0,1fr); }
  .form-dialog > .form-stack, .form-dialog > form { padding: 14px 13px 16px; }
  .party-price-editor { grid-template-columns: minmax(0,1fr) minmax(100px,.8fr); gap: 6px 8px; }
  .party-price-info strong { font-size: 13px; }
  .party-price-info small { font-size: 10px; }
}


/* Distribution and reporting views */
.heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.distribution-context { display: flex; align-items: center; gap: 12px; padding: 14px 15px; }
.context-icon { display: grid; flex: 0 0 46px; width: 46px; height: 46px; place-items: center; border: 1px solid #dce6fb; border-radius: 14px; background: #f1f5ff; color: var(--primary); font-size: 20px; font-weight: 900; }
.distribution-context strong { display: block; font-size: 16px; }
.distribution-context p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.distribution-form { width: min(100%, 680px); margin-inline: auto; }
.issue-form-card, .payment-form-card { padding: 18px 16px; }
.issue-total-field { background: #f7f9fc; font-weight: 800; }
.latest-issue-note { min-height: 17px; color: #c62828; font-size: 12px; font-weight: 900; }
.subtle-hint { color: #6d7788; font-size: 12px; }
.party-summary-panel { margin: 5px 0 3px; padding: 13px; border: 1px solid #dfe7f5; border-radius: 14px; background: #f8faff; }
.party-summary-panel[hidden] { display: none; }
.party-summary-title { margin-bottom: 9px; color: #293953; font-size: 14px; font-weight: 900; }
.summary-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #e9eef7; }
.summary-line:last-child { border-bottom: 0; }
.summary-line > span { color: #5f6c80; font-size: 12px; }
.summary-line > strong { color: #1f2937; font-size: 14px; text-align: left; }
.summary-line-total { margin-top: 3px; padding-top: 11px; border-top: 1px solid #d9e2f3; }
.summary-line-total strong { color: #1648a6; font-size: 16px; }
.summary-red { color: #c62828 !important; }
.summary-green { color: #167847 !important; }
.summary-note { display: block; margin-top: 9px; color: #7b8494; font-size: 11px; line-height: 1.5; }
.receipt-dialog { width: min(92vw, 430px); }
.receipt-content { padding: 17px; }
.receipt-brand { margin-bottom: 4px; color: #1d3769; font-size: 18px; font-weight: 900; text-align: center; }
.receipt-number { margin-bottom: 14px; color: #738096; font-size: 11px; text-align: center; }
.receipt-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #e1e6ee; }
.receipt-line span { color: #697589; font-size: 12px; }
.receipt-line strong { color: #263246; font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.receipt-total { margin-top: 5px; padding: 12px 10px; border: 1px solid #d9e4fb; border-radius: 11px; background: #f2f6ff; }
.receipt-total strong { color: #1748ae; font-size: 17px; }
.receipt-statement { margin: 12px 0; padding: 9px; border-radius: 9px; background: #f8f9fc; color: #586377; white-space: pre-wrap; font-size: 12px; }
.receipt-signature { margin: 14px 0 3px; color: #8992a0; font-size: 10px; text-align: center; }
.report-filter-form { display: flex; flex-direction: column; gap: 13px; }
.report-totals-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.report-totals-grid > div { display: flex; min-width: 0; flex-direction: column; gap: 4px; padding: 10px 9px; border: 1px solid #e8edf4; border-radius: 11px; background: #fafbfe; }
.report-totals-grid small { color: #68758a; font-size: 11px; }
.report-totals-grid strong { color: #253047; font-size: 14px; overflow-wrap: anywhere; }
.report-totals-grid.compact { margin: 12px 0; gap: 6px; }
.report-totals-grid.compact > div { padding: 8px 7px; }
.report-totals-grid.compact small { font-size: 10px; }
.report-totals-grid.compact strong { font-size: 12px; }
.statement-summary { display: flex; flex-direction: column; gap: 0; }
.statement-extra { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 10px; color: #5f6c80; font-size: 12px; }
@media (max-width: 480px) {
  .heading-actions { margin-top: 10px; }
  .report-totals-grid { gap: 5px; }
  .report-totals-grid > div { padding: 8px 6px; }
  .report-totals-grid strong { font-size: 12px; }
  .summary-line > span { font-size: 11px; }
}
@media print {
  .app-topbar, .sidebar, .bottom-nav, .heading-actions, .report-filter-form, .distribution-form, .dialog-actions, .secondary-button, .primary-button { display: none !important; }
  .app-main.with-sidebar { margin: 0 !important; }
  .page-content { width: 100%; padding: 0 !important; }
  .content-card, .entity-card { break-inside: avoid; box-shadow: none; }
}


/* Inventory and production mobile views */
.status-warning { border-color: #eed8a0; background: #fff8e8; color: #875a07; }
.stock-overview { padding: 15px; }
.stock-balance-panel { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 13px; padding: 11px 12px; border: 1px solid #e8edf4; border-radius: 12px; background: #fafbfe; }
.stock-balance-panel small { color: #68758a; font-size: 12px; }
.stock-balance-panel > strong { color: #253047; font-size: 19px; font-weight: 900; }
.stock-balance-panel > strong small { display: inline; font-size: 11px; }
.stock-value { color: #1748ae !important; }
.entity-extra-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0 0; color: #748094; font-size: 12px; }
.entity-extra-line strong { color: #344054; font-size: 13px; }
.production-period-banner { display: flex; align-items: center; gap: 12px; padding: 14px; }
.production-period-mark { display: grid; flex: 0 0 48px; width: 48px; height: 48px; place-items: center; border: 1px solid #dce6fb; border-radius: 15px; background: #f1f5ff; color: var(--primary); font-size: 26px; }
.production-period-copy { min-width: 0; }
.production-period-copy > strong { display: block; margin-bottom: 4px; font-size: 15px; }
.production-period-copy p { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; color: #667085; font-size: 12px; }
.production-summary { padding: 15px; }
.js-flour-fields[hidden] { display: none !important; }
.stock-current-card { display: flex; flex-direction: column; gap: 6px; padding: 19px; }
.stock-current-card small { color: #68758a; font-size: 13px; }
.stock-current-card strong { color: #1748ae; font-size: 25px; }
@media (max-width: 480px) {
  .stock-balance-panel > strong { font-size: 16px; }
  .production-period-banner { align-items: flex-start; }
}


/* Employee and role permission administration */
.role-check-list, .role-selector-list, .permission-grid { display: grid; gap: 8px; }
.role-check-item, .permission-check-item {
  display: flex; min-width: 0; align-items: flex-start; gap: 10px; padding: 11px;
  border: 1px solid #e4e9f1; border-radius: 12px; background: #fff;
}
.role-check-item input, .permission-check-item input { flex: 0 0 19px; width: 19px; height: 19px; margin-top: 3px; accent-color: var(--primary); }
.role-check-item > span, .permission-check-item > span { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.role-check-item strong, .permission-check-item strong { color: #273246; font-size: 14px; }
.role-check-item small, .permission-check-item small { color: #667085; font-size: 12px; line-height: 1.45; }
.permission-check-item code { align-self: flex-start; color: #627089; font-size: 10px; overflow-wrap: anywhere; }
.role-selector { display: flex; min-width: 0; flex-direction: column; gap: 3px; padding: 12px; border: 1px solid #e0e6ef; border-radius: 12px; background: #fff; color: var(--text); text-decoration: none; }
.role-selector strong { font-size: 14px; }
.role-selector small { color: var(--muted); font-size: 12px; }
.role-selector.is-selected { border-color: #b9cdf8; background: var(--primary-soft); color: #1748ae; }
.role-selector.is-selected small { color: #3b568c; }
.permission-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 480px) {
  .permission-grid { grid-template-columns: minmax(0,1fr); }
  .role-check-item, .permission-check-item { padding: 10px; }
}


/* Period closing workflow */
.closing-form { display: flex; flex-direction: column; gap: 14px; }
.closing-product-list { display: grid; gap: 10px; }
.closing-product-card { min-width: 0; padding: 13px; border: 1px solid #e2e8f0; border-radius: 14px; background: #fbfcff; }
.closing-product-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.closing-product-heading strong { font-size: 15px; }
.closing-product-heading span { padding: 3px 8px; border: 1px solid #e0e7f2; border-radius: 7px; background: #fff; color: #667085; font-size: 11px; }
.closing-calc-result { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding: 13px; border: 1px solid #dce6fa; border-radius: 14px; background: #f6f9ff; }
.closing-calc-result > div { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.closing-calc-result small { color: #67758b; font-size: 11px; line-height: 1.4; }
.closing-calc-result strong { color: #24334e; font-size: 14px; overflow-wrap: anywhere; }
.closing-calc-result p { grid-column: 1 / -1; margin: 3px 0 0; color: #68758a; font-size: 11px; line-height: 1.5; }
@media (max-width: 480px) {
  .closing-calc-result { gap: 5px; padding: 10px; }
  .closing-calc-result > div { gap: 5px; }
  .closing-calc-result strong { font-size: 12px; }
}
