:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #b45309;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f8fafc, #e5e7eb);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: white;
  border-radius: 28px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.container {
  max-width: 1450px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  background: var(--card);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}

.header h1 {
  margin: 4px 0 8px;
  font-size: 28px;
}

.header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.badge {
  background: var(--primary);
  color: white;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.user-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.user-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  padding: 7px 12px;
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  background: var(--card);
  border-radius: 22px;
  padding: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: sticky;
  top: 8px;
  z-index: 10;
}

.tab-btn {
  border: 0;
  background: #f8fafc;
  color: #334155;
  padding: 12px 10px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s;
  font-size: 14px;
}

.tab-btn:hover {
  background: #e5e7eb;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.layout {
  display: grid;
  grid-template-columns: 410px 1fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 19px;
}

.summary .label {
  color: var(--muted);
  font-size: 14px;
}

.summary .value {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 800;
}

.summary .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.danger { color: var(--danger); }
.success { color: var(--success); }
.warning { color: var(--warning); }

label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: #374151;
  font-weight: 600;
}

label span {
  display: block;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: white;
  padding: 11px 12px;
  border-radius: 14px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

input:focus, select:focus, textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 800;
  font-family: inherit;
  font-size: 14px;
  transition: 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: #374151;
}

.btn-light {
  background: #f3f4f6;
  color: #111827;
}

.btn-light:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.btn-danger:hover {
  background: #fecaca;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

.toolbar input, .toolbar select {
  max-width: 260px;
}

.message {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fffbeb;
  color: #92400e;
  display: none;
  line-height: 1.6;
}

.message.show {
  display: block;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: white;
  font-size: 14px;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
}

tr:hover td {
  background: #f9fafb;
}

.status {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 800;
}

.bar-row {
  margin-bottom: 14px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  color: #374151;
  font-size: 14px;
  margin-bottom: 6px;
  gap: 12px;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: #111827;
  border-radius: 999px;
  width: 0%;
}

.info-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  padding: 12px;
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.8;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: #fafafa;
}

@media print {
  body {
    background: white;
  }
  .tabs, .form-card, .toolbar, .header .badge, .no-print {
    display: none !important;
  }
  .container {
    padding: 0;
    max-width: none;
  }
  .card, .header {
    box-shadow: none;
    border: 1px solid #ddd;
  }
  .section {
    display: none !important;
  }
  .section.active {
    display: block !important;
  }
}

@media (max-width: 1100px) {
  .tabs {
    grid-template-columns: repeat(3, 1fr);
  }
  .layout, .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .container {
    padding: 10px;
  }
  .header {
    flex-direction: column;
  }
  .tabs {
    grid-template-columns: repeat(2, 1fr);
    position: static;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .toolbar input, .toolbar select {
    max-width: none;
  }
}


/* SADEN enhancements v2 */
body {
  background: linear-gradient(180deg, #eef2f7 0%, #e9edf3 100%);
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url('./saden-logo.png') center center / 430px no-repeat;
  opacity: 0.025;
  pointer-events: none;
  z-index: 0;
}
.container, .login-screen { position: relative; z-index: 1; }
.login-logo { width: 115px; display: block; margin: 0 auto 14px; }
.brand-block { display: flex; align-items: flex-start; gap: 16px; }
.header-logo { width: 92px; height: auto; display: block; }
.card, .header, .tabs, .login-card { background: rgba(255,255,255,0.92); backdrop-filter: blur(6px); }
.row-actions { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.btn-sm { padding: 7px 9px; font-size: 12px; width: auto !important; }
.file-link { display:inline-block; padding:6px 9px; border-radius:10px; background:#eef2ff; color:#1e3a8a; font-weight:800; text-decoration:none; margin:2px; }
.permissions-box { background:#f8fafc; border:1px solid #e2e8f0; border-radius:16px; padding:12px; margin-bottom:12px; }
.permissions-box label { margin:7px 0; display:flex; gap:8px; align-items:center; font-size:13px; }
.permissions-box input { width:auto; margin:0; }
.report-toolbar input, .report-toolbar select { max-width:210px; }
.summary.mini { padding:14px; }
.summary.mini .value { font-size:21px; }
.print-letterhead, .print-footer, .print-report-title { display:none; }
.po-result h3, .po-result h4 { margin: 16px 0 10px; }
@page { size: A4 landscape; margin: 9mm; }
@media print {
  body::before { display:none !important; }
  .print-letterhead { display:grid; grid-template-columns:1fr 90px 1fr; align-items:center; gap:10px; border-bottom:2px solid var(--danger); padding-bottom:7px; margin-bottom:8px; }
  .print-letterhead img { width:78px; display:block; margin:auto; }
  .print-letterhead .en { direction:ltr; text-align:left; }
  .print-letterhead .ar { text-align:right; }
  .print-letterhead h2 { margin:0; font-size:20px; }
  .print-letterhead p { margin:3px 0 0; font-size:12px; color:#333; }
  .print-report-title { display:block; text-align:center; font-size:15px; font-weight:900; border:1px solid var(--border); border-radius:10px; padding:8px; margin:8px 0 10px; }
  .print-footer { display:flex; justify-content:space-between; border-top:2px solid var(--danger); margin-top:10px; padding-top:5px; font-size:9px; }
  .report-print-area .toolbar { display:none !important; }
  .report-summary-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 6px !important; }
  .report-summary-grid .card { padding:8px !important; min-height:60px; }
  th, td { white-space: normal !important; font-size: 9px; padding: 5px; }
  table { min-width: 0; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  .file-link, .btn { display:none !important; }
}


.notification-tab {
  position: relative;
}

.notification-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  margin-inline-start: 6px;
}

.notification-row-unread td {
  background: #fff7ed;
  font-weight: 700;
}

.notification-title {
  font-weight: 800;
  color: #111827;
}

.notification-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.btn-sm {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}


.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  margin-top: -6px;
  margin-bottom: 6px;
}

select[multiple] {
  min-height: 120px;
  padding: 8px;
}

select[multiple] option {
  padding: 7px;
  border-radius: 8px;
}

.department-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 9px;
  margin: 2px;
  font-size: 12px;
  font-weight: 700;
}


/* V10 print cleanup: print reports only with SADEN letterhead */
@media print {
  .header,
  .tabs,
  .user-strip,
  #message,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff !important;
  }

  .container {
    max-width: none !important;
    padding: 0 !important;
  }

  .section {
    display: none !important;
  }

  #reports.section.active {
    display: block !important;
  }

  #reports .card.report-print-area {
    box-shadow: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  #reports .card:not(.summary) {
    box-shadow: none !important;
  }
}


/* V11 - Better table layout without forced horizontal scrolling */
.table-wrap {
  overflow-x: visible !important;
  overflow-y: visible !important;
}

table {
  min-width: 0 !important;
  width: 100% !important;
  table-layout: fixed !important;
}

th, td {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.7;
}

td .row-actions {
  justify-content: flex-start;
}

.card {
  overflow: visible !important;
}

/* Make dense tables easier to read */
#clientsTable table,
#projectsTable table,
#workTable table,
#invoicesTable table,
#paymentsTable table,
#debtsTable table,
#advancedReportOutput table,
#notificationsTable table {
  font-size: 13px;
}

#clientsTable th,
#clientsTable td,
#projectsTable th,
#projectsTable td,
#workTable th,
#workTable td,
#invoicesTable th,
#invoicesTable td,
#paymentsTable th,
#paymentsTable td,
#debtsTable th,
#debtsTable td,
#advancedReportOutput th,
#advancedReportOutput td,
#notificationsTable th,
#notificationsTable td {
  padding: 9px 8px;
}

