:root {
  --light-cyan: #bdeff2;
  --teal: #2f9fb3;
  --dark-navy: #102a43;
  --light-blue: #d9f0ff;
  --medium-blue: #4fa3d1;
  --surface: #f5fbfe;
  --text: #17324d;
  --muted: #60758a;
}

body {
  background: var(--surface);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--light-blue), #fff 58%, var(--light-cyan));
}

.login-panel {
  width: min(430px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--light-cyan);
  border-radius: 12px;
  box-shadow: 0 22px 60px rgba(16, 42, 67, .14);
  padding: 34px;
}

.login-brand {
  color: var(--dark-navy);
  font-weight: 800;
  font-size: 1.65rem;
}

.login-logo,
.dashboard-logo {
  max-width: 260px;
  height: auto;
  object-fit: contain;
  margin-bottom: 12px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 288px;
  background: var(--dark-navy);
  color: #fff;
  transition: width .2s ease;
  overflow-x: hidden;
  flex: 0 0 auto;
  box-shadow: 8px 0 28px rgba(16, 42, 67, .12);
}

.sidebar.collapsed {
  width: 78px;
}

.sidebar-head {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(189, 239, 242, .16);
}

.user-toggle {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 1.25rem;
  flex: 0 0 auto;
}

.sidebar-brand {
  display: grid;
  line-height: 1.1;
}

.sidebar-logo {
  max-width: 185px;
  max-height: 42px;
  object-fit: contain;
  transition: opacity .2s ease;
}

.sidebar.collapsed .sidebar-logo {
  display: none;
}

.sidebar-brand small {
  color: var(--light-cyan);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .parent-link strong,
.sidebar.collapsed .child-link span,
.sidebar.collapsed .parent-chevron {
  display: none;
}

.sidebar-nav {
  padding: 12px 10px 24px;
}

.nav-section {
  margin-bottom: 6px;
}

.parent-link,
.child-link {
  width: 100%;
  border: 0;
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.parent-link {
  background: transparent;
  padding: 11px 12px;
  font-weight: 800;
}

.parent-link .nav-icon,
.child-link > i {
  width: 22px;
  min-width: 22px;
  text-align: center;
  font-size: 1.05rem;
}

.parent-link:hover,
.child-link:hover,
.child-link.active {
  background: rgba(47, 159, 179, .9);
  color: #fff;
}

.parent-chevron {
  margin-left: auto;
  transition: transform .2s ease;
}

.parent-link:not(.collapsed) .parent-chevron {
  transform: rotate(180deg);
}

.child-link {
  padding: 9px 12px 9px 42px;
  color: rgba(255,255,255,.88);
  font-size: .94rem;
}

.sidebar.collapsed .child-link {
  padding-left: 14px;
  justify-content: center;
}

.sidebar.collapsed .parent-link {
  justify-content: center;
}

.menu-icon-preview {
  min-width: 46px;
  justify-content: center;
}

.main-area {
  flex: 1;
  min-width: 0;
}

.topbar {
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--light-cyan);
}

.brand {
  font-weight: 800;
  color: var(--dark-navy);
}

.topbar small,
.page-head p {
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.top-brand img {
  width: 118px;
  max-height: 36px;
  object-fit: contain;
}

.user-pill {
  background: var(--light-blue);
  border-radius: 999px;
  padding: 7px 13px;
  color: var(--dark-navy);
}

.content {
  padding: 28px;
}

.breadcrumb-row {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: .92rem;
}

.breadcrumb-row a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 700;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  color: var(--dark-navy);
  font-size: 1.75rem;
  font-weight: 800;
}

.erp-card,
.panel {
  background: #fff;
  border: 1px solid rgba(189, 239, 242, .9);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 12px 34px rgba(16, 42, 67, .07);
}

.erp-card h5 {
  color: var(--dark-navy);
  font-weight: 800;
}

.toolbar-row {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.table-shell {
  border: 1px solid var(--light-cyan);
  border-radius: 10px;
  overflow: hidden;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  background: var(--light-blue);
  color: var(--dark-navy);
  font-weight: 800;
  white-space: nowrap;
}

.table tbody td {
  white-space: nowrap;
  vertical-align: middle;
}

.action-col {
  width: 110px;
}

.modal-xl {
  --bs-modal-width: min(1120px, calc(100vw - 40px));
}

.modal-dialog-scrollable .modal-content {
  max-height: calc(100vh - 48px);
}

.modal-content {
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(16, 42, 67, .2);
}

.crud-modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.crud-modal form {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.crud-modal-header {
  border-bottom: 1px solid var(--light-cyan);
  background: var(--surface);
  padding: 18px 22px;
}

.modal-title {
  color: var(--dark-navy);
  font-weight: 800;
}

.crud-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  background: #fff;
  padding: 22px 22px 42px;
  overflow-y: auto;
}

.crud-modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 24px;
  align-items: start;
}

.crud-modal-grid.without-image {
  grid-template-columns: 1fr;
}

.crud-fields-panel {
  min-width: 0;
}

.form-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px 18px;
  align-items: start;
}

.field-cell {
  min-width: 0;
}

.field-cell.span-2 {
  grid-column: 1 / -1;
}

.crud-fields-panel .form-label {
  color: var(--dark-navy);
  font-weight: 700;
  margin-bottom: 6px;
}

.required-star {
  color: #dc3545;
  font-weight: 900;
}

.crud-fields-panel .form-control,
.crud-fields-panel .form-select,
.select2-container--bootstrap-5 .select2-selection {
  min-height: 42px;
  border-radius: 8px;
  border-color: #c8e7f1;
}