/* Prevent very small columns from wasting space */
.status,
.file-link,
.btn-sm {
  white-space: nowrap !important;
}

.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* On smaller screens convert tables into readable cards */
@media (max-width: 900px) {
  .table-wrap {
    border: 0 !important;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 12px;
    background: #fff;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  }

  tbody td {
    border-bottom: 1px dashed var(--border);
    display: grid;
    grid-template-columns: 135px 1fr;
    gap: 10px;
    align-items: start;
    padding: 8px 4px !important;
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
  }
}

@media print {
  .table-wrap {
    overflow: visible !important;
  }

  table {
    table-layout: auto !important;
  }
}


/* V12 - Two button layout: Input / Registered operations */
.section-view-switch {
  display: flex;
  gap: 10px;
  background: var(--card);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.view-btn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  background: #f1f5f9;
  color: #334155;
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 900;
  font-family: inherit;
  transition: 0.2s;
}

.view-btn:hover {
  background: #e2e8f0;
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
}

.layout-switchable {
  display: block !important;
}

.layout-switchable .card {
  width: 100%;
}

.layout-switchable .form-card {
  max-width: 620px;
  margin-inline-start: auto;
  margin-inline-end: 0;
}

.layout-switchable .list-card {
  width: 100%;
}

.layout-switchable .list-card .toolbar {
  align-items: center;
}

.layout-switchable .list-card .toolbar input,
.layout-switchable .list-card .toolbar select {
  max-width: 340px;
}

.layout-switchable table {
  font-size: 14px;
}

.layout-switchable th,
.layout-switchable td {
  vertical-align: top;
}

@media (max-width: 900px) {
  .section-view-switch {
    position: sticky;
    top: 78px;
    z-index: 8;
  }

  .layout-switchable .form-card {
    max-width: none;
  }
}

#projectsTable th:nth-child(1), #projectsTable td:nth-child(1) { width: 11%; }
#projectsTable th:nth-child(2), #projectsTable td:nth-child(2) { width: 14%; }
#projectsTable th:nth-child(3), #projectsTable td:nth-child(3) { width: 10%; }
#projectsTable th:nth-child(4), #projectsTable td:nth-child(4) { width: 10%; }
#projectsTable th:nth-child(10), #projectsTable td:nth-child(10) { width: 9%; }
#projectsTable th:nth-child(11), #projectsTable td:nth-child(11) { width: 9%; }

#workTable th:nth-child(4), #workTable td:nth-child(4),
#invoicesTable th:nth-child(5), #invoicesTable td:nth-child(5) {
  width: 9%;
}


/* V13 - Compact operations cards instead of wide tables */
.layout-switchable {
  display: block !important;
}

.layout-switchable .form-card {
  max-width: 720px;
  margin-inline-start: auto;
  margin-inline-end: auto;
}

.layout-switchable .list-card {
  width: 100%;
}

.operations-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
}

.operation-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.055);
}

.operation-card-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.operation-title {
  font-weight: 900;
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

.operation-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin-top: 3px;
}

.operation-actions .row-actions {
  justify-content: flex-start;
  max-width: 180px;
}

.operation-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-meta {
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 9px;
  min-height: 50px;
}

.compact-meta span,
.compact-value span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 4px;
}

.compact-meta strong {
  display: block;
  color: #111827;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.operation-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.compact-value {
  background: #f1f5f9;
  border-radius: 13px;
  padding: 10px;
  text-align: center;
}

.compact-value strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  color: #111827;
}

.compact-value.success strong {
  color: var(--success);
}

.section-view-switch {
  margin-top: 0;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .operations-list {
    grid-template-columns: 1fr;
  }

  .operation-card-main {
    grid-template-columns: 1fr;
  }

  .operation-actions .row-actions {
    max-width: none;
  }

  .operation-meta-grid {
    grid-template-columns: 1fr;
  }
}


/* V14 - Compact header */
.compact-header {
  min-height: 0 !important;
  padding: 12px 18px !important;
  border-radius: 22px !important;
  align-items: center !important;
  margin-bottom: 12px !important;
}

.compact-brand {
  align-items: center !important;
  gap: 12px !important;
}

.compact-logo {
  width: 70px !important;
  max-height: 70px !important;
  object-fit: contain;
}

.brand-text h1 {
  margin: 0 !important;
  font-size: 26px !important;
  line-height: 1.2 !important;
  letter-spacing: 0.2px;
}

.brand-text p {
  display: none !important;
}

.compact-user-strip {
  margin-top: 7px !important;
  gap: 8px !important;
}

.compact-user-strip .btn {
  padding: 8px 14px !important;
  min-height: 0 !important;
}

.compact-badge {
  padding: 7px 13px !important;
  font-size: 12px !important;
}

.login-card p {
  margin-top: 0 !important;
}

@media (max-width: 900px) {
  .compact-header {
    padding: 12px !important;
  }

  .compact-logo {
    width: 58px !important;
  }

  .brand-text h1 {
    font-size: 21px !important;
  }

  .compact-badge {
    display: none !important;
  }
}


/* V15 - Return to organized horizontal table rows */
.operations-list,
.operation-card,
.operation-card-main,
.operation-meta-grid,
.operation-values {
  display: unset;
}

.layout-switchable {
  display: block !important;
}

.layout-switchable .form-card {
  max-width: 720px;
  margin-inline-start: auto;
  margin-inline-end: auto;
}

.layout-switchable .list-card,
#projects .list-card,
#work .list-card,
#invoices .list-card,
#payments .list-card,
#clients .list-card {
  width: 100%;
}

#projectsTable .table-wrap,
#workTable .table-wrap,
#invoicesTable .table-wrap,
#paymentsTable .table-wrap,
#clientsTable .table-wrap {
  overflow-x: auto !important;
  overflow-y: visible !important;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
}

#projectsTable table,
#workTable table,
#invoicesTable table,
#paymentsTable table,
#clientsTable table {
  width: 100% !important;
  min-width: 1180px !important;
  table-layout: auto !important;
  border-collapse: collapse;
}

#projectsTable th,
#workTable th,
#invoicesTable th,
#paymentsTable th,
#clientsTable th {
  background: #f8fafc;
  color: #334155;
  font-weight: 900;
  font-size: 13px;
  padding: 10px 9px;
  white-space: nowrap !important;
}

#projectsTable td,
#workTable td,
#invoicesTable td,
#paymentsTable td,
#clientsTable td {
  font-size: 13px;
  padding: 9px 9px;
  vertical-align: middle;
  white-space: normal !important;
  line-height: 1.55;
}

#projectsTable tr:nth-child(even) td,
#workTable tr:nth-child(even) td,
#invoicesTable tr:nth-child(even) td,
#paymentsTable tr:nth-child(even) td,
#clientsTable tr:nth-child(even) td {
  background: #fcfdff;
}

#projectsTable td:nth-child(2),
#workTable td:nth-child(3),
#invoicesTable td:nth-child(4) {
  max-width: 240px;
}

#workTable td:nth-child(6),
#paymentsTable td:nth-child(9) {
  max-width: 220px;
}

#projectsTable .row-actions,
#workTable .row-actions,
#invoicesTable .row-actions,
#paymentsTable .row-actions,
#clientsTable .row-actions {
  min-width: 145px;
  justify-content: flex-start;
  gap: 6px;
}

#projectsTable .btn-sm,
#workTable .btn-sm,
#invoicesTable .btn-sm,
#paymentsTable .btn-sm,
#clientsTable .btn-sm {
  padding: 6px 9px !important;
  font-size: 12px !important;
}

.department-pill {
  margin: 2px;
}

.section-view-switch {
  margin-bottom: 14px !important;
}

.view-btn {
  padding: 12px 16px !important;
}

/* Keep mobile card mode only for very small screens */
@media (max-width: 700px) {
  #projectsTable .table-wrap,
  #workTable .table-wrap,
  #invoicesTable .table-wrap,
  #paymentsTable .table-wrap,
  #clientsTable .table-wrap {
    overflow-x: visible !important;
  }

  #projectsTable table,
  #workTable table,
  #invoicesTable table,
  #paymentsTable table,
  #clientsTable table {
    min-width: 0 !important;
  }
}


/* V16 - Edit records in the same input form */
.edit-mode-btn {
  background: #0f766e !important;
  color: #fff !important;
}

.cancel-edit-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #cbd5e1 !important;
}

.form-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}



/* V17 - Full width input screens */
.layout-switchable .form-card {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 24px !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(220px, 1fr)) !important;
  gap: 14px 18px !important;
  align-items: end !important;
}

.layout-switchable .form-card h2 {
  grid-column: 1 / -1 !important;
  margin: 0 0 8px !important;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f7;
}

.layout-switchable .form-card label {
  margin: 0 !important;
}

.layout-switchable .form-card input,
.layout-switchable .form-card select,
.layout-switchable .form-card textarea {
  width: 100% !important;
}

.layout-switchable .form-card textarea {
  min-height: 92px;
}

.layout-switchable .form-card .form-row {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) !important;
  gap: 14px !important;
  margin: 0 !important;
}

.layout-switchable .form-card .info-box,
.layout-switchable .form-card .permissions-box,
.layout-switchable .form-card .hint {
  grid-column: 1 / -1 !important;
}

.layout-switchable .form-card button.btn-primary,
.layout-switchable .form-card .edit-mode-btn,
.layout-switchable .form-card .cancel-edit-btn {
  grid-column: 1 / -1 !important;
  max-width: 420px;
  justify-self: center;
}

.layout-switchable .form-card select[multiple] {
  min-height: 160px;
}

/* Special forms layout */
#projects .form-card label:nth-of-type(2),
#projects .form-card label:nth-of-type(6),
#work .form-card label:nth-of-type(5),
#work .form-card label:nth-of-type(7),
#invoices .form-card label:nth-of-type(3),
#payments .form-card label:nth-of-type(8) {
  grid-column: span 2;
}

#work .form-card #workPreview {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Make input pages feel like a full page, not a small centered box */
.section.active .layout-switchable {
  width: 100%;
}

.section.active .layout-switchable .card.form-card {
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

/* Keep operation tables wide and readable */
.layout-switchable .list-card {
  width: 100% !important;
}

@media (max-width: 1200px) {
  .layout-switchable .form-card {
    grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
  }

  .layout-switchable .form-card .form-row {
    grid-template-columns: repeat(2, minmax(180px, 1fr)) !important;
  }

  #projects .form-card label:nth-of-type(2),
  #projects .form-card label:nth-of-type(6),
  #work .form-card label:nth-of-type(5),
  #work .form-card label:nth-of-type(7),
  #invoices .form-card label:nth-of-type(3),
  #payments .form-card label:nth-of-type(8) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .layout-switchable .form-card {
    grid-template-columns: 1fr !important;
    padding: 18px !important;
  }

  .layout-switchable .form-card .form-row {
    grid-template-columns: 1fr !important;
  }

  .layout-switchable .form-card button.btn-primary,
  .layout-switchable .form-card .edit-mode-btn,
  .layout-switchable .form-card .cancel-edit-btn {
    max-width: none;
  }
}


/* V18 - Compact payment rows and controlled notes */
#paymentsTable table {
  min-width: 1050px !important;
}

#paymentsTable th,
#paymentsTable td {
  vertical-align: middle !important;
}

#paymentsTable td:nth-child(2),
#paymentsTable td:nth-child(3) {
  max-width: 260px;
}

.cell-clip {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
}

.row-details {
  max-width: 170px;
}

.row-details summary {
  cursor: pointer;
  display: inline-block;
  background: #eef2ff;
  color: #1e3a8a;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

.row-details div {
  margin-top: 8px;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  max-height: 180px;
  overflow: auto;
  line-height: 1.7;
  min-width: 260px;
  white-space: normal;
  text-align: right;
}

#paymentsTable .row-actions {
  min-width: 120px;
}

/* More compact rows in all operation tables */
#projectsTable td,
#workTable td,
#invoicesTable td,
#paymentsTable td,
#clientsTable td {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

#projectsTable .table-wrap,
#workTable .table-wrap,
#invoicesTable .table-wrap,
#paymentsTable .table-wrap,
#clientsTable .table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto !important;
}

#projectsTable thead th,
#workTable thead th,
#invoicesTable thead th,
#paymentsTable thead th,
#clientsTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

@media (max-width: 700px) {
  .row-details {
    max-width: none;
  }

  .row-details div {
    min-width: 0;
  }
}


/* V19 - Fix view toggle: don't show input form while registered operations is active */
.layout-switchable .form-card.hidden,
.layout-switchable .list-card.hidden,
.form-card.hidden,
.list-card.hidden,
.hidden {
  display: none !important;
}

select {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.layout-switchable .form-card select {
  min-width: 0;
}

#clientsTable table {
  min-width: 1250px !important;
}

#clientsTable td:nth-child(1),
#clientsTable th:nth-child(1) {
  white-space: nowrap !important;
  font-weight: 900;
  color: #1e293b;
}


/* V20 - duplicate clients merge button */
#mergeDuplicateClientsBtn {
  white-space: nowrap;
}

.toolbar #mergeDuplicateClientsBtn {
  min-width: 170px;
}


/* V21 - Client statement report */
.client-statement-report h3 {
  margin-top: 22px;
}

.statement-client-card,
.statement-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.statement-client-card > div,
.statement-summary > div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px;
}

.statement-client-card span,
.statement-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.statement-client-card strong,
.statement-summary strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.5;
}

.statement-summary strong.success {
  color: var(--success);
}

.statement-summary strong.danger,
.client-statement-report .danger {
  color: var(--danger);
}

.client-statement-report .success {
  color: var(--success);
}

.client-statement-report table {
  min-width: 1100px !important;
}

@media print {
  .client-statement-report table {
    min-width: 0 !important;
    font-size: 10px;
  }

  .statement-client-card,
  .statement-summary {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* V22 - Payments search */
.payments-toolbar {
  display: grid !important;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.payments-toolbar input {
  width: 100% !important;
}

#paymentsTable table {
  min-width: 1150px !important;
}

#paymentsTable td:nth-child(4),
#paymentsTable th:nth-child(4) {
  white-space: nowrap !important;
  font-weight: 800;
}

@media (max-width: 700px) {
  .payments-toolbar {
    grid-template-columns: 1fr;
  }
}


/* V27 - Dashboard cards instead of wide tables */
.dashboard-insights {
  align-items: stretch;
}

.dashboard-panel {
  min-height: 520px;
  overflow: hidden !important;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title-row h2 {
  margin: 0 !important;
}

.panel-hint {
  color: var(--muted);
  background: #f1f5f9;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dept-dashboard-list,
.client-dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 620px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline-end: 4px;
}

.dept-dashboard-item,
.client-dashboard-card {
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.045);
}

.dept-dashboard-head,
.client-dashboard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dept-dashboard-head > div:first-child,
.client-dashboard-head > div:first-child {
  min-width: 0;
}

.dept-dashboard-head strong,
.client-dashboard-head strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
  line-height: 1.5;
}