.form-switch-card {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 12px 10px 44px;
  background: #f7fcff;
  border: 1px solid #d5edf5;
  border-radius: 10px;
  margin-top: 24px;
}

.crud-image-panel {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 14px 13px;
  background: #f7fcff;
  border: 1px solid #d5edf5;
  border-radius: 12px;
}

.image-uploader-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.image-clear {
  color: var(--teal);
  text-decoration: none;
  padding: 0;
}

.image-dropzone {
  width: 220px;
  height: 160px;
  max-width: 100%;
  position: relative;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 2px dashed #87d4df;
  border-radius: 12px;
  background: rgba(217, 240, 255, .48);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.image-dropzone:hover,
.image-dropzone.drag-over {
  border-color: var(--teal);
  background: rgba(189, 239, 242, .62);
  box-shadow: 0 10px 24px rgba(47, 159, 179, .14);
}

.image-dropzone:disabled {
  cursor: not-allowed;
  opacity: .82;
}

.image-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.image-placeholder {
  display: grid;
  gap: 4px;
  justify-items: center;
  pointer-events: none;
}

.image-placeholder i {
  font-size: 2rem;
  color: var(--teal);
}

.image-placeholder strong {
  color: var(--dark-navy);
  font-size: .92rem;
}

.image-placeholder small {
  color: var(--muted);
}

.preview-status {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 8px;
  place-content: center;
  background: rgba(255, 255, 255, .86);
  color: var(--dark-navy);
  font-size: .9rem;
  z-index: 2;
}

.preview-status {
  align-items: center;
}

.preview-error {
  color: #b42318;
  font-size: .85rem;
  margin-top: 8px;
}

.crud-modal-footer {
  z-index: 4;
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  background: #fff;
  border-top: 1px solid var(--light-cyan);
  box-shadow: 0 -10px 22px rgba(16, 42, 67, .05);
}

.crud-modal-footer .btn {
  min-width: 104px;
  font-weight: 700;
}

.list-thumb {
  width: 56px;
  height: 36px;
  object-fit: contain;
  border: 1px solid var(--light-cyan);
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}

.btn-primary {
  --bs-btn-bg: var(--teal);
  --bs-btn-border-color: var(--teal);
  --bs-btn-hover-bg: var(--medium-blue);
  --bs-btn-hover-border-color: var(--medium-blue);
}

.btn-outline-primary {
  --bs-btn-color: var(--teal);
  --bs-btn-border-color: var(--teal);
  --bs-btn-hover-bg: var(--teal);
  --bs-btn-hover-border-color: var(--teal);
}

.coa-panel {
  min-height: 520px;
}

.coa-tree {
  min-height: 430px;
  border: 1px solid var(--light-cyan);
  border-radius: 12px;
  background: #fbfeff;
  padding: 12px;
  overflow: auto;
}

.coa-node-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.coa-node-row {
  display: grid;
  grid-template-columns: 28px 24px minmax(86px, 110px) minmax(220px, 1fr) auto auto auto 38px;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  margin: 3px 0;
  padding: 6px 8px 6px calc(8px + (var(--level) * 24px));
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--dark-navy);
}

.coa-node-row:hover {
  background: var(--light-blue);
  border-color: var(--light-cyan);
}

.coa-node.inactive > .coa-node-row {
  opacity: .58;
  filter: grayscale(.15);
}

.coa-node.collapsed > .coa-children {
  display: none;
}

.coa-node.collapsed > .coa-node-row .coa-expander i {
  transform: rotate(-90deg);
}

.coa-expander {
  border: 0;
  background: transparent;
  color: var(--teal);
}

.coa-node-icon {
  color: var(--teal);
  font-size: 1.12rem;
}

.coa-code {
  font-weight: 800;
  color: var(--dark-navy);
}

.coa-name {
  font-weight: 700;
}

.coa-badge {
  border: 1px solid #c8e7f1;
  background: #fff;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: .78rem;
  white-space: nowrap;
}

.coa-badge.postable {
  color: #0f766e;
  border-color: #99f6e4;
  background: #ecfeff;
}

.coa-badge.group {
  color: #1d4ed8;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.coa-badge.active {
  color: #166534;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.coa-badge.inactive {
  color: #64748b;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.coa-context-menu {
  position: absolute;
  z-index: 2000;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--light-cyan);
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(16, 42, 67, .18);
  padding: 6px;
}

.coa-context-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--dark-navy);
  text-align: left;
}

.coa-context-menu button:hover {
  background: var(--light-blue);
}

.coa-empty {
  min-height: 340px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #9bdce5;
  border-radius: 12px;
}

.form-control:focus,
.form-select:focus,
.select2-container--bootstrap-5 .select2-selection:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 .2rem rgba(47, 159, 179, .16);
}

div.dt-container .dt-search input,
div.dt-container .dt-length select {
  border-radius: 8px;
  border-color: var(--light-cyan);
}

@media (max-width: 900px) {
  .sidebar {
    width: 78px;
  }
  .sidebar .sidebar-brand,
  .sidebar .parent-link strong,
  .sidebar .child-link span,
  .sidebar .parent-chevron {
    display: none;
  }
  .content {
    padding: 18px;
  }
  .page-head {
    flex-direction: column;
  }
  .toolbar-row {
    grid-template-columns: 1fr;
  }
  .crud-modal-grid {
    grid-template-columns: 1fr;
  }
  .form-field-grid {
    grid-template-columns: 1fr;
  }
  .field-cell.span-2 {
    grid-column: auto;
  }
  .crud-image-panel {
    position: static;
    order: -1;
  }
  .image-dropzone {
    width: 100%;
  }
}