.client-dashboard-head strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.client-dashboard-head span:not(.client-status) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  font-weight: 800;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 950;
  margin-inline-start: 8px;
}

.dept-value {
  color: var(--text);
  font-weight: 950;
  font-size: 15px;
  white-space: nowrap;
}

.dept-progress {
  height: 14px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.dept-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  min-width: 4px;
}

.dept-dashboard-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 8px;
}

.client-status {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.client-status.success,
.client-metric strong.success {
  color: var(--success);
}

.client-status.danger,
.client-metric strong.danger {
  color: var(--danger);
}

.client-status.warning,
.client-metric strong.warning {
  color: #b45309;
}

.client-status.success {
  background: #ecfdf5;
}

.client-status.danger {
  background: #fef2f2;
}

.client-status.warning {
  background: #fffbeb;
}

.client-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.client-metric {
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 14px;
  padding: 10px;
  min-width: 0;
}

.client-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 5px;
}

.client-metric strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 950;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Keep dashboard clean: no table scrolling in these two widgets */
#departmentChart,
#clientBalanceTable {
  overflow: hidden !important;
}

@media (max-width: 1100px) {
  .client-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-panel {
    min-height: auto;
  }
}

@media (max-width: 700px) {
  .panel-title-row,
  .dept-dashboard-head,
  .client-dashboard-head,
  .dept-dashboard-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-hint,
  .dept-value,
  .client-status {
    white-space: normal;
  }

  .client-metrics-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .dept-dashboard-list,
  .client-dashboard-list {
    max-height: none;
    overflow: visible;
  }

  .dashboard-panel {
    min-height: 0;
  }
}


/* V28 - Projects search moved above the table */
.projects-list-card {
  width: 100%;
}

.projects-toolbar {
  display: grid !important;
  grid-template-columns: minmax(260px, 1.35fr) minmax(220px, 0.9fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.projects-toolbar input {
  width: 100% !important;
}

.po-search-inline-result {
  margin-bottom: 14px;
}

.po-search-inline-result:empty {
  display: none;
}

.po-search-inline-result .po-result {
  border: 1px solid #e2e8f0;
  background: #fbfdff;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
}

.po-search-inline-result .po-result h3 {
  margin-top: 0;
  margin-bottom: 12px;
  line-height: 1.7;
}

#projectsTable table {
  min-width: 1180px !important;
}

#projectsTable td:nth-child(1),
#projectsTable td:nth-child(2),
#projectsTable td:nth-child(3) {
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .projects-toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .projects-toolbar {
    grid-template-columns: 1fr;
  }
}


/* V29 - Department cards horizontally, clients underneath each department */
.dashboard-full {
  display: block !important;
}

.department-clients-panel {
  overflow: visible !important;
  min-height: 0 !important;
}

.department-clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
  align-items: start;
}

.dept-client-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
  min-width: 0;
}

.dept-client-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.dept-client-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dept-client-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 950;
  color: var(--text);
  line-height: 1.3;
}

.dept-client-head > strong {
  font-size: 18px;
  font-weight: 950;
  color: var(--text);
  white-space: nowrap;
}

.dept-progress.wide {
  height: 14px;
  margin: 8px 0;
}

.dept-client-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin: 8px 0 14px;
}

.dept-clients-title {
  background: #f1f5f9;
  color: #334155;
  border-radius: 999px;
  display: inline-block;
  padding: 7px 12px;
  font-weight: 950;
  font-size: 12px;
  margin-bottom: 10px;
}

.dept-clients-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline-end: 4px;
}

.dept-client-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(300px, 2fr) auto;
  gap: 10px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #e8eef5;
  border-radius: 16px;
  padding: 11px;
}

.dept-client-name {
  min-width: 0;
}

.dept-client-name strong {
  display: block;
  color: var(--text);
  font-weight: 950;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.dept-client-name span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
  font-weight: 800;
}

.dept-client-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 7px;
}

.dept-client-numbers div {
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.dept-client-numbers span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  margin-bottom: 4px;
}

.dept-client-numbers strong {
  color: var(--text);
  font-weight: 950;
  font-size: 12px;
  line-height: 1.4;
}

.dept-client-numbers strong.success {
  color: var(--success);
}

.dept-client-numbers strong.danger {
  color: var(--danger);
}

.dept-client-numbers strong.warning {
  color: #b45309;
}

.more-clients-note {
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 10px;
  font-weight: 900;
  font-size: 12px;
}

.empty.small {
  padding: 14px;
  font-size: 13px;
}

@media (max-width: 1200px) {
  .department-clients-grid {
    grid-template-columns: 1fr;
  }

  .dept-client-row {
    grid-template-columns: 1fr;
  }

  .dept-client-numbers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .client-status {
    justify-self: start;
  }
}

@media (max-width: 700px) {
  .dept-client-head,
  .dept-client-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .dept-client-head > strong {
    white-space: normal;
  }

  .dept-client-numbers {
    grid-template-columns: 1fr;
  }
}

@media print {
  .department-clients-grid {
    grid-template-columns: 1fr;
  }

  .dept-clients-list {
    max-height: none;
    overflow: visible;
  }
}


/* V30 - smart searchable selects to avoid long dropdown hunting */
.smart-select-search {
  width: 100% !important;
  padding: 10px 12px !important;
  border: 1px solid #dbe3ef !important;
  border-radius: 12px !important;
  background: #f8fafc !important;
  color: var(--text) !important;
  font-family: inherit !important;
  font-weight: 800 !important;
  font-size: 13px !important;
  margin: 6px 0 6px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.smart-select-search:focus {
  outline: 2px solid rgba(17, 24, 39, 0.18);
  background: #fff !important;
}

.smart-select-label select {
  margin-top: 0 !important;
}

.report-toolbar .smart-select-search {
  min-width: 210px;
  max-width: 320px;
}

.report-toolbar #reportClient {
  min-width: 220px;
}

@media (max-width: 900px) {
  .report-toolbar .smart-select-search {
    max-width: none;
  }
}


/* V31 - make report client search clearer */
#reportClientSmartSearch {
  border-width: 2px !important;
  background: #ffffff !important;
}

.report-toolbar #reportClientSmartSearch::placeholder {
  color: #64748b;
}


/* V32 - Printable client statement ledger: force real table, not mobile cards */
.ledger-title {
  color: var(--text);
  font-weight: 950;
}

.statement-ledger-table table th:nth-child(7),
.statement-ledger-table table th:nth-child(8),
.statement-ledger-table table th:nth-child(9),
.statement-ledger-table table td:nth-child(7),
.statement-ledger-table table td:nth-child(8),
.statement-ledger-table table td:nth-child(9) {
  font-weight: 950;
  text-align: center;
}

.statement-ledger-table table td:nth-child(7) {
  color: var(--danger);
}

.statement-ledger-table table td:nth-child(8) {
  color: var(--success);
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  .client-statement-report {
    direction: rtl;
    font-size: 10px !important;
  }

  .client-statement-report h3,
  .client-statement-report .ledger-title {
    font-size: 13px !important;
    margin: 10px 0 6px !important;
    padding: 0 !important;
  }

  .statement-client-card,
  .statement-summary {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
    margin: 6px 0 !important;
    page-break-inside: avoid !important;
  }

  .statement-client-card > div,
  .statement-summary > div {
    padding: 5px !important;
    border-radius: 6px !important;
    background: #fff !important;
    border: 1px solid #d9dee7 !important;
  }

  .statement-client-card span,
  .statement-summary span {
    font-size: 8px !important;
    margin-bottom: 2px !important;
  }

  .statement-client-card strong,
  .statement-summary strong {
    font-size: 10px !important;
    line-height: 1.25 !important;
  }

  .statement-ledger-table .table-wrap,
  .statement-work-table .table-wrap,
  .client-statement-report .table-wrap {
    overflow: visible !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0 !important;
    page-break-inside: auto !important;
  }

  .statement-ledger-table table,
  .statement-ledger-table thead,
  .statement-ledger-table tbody,
  .statement-ledger-table tfoot,
  .statement-ledger-table tr,
  .statement-ledger-table th,
  .statement-ledger-table td,
  .statement-work-table table,
  .statement-work-table thead,
  .statement-work-table tbody,
  .statement-work-table tfoot,
  .statement-work-table tr,
  .statement-work-table th,
  .statement-work-table td {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .statement-ledger-table table,
  .statement-work-table table {
    display: table !important;
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    background: #fff !important;
    font-size: 8px !important;
  }

  .statement-ledger-table thead,
  .statement-work-table thead {
    display: table-header-group !important;
  }

  .statement-ledger-table tbody,
  .statement-work-table tbody {
    display: table-row-group !important;
  }

  .statement-ledger-table tr,
  .statement-work-table tr {
    display: table-row !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    border: 0 !important;
    background: transparent !important;
  }

  .statement-ledger-table th,
  .statement-ledger-table td,
  .statement-work-table th,
  .statement-work-table td {
    display: table-cell !important;
    border: 1px solid #cbd5e1 !important;
    padding: 3px 4px !important;
    line-height: 1.35 !important;
    text-align: right !important;
    vertical-align: top !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .statement-ledger-table th,
  .statement-work-table th {
    background: #f1f5f9 !important;
    color: #111827 !important;
    font-weight: 950 !important;
    text-align: center !important;
  }

  .statement-ledger-table td::before,
  .statement-work-table td::before {
    content: none !important;
    display: none !important;
  }

  /* Ledger column sizing */
  .statement-ledger-table th:nth-child(1),
  .statement-ledger-table td:nth-child(1) { width: 8% !important; text-align: center !important; }

  .statement-ledger-table th:nth-child(2),
  .statement-ledger-table td:nth-child(2) { width: 7% !important; text-align: center !important; }

  .statement-ledger-table th:nth-child(3),
  .statement-ledger-table td:nth-child(3) { width: 9% !important; text-align: center !important; }

  .statement-ledger-table th:nth-child(4),
  .statement-ledger-table td:nth-child(4) { width: 10% !important; text-align: center !important; }

  .statement-ledger-table th:nth-child(5),
  .statement-ledger-table td:nth-child(5) { width: 18% !important; }

  .statement-ledger-table th:nth-child(6),
  .statement-ledger-table td:nth-child(6) { width: 24% !important; }

  .statement-ledger-table th:nth-child(7),
  .statement-ledger-table td:nth-child(7),
  .statement-ledger-table th:nth-child(8),
  .statement-ledger-table td:nth-child(8),
  .statement-ledger-table th:nth-child(9),
  .statement-ledger-table td:nth-child(9) {
    width: 8% !important;
    text-align: center !important;
    font-weight: 950 !important;
    white-space: nowrap !important;
  }

  .statement-ledger-table td:nth-child(7) { color: #dc2626 !important; }
  .statement-ledger-table td:nth-child(8) { color: #059669 !important; }
  .statement-ledger-table td:nth-child(9) { color: #111827 !important; }

  /* Hide non-essential browser-like decorative elements in printed statement */
  #advancedReportOutput {
    overflow: visible !important;
  }
}


/* V33 - clean executive home dashboard */
.executive-header {
  min-height: 82px !important;
  padding: 14px 18px !important;
  align-items: center !important;
  border-radius: 24px !important;
}

.executive-brand {
  align-items: center !important;
}

.executive-brand .header-logo {
  width: 62px !important;
  height: 62px !important;
  object-fit: contain;
}

.executive-brand .brand-text h1 {
  font-size: 28px !important;
  margin: 0 !important;
  color: #0f172a;
}

.executive-brand .brand-text p {
  margin: 2px 0 0 !important;
  color: #64748b;
  font-weight: 800;
}

.executive-header-center {
  flex: 1;
  text-align: center;
  color: #334155;
  font-weight: 900;
}

.executive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 0;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 14px;
  min-width: 42px;
  height: 42px;
  font-weight: 950;
  cursor: pointer;
  position: relative;
}

.dashboard-new {
  display: none;
}

.dashboard-new.active {
  display: block;
}

.dashboard-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin: 4px 0 14px;
}

.dashboard-title-row h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 950;
}

.dashboard-title-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.dashboard-mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.executive-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.executive-kpi {
  background: #fff;
  border: 1px solid #e6edf5;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 130px;
}

.executive-kpi span {
  color: #64748b;
  display: block;
  font-weight: 900;
  margin-bottom: 8px;
}

.executive-kpi strong {
  display: block;
  font-size: 26px;
  font-weight: 950;
  color: #0f172a;
  line-height: 1.2;
}

.executive-kpi small {
  color: #64748b;
  font-weight: 800;
}

.kpi-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 950;
}

.kpi-work .kpi-icon { background: #eaf3ff; color: #2563eb; }
.kpi-invoices .kpi-icon { background: #fff7ed; color: #ea580c; }
.kpi-payments .kpi-icon { background: #ecfdf5; color: #16a34a; }
.kpi-outstanding .kpi-icon { background: #fef2f2; color: #dc2626; }

.quick-actions-card,
.dashboard-tools,
.home-panel {
  background: #fff;
  border: 1px solid #e6edf5;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.quick-actions-card {
  margin-top: 14px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 950;
}

.section-heading span {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.quick-actions-grid,
.tools-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.quick-actions-grid button,
.tools-grid button,
.panel-footer-btn {
  border: 1px solid #dbe5f1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 16px;
  padding: 13px 12px;
  font-weight: 950;
  cursor: pointer;
  font-family: inherit;
}

.quick-actions-grid button:hover,
.tools-grid button:hover,
.panel-footer-btn:hover,
.recent-row:hover,
.dashboard-alert:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.dashboard-workspace {
  display: grid;
  grid-template-columns: 0.95fr 1.15fr 1.25fr;
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}

.home-panel {
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

.dashboard-alerts,
.dashboard-recent,
.dashboard-departments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.dashboard-alert,
.recent-row {
  border: 1px solid #e5eaf1;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: inherit;
}

.dashboard-alert {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
}

.alert-count {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 950;
  color: #fff;
  background: #64748b;
}

.dashboard-alert.danger .alert-count { background: #dc2626; }
.dashboard-alert.warning .alert-count { background: #f59e0b; }
.dashboard-alert.info .alert-count { background: #2563eb; }

.alert-title {
  font-weight: 950;
  color: #0f172a;
}

.dashboard-alert small {
  color: #64748b;
  font-weight: 800;
}

.recent-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.recent-badge {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 950;
  background: #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.recent-badge.payment { background: #ecfdf5; color: #059669; }
.recent-badge.invoice { background: #fff7ed; color: #ea580c; }
.recent-badge.work { background: #f5f3ff; color: #7c3aed; }
.recent-badge.project { background: #eff6ff; color: #2563eb; }

.recent-main strong {
  display: block;
  color: #0f172a;
  font-weight: 950;
  line-height: 1.4;
}

.recent-main small,
.recent-side small {
  display: block;
  color: #64748b;
  font-weight: 800;
  line-height: 1.6;
}

.recent-side {
  text-align: left;
  color: #334155;
  font-weight: 900;
}

.department-mini-row {
  border: 1px solid #e5eaf1;
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}

.department-mini-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #0f172a;
  font-weight: 950;
  margin-bottom: 8px;
}

.department-mini-progress {
  background: #e5e7eb;
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
}

.department-mini-progress div {
  height: 100%;
  background: #0f172a;
  border-radius: 999px;
}

.department-mini-row small {
  display: block;
  color: #64748b;
  font-weight: 800;
  margin-top: 6px;
}

.panel-footer-btn {
  margin-top: 14px;
  width: 100%;
}

.dashboard-tools {
  margin-top: 14px;
}

.compact-empty {
  padding: 24px !important;
  min-height: 120px;
  display: grid;
  place-items: center;
}

@media (max-width: 1200px) {
  .executive-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-workspace {
    grid-template-columns: 1fr;
  }

  .quick-actions-grid,
  .tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .executive-header,
  .dashboard-title-row,
  .section-heading,
  .executive-actions {
    flex-direction: column;
    align-items: stretch !important;
  }

  .executive-kpis,
  .quick-actions-grid,
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .executive-kpi,
  .recent-row,
  .dashboard-alert {
    grid-template-columns: 1fr;
    display: grid;
  }

  .recent-side {
    text-align: right;
  }
}

@media print {
  .dashboard-title-row,
  .quick-actions-card,
  .dashboard-tools {
    display: none !important;
  }
}


/* V34 - actionable dashboard alert filters */
.active-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #dbe5f1;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.active-filter-bar strong {
  color: #0f172a;
  font-weight: 950;
}

.active-filter-bar span {
  color: #334155;
  font-weight: 900;
}

.dashboard-alert small {
  white-space: nowrap;
}

.dashboard-alert[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .active-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-alert small {
    white-space: normal;
  }
}


/* V35 - search/select reliability */
.smart-select-search {
  position: relative;
}

.smart-select-label select option[selected],
.smart-select-label select:focus {
  font-weight: 900;
}

.edit-mode-btn {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}


/* V36 - SADEN enterprise theme inspired by corporate ERP portals */
:root {
  --saden-teal: #006c73;
  --saden-teal-dark: #063842;
  --saden-navy: #071423;
  --saden-cyan: #34d6e8;
  --saden-red: #d91f2f;
  --saden-gold: #f59e0b;
}

body {
  background:
    radial-gradient(circle at 15% 12%, rgba(52, 214, 232, 0.12), transparent 25%),
    radial-gradient(circle at 92% 4%, rgba(217, 31, 47, 0.08), transparent 22%),
    linear-gradient(180deg, #f4f8fb 0%, #eef4f8 100%) !important;
}

.container {
  max-width: 1760px !important;
  padding-top: 18px !important;
}

.saden-topbar {
  min-height: 78px;
  border-radius: 0;
  background: #ffffff;
  border: 1px solid #e6edf5;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
}

.avatar-pill {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef2ff;
  color: #0f172a;
  font-weight: 950;
  border: 1px solid #dbe3ef;
}

.user-welcome strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
  font-weight: 950;
}

.user-welcome small {
  display: block;
  color: #64748b;
  margin-top: 3px;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
}

.top-icon {
  border: 1px solid #e5eaf1;
  background: #fff;
  color: #0f172a;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 17px;
  position: relative;
}

.saden-logo-wrap {
  justify-self: end;
  display: flex;
  align-items: center;
}

.saden-top-logo {
  height: 66px;
  max-width: 210px;
  object-fit: contain;
}

.enterprise-tabs {
  margin: 0 !important;
  border-radius: 0 !important;
  background: linear-gradient(90deg, #071423 0%, #08263a 58%, #064e58 100%) !important;
  border: 0 !important;
  box-shadow: 0 18px 36px rgba(7, 20, 35, 0.18);
  padding: 0 !important;
  overflow-x: auto;
}

.enterprise-tabs .tab-btn {
  min-height: 70px;
  border-radius: 0 !important;
  color: rgba(255,255,255,0.84) !important;
  background: transparent !important;
  border-inline-start: 1px solid rgba(255,255,255,0.08) !important;
  font-size: 15px !important;
  font-weight: 900 !important;
  padding: 0 24px !important;
  position: relative;
  white-space: nowrap;
}

.enterprise-tabs .tab-btn:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
}

.enterprise-tabs .tab-btn.active {
  background: linear-gradient(180deg, rgba(0,108,115,0.95), rgba(0,78,88,0.94)) !important;
  color: #fff !important;
  box-shadow: inset 0 -4px 0 var(--saden-cyan);
}

.enterprise-hero {
  min-height: 178px;
  margin: 0 -10px 20px;
  padding: 28px 34px;
  display: grid;
  grid-template-columns: 260px 1fr auto;
  gap: 22px;
  align-items: center;
  color: #fff;
  background:
    linear-gradient(120deg, rgba(7,20,35,.90), rgba(0,108,115,.87)),
    radial-gradient(circle at 18% 22%, rgba(52,214,232,.24), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(255,255,255,.16), transparent 24%);
  border-radius: 0 0 26px 26px;
  box-shadow: 0 20px 44px rgba(7, 20, 35, 0.20);
  position: relative;
  overflow: hidden;
}

.enterprise-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,.12) 0 1px, transparent 1px 45px),
    radial-gradient(circle at 5% 20%, rgba(255,255,255,.18), transparent 16%);
  pointer-events: none;
}

.hero-date-card,
.hero-copy,
.hero-actions {
  position: relative;
  z-index: 1;
}

.hero-date-card {
  width: 210px;
  border: 1px solid rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.10);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 18px;
  font-weight: 900;
}

.hero-date-card .header-date {
  display: block;
  font-size: 18px;
  line-height: 1.6;
}

.hero-date-card small {
  color: rgba(255,255,255,0.8);
}

.hero-copy {
  text-align: right;
}

.hero-copy h2 {
  margin: 0;
  color: #fff;
  font-size: 38px;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.hero-copy p {
  color: rgba(255,255,255,0.82);
  font-size: 17px;
  font-weight: 800;
  margin: 12px 0 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.hero-btn {
  border: 1px solid rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.14);
  color: #fff;
  padding: 13px 16px;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 950;
  cursor: pointer;
}

.hero-btn.primary {
  background: #fff;
  color: #063842;
}

.executive-kpis {
  margin-top: 0 !important;
  gap: 16px !important;
}

.executive-kpi {
  border: 1px solid #e6edf5 !important;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.07) !important;
  background: #fff !important;
  overflow: hidden;
  position: relative;
}

.executive-kpi::after {
  content: "";
  position: absolute;
  inset-inline-end: 0;
  top: 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--saden-teal));
}

.kpi-outstanding::after { background: linear-gradient(90deg, transparent, var(--saden-red)); }
.kpi-payments::after { background: linear-gradient(90deg, transparent, #10b981); }
.kpi-invoices::after { background: linear-gradient(90deg, transparent, #2563eb); }
.kpi-work::after { background: linear-gradient(90deg, transparent, #f59e0b); }

.enterprise-actions {
  border-radius: 20px !important;
  padding: 14px 18px !important;
}

.enterprise-actions .section-heading {
  margin-bottom: 10px !important;
}

.enterprise-actions .quick-actions-grid button {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
}

.enterprise-actions .quick-actions-grid button span {
  font-size: 18px;
}

.dashboard-workspace {
  grid-template-columns: 1fr 1.15fr 1.15fr !important;
  margin-top: 16px !important;
}

.home-panel {
  border-radius: 20px !important;
  border: 1px solid #e6edf5 !important;
}

.dashboard-alert,
.recent-row,
.department-mini-row {
  border-radius: 14px !important;
}

.dashboard-tools {
  border-radius: 20px !important;
}

.tools-grid button {
  min-height: 52px;
}

.po-items-box {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #f8fafc;
  padding: 14px;
  margin: 12px 0;
}

.po-items-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.po-items-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.po-items-head p,
.po-item-row small {
  margin: 0;
  color: #64748b;
  font-size: 12px;
}

.po-total-chip {
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  border: 1px solid #99f6e4;
  padding: 7px 12px;
  font-weight: 900;
  white-space: nowrap;
}

.po-total-chip.danger {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

.po-total-chip.success {
  color: #16a34a;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.po-item-entry {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, .55fr) minmax(110px, .35fr) auto;
  gap: 10px;
  align-items: end;
}

.po-item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #e2e8f0;
}

.po-items-list {
  margin-top: 8px;
}

@media (max-width: 1200px) {
  .saden-topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .saden-logo-wrap,
  .topbar-left,
  .topbar-actions {
    justify-self: stretch;
    justify-content: center;
  }

  .enterprise-hero {
    grid-template-columns: 1fr;
  }

  .hero-date-card {
    width: auto;
  }

  .hero-actions {
    justify-content: stretch;
  }

  .hero-btn {
    flex: 1;
  }
}

@media (max-width: 700px) {
  .enterprise-hero {
    padding: 22px 18px;
  }

  .hero-copy h2 {
    font-size: 28px;
  }

  .enterprise-tabs .tab-btn {
    min-height: 58px;
    padding: 0 16px !important;
  }
}

@media print {
  .saden-topbar,
  .enterprise-tabs,
  .enterprise-hero {
    display: none !important;
  }
}


/* V37 - Fix page horizontal scrolling / keep all home content inside screen */
html,
body {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

body * {
  min-width: 0;
}

.container {
  width: min(100%, 1760px) !important;
  max-width: 100% !important;
  margin-inline: auto !important;
  padding-inline: clamp(10px, 1.5vw, 18px) !important;
  overflow-x: clip !important;
}

.saden-topbar,
.enterprise-tabs,
.enterprise-hero,
.executive-kpis,
.quick-actions-card,
.dashboard-workspace,
.dashboard-tools,
.section,
.card,
.home-panel {
  max-width: 100% !important;
  overflow-wrap: anywhere;
}

.saden-topbar {
  width: 100% !important;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important;
}

.user-welcome,
.user-welcome strong,
.user-welcome small,
.hero-copy,
.hero-copy h2,
.hero-copy p,
.recent-main,
.recent-side,
.department-mini-head,
.section-heading {
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

.enterprise-tabs {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: repeat(10, minmax(0, 1fr)) !important;
  gap: 0 !important;
  overflow: hidden !important;
}

.enterprise-tabs .tab-btn {
  min-width: 0 !important;
  width: 100% !important;
  padding-inline: clamp(6px, 1vw, 16px) !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.enterprise-hero {
  width: 100% !important;
  margin: 0 0 20px 0 !important;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(180px, auto) !important;
  padding-inline: clamp(16px, 2vw, 28px) !important;
}

.hero-actions {
  min-width: 0 !important;
}

.hero-btn {
  max-width: 100% !important;
  white-space: nowrap;
}

.executive-kpis,
.quick-actions-grid,
.tools-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
}

.executive-kpi {
  min-width: 0 !important;
}

.dashboard-workspace {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.home-panel,
.dashboard-alert,
.recent-row,
.department-mini-row {
  min-width: 0 !important;
}

.table-wrap {
  max-width: 100% !important;
  overflow-x: auto !important;
}

select,
input,
textarea,
button {
  max-width: 100% !important;
}

@media (max-width: 1350px) {
  .enterprise-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }

  .enterprise-tabs .tab-btn {
    min-height: 54px !important;
  }

  .enterprise-hero {
    grid-template-columns: 1fr !important;
  }

  .hero-date-card {
    width: 100% !important;
  }

  .hero-actions {
    justify-content: stretch !important;
  }

  .hero-btn {
    flex: 1 1 180px !important;
  }

  .dashboard-workspace {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  .enterprise-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .saden-topbar {
    grid-template-columns: 1fr !important;
  }

  .topbar-left,
  .topbar-actions,
  .saden-logo-wrap {
    justify-self: stretch !important;
    justify-content: center !important;
  }

  .enterprise-hero {
    padding: 18px 12px !important;
  }
}

/* shared-work-wide-form */
#sharedWork .layout .card.form-card,
#sharedWork .layout-switchable .card.form-card {
  width: 100% !important;
  max-width: none !important;
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  gap: 14px 18px !important;
  align-items: start !important;
}

#sharedWork .layout .card.form-card.hidden,
#sharedWork .layout-switchable .card.form-card.hidden,
#sharedWork .shared-sub-form.hidden {
  display: none !important;
}

#sharedWork .layout .form-card > h2,
#sharedWork .layout .form-card > .info-box,
#sharedWork .layout .form-card > .po-items-box,
#sharedWork .layout .form-card > #sharedItemsDraftList,
#sharedWork .layout .form-card > #addSharedWorkBtn,
#sharedWork .layout-switchable .form-card > h2,
#sharedWork .layout-switchable .form-card > .info-box,
#sharedWork .layout-switchable .form-card > .po-items-box,
#sharedWork .layout-switchable .form-card > #sharedItemsDraftList,
#sharedWork .layout-switchable .form-card > #addSharedWorkBtn {
  grid-column: 1 / -1 !important;
}

#sharedWork .layout .form-card > label,
#sharedWork .layout-switchable .form-card > label {
  grid-column: span 6 !important;
  min-width: 0 !important;
}

#sharedWork .layout .form-card > label:has(#sharedItemDesc),
#sharedWork .layout .form-card > label:has(#sharedTotalAmount),
#sharedWork .layout .form-card > label:has(#sharedStatus),
#sharedWork .layout .form-card > label:has(#sharedNotes),
#sharedWork .layout-switchable .form-card > label:has(#sharedItemDesc),
#sharedWork .layout-switchable .form-card > label:has(#sharedTotalAmount),
#sharedWork .layout-switchable .form-card > label:has(#sharedStatus),
#sharedWork .layout-switchable .form-card > label:has(#sharedNotes) {
  grid-column: 1 / -1 !important;
}

#sharedWork .layout .form-card > .form-row,
#sharedWork .layout-switchable .form-card > .form-row {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px !important;
  margin: 0 !important;
}

#sharedWork .layout .form-card > .form-row label,
#sharedWork .layout-switchable .form-card > .form-row label {
  min-width: 0 !important;
}

#sharedWork .layout .form-card .po-items-box,
#sharedWork .layout-switchable .form-card .po-items-box {
  width: 100% !important;
  margin: 0 !important;
}

#sharedWork .layout .form-card .po-items-head,
#sharedWork .layout-switchable .form-card .po-items-head {
  align-items: flex-start !important;
  gap: 12px !important;
}

#sharedWork .layout .form-card .po-total-chip,
#sharedWork .layout-switchable .form-card .po-total-chip {
  white-space: nowrap !important;
}

#sharedWork .layout .form-card .clean-po-item-entry,
#sharedWork .layout-switchable .form-card .clean-po-item-entry {
  display: grid !important;
  grid-template-columns: minmax(260px, 2fr) minmax(170px, 1fr) minmax(120px, .6fr) minmax(180px, auto) !important;
  gap: 12px !important;
  align-items: end !important;
}

#sharedWork .layout .form-card .clean-po-item-entry label,
#sharedWork .layout-switchable .form-card .clean-po-item-entry label {
  min-width: 0 !important;
}

#sharedWork .layout .form-card > #addSharedItemBtn,
#sharedWork .layout-switchable .form-card > #addSharedItemBtn {
  grid-column: 1 / -1 !important;
  width: 100% !important;
}

#sharedWork .layout .form-card .po-add-item-btn,
#sharedWork .layout .form-card #addSharedItemBtn,
#sharedWork .layout .form-card #addSharedWorkBtn,
#sharedWork .layout-switchable .form-card .po-add-item-btn,
#sharedWork .layout-switchable .form-card #addSharedItemBtn,
#sharedWork .layout-switchable .form-card #addSharedWorkBtn {
  min-height: 48px !important;
  justify-content: center !important;
}

#sharedWork .layout .form-card textarea,
#sharedWork .layout-switchable .form-card textarea {
  min-height: 90px !important;
}

@media (max-width: 900px) {
  #sharedWork .layout .card.form-card,
  #sharedWork .layout-switchable .card.form-card {
    grid-template-columns: 1fr !important;
  }

  #sharedWork .layout .form-card > label,
  #sharedWork .layout .form-card > .form-row,
  #sharedWork .layout .form-card > .po-items-box,
  #sharedWork .layout .form-card > #sharedItemsDraftList,
  #sharedWork .layout .form-card > #addSharedWorkBtn,
  #sharedWork .layout .form-card > #addSharedItemBtn,
  #sharedWork .layout-switchable .form-card > label,
  #sharedWork .layout-switchable .form-card > .form-row,
  #sharedWork .layout-switchable .form-card > .po-items-box,
  #sharedWork .layout-switchable .form-card > #sharedItemsDraftList,
  #sharedWork .layout-switchable .form-card > #addSharedWorkBtn,
  #sharedWork .layout-switchable .form-card > #addSharedItemBtn {
    grid-column: 1 / -1 !important;
  }

  #sharedWork .layout .form-card > .form-row,
  #sharedWork .layout .form-card .clean-po-item-entry,
  #sharedWork .layout-switchable .form-card > .form-row,
  #sharedWork .layout-switchable .form-card .clean-po-item-entry {
    grid-template-columns: 1fr !important;
  }
}

/* shared-finance-center */
#sharedWork .shared-sub-form {
  width: 100% !important;
  max-width: none !important;
}

#sharedWork .section-view-switch {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

#sharedWork .shared-finance-entry {
  grid-template-columns: minmax(260px, 2fr) minmax(120px, .7fr) minmax(130px, .7fr) minmax(170px, 1fr) minmax(150px, auto) !important;
}

#sharedWork .shared-distribution-entry {
  grid-template-columns: minmax(220px, 1.4fr) minmax(120px, .7fr) minmax(220px, 1.5fr) minmax(140px, .8fr) minmax(110px, .6fr) minmax(150px, auto) !important;
}

#sharedWork .shared-sub-form .po-items-box {
  grid-column: 1 / -1 !important;
}

#sharedWork .layout .card.form-card[data-shared-panel="balance"],
#sharedWork .layout-switchable .card.form-card[data-shared-panel="balance"],
#sharedWork [data-shared-panel="balance"] {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  grid-column: 1 / -1 !important;
  padding: 14px 12px !important;
}

#sharedWork .layout .card.form-card[data-shared-panel="projectList"],
#sharedWork .layout-switchable .card.form-card[data-shared-panel="projectList"],
#sharedWork [data-shared-panel="projectList"] {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  grid-column: 1 / -1 !important;
  padding: 18px !important;
}

#sharedWork [data-shared-panel="projectList"].hidden,
#sharedWork .layout .card.form-card[data-shared-panel="projectList"].hidden,
#sharedWork .layout-switchable .card.form-card[data-shared-panel="projectList"].hidden {
  display: none !important;
}

#sharedProjectsTable {
  width: 100% !important;
  max-width: 100% !important;
  direction: rtl;
}

#sharedProjectsTable .table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

#sharedProjectsTable table {
  width: 100% !important;
  min-width: 980px !important;
  table-layout: auto !important;
  font-size: 13px;
}

#sharedProjectsTable th,
#sharedProjectsTable td {
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: anywhere !important;
  padding: 10px 12px !important;
  vertical-align: middle !important;
}

#sharedWork [data-shared-panel="balance"] h2 {
  margin-bottom: 10px !important;
}

#sharedWork [data-shared-panel="balance"] .info-box {
  margin: 0 0 10px !important;
  padding: 10px 12px !important;
}

#sharedWork [data-shared-panel="balance"].hidden {
  display: none !important;
}

#sharedWork .shared-sub-form.hidden,
#sharedWork .layout .card.form-card.shared-sub-form.hidden,
#sharedWork .layout-switchable .card.form-card.shared-sub-form.hidden,
#sharedWork .layout .card.form-card[data-shared-panel="balance"].hidden,
#sharedWork .layout-switchable .card.form-card[data-shared-panel="balance"].hidden {
  display: none !important;
}

.shared-balance-toolbar {
  justify-content: flex-start;
  margin: 0 0 8px !important;
}

#sharedBalanceTable {
  width: 100%;
  max-width: 100%;
  direction: rtl;
  grid-column: 1 / -1 !important;
  margin-top: 8px;
}

#sharedBalanceTable .table-wrap {
  overflow-x: auto !important;
  overflow-y: visible !important;
  width: 100%;
  max-width: 100%;
  direction: rtl;
}

#sharedBalanceTable table {
  direction: rtl;
  width: max-content !important;
  min-width: 1900px !important;
  table-layout: auto;
  font-size: 11.5px;
}

#sharedBalanceTable th,
#sharedBalanceTable td {
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  min-width: 78px !important;
  padding: 7px 7px !important;
  text-align: center;
}

#sharedBalanceTable th:first-child,
#sharedBalanceTable td:first-child,
#sharedBalanceTable th:nth-child(2),
#sharedBalanceTable td:nth-child(2),
#sharedBalanceTable th:nth-child(3),
#sharedBalanceTable td:nth-child(3) {
  min-width: 150px !important;
  text-align: right;
}

#sharedBalanceTable th:first-child,
#sharedBalanceTable td:first-child {
  min-width: 105px !important;
}

#sharedBalanceTable th:nth-child(2),
#sharedBalanceTable td:nth-child(2) {
  min-width: 230px !important;
}

@media (max-width: 900px) {
  #sharedWork .section-view-switch,
  #sharedWork .shared-finance-entry {
    grid-template-columns: 1fr !important;
  }
}

@media print {
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) .section:not(#sharedWork),
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) .enterprise-tabs,
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) .saden-topbar,
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) .section-view-switch,
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) .shared-balance-toolbar,
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) #sharedWork .form-card:not([data-shared-panel="balance"]),
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) #sharedWork .list-card {
    display: none !important;
  }

  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) #sharedWork,
  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) #sharedWork [data-shared-panel="balance"] {
    display: block !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
  }

  body:has(#sharedWork.active [data-shared-panel="balance"]:not(.hidden)) #sharedBalanceTable table {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 8px !important;
  }
}

