/*
 * Zenhit — Modern, compact workspace layer
 * Keeps every existing screen compatible while improving speed, density
 * and visual hierarchy across lists, forms, dashboards and detail pages.
 */

:root {
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --primary-hover: #115e59;
  --primary-soft: rgba(15, 118, 110, .10);
  --primary-gradient: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
  --primary-glow: 0 8px 22px rgba(15, 118, 110, .18);
  --secondary: #0f766e;
  --accent: #d59b42;
  --accent-soft: rgba(213, 155, 66, .12);
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, .16);

  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #edf2f0;
  --border: #dce5e2;
  --border-light: #e9efed;
  --text: #172421;
  --text-secondary: #40514d;
  --text-muted: #71807c;
  --text-soft: #9aa7a3;

  --shadow-xs: 0 1px 2px rgba(20, 43, 38, .04);
  --shadow-sm: 0 2px 8px rgba(20, 43, 38, .055);
  --shadow: 0 8px 24px rgba(20, 43, 38, .07);
  --shadow-lg: 0 16px 42px rgba(20, 43, 38, .11);
  --shadow-xl: 0 24px 64px rgba(20, 43, 38, .15);

  --sb-bg1: #102a26;
  --sb-bg2: #183b35;
  --sidebar-w: 248px;
  --sidebar-collapsed-w: 68px;
  --header-h: 64px;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

[data-theme="dark"] {
  --bg: #0d1513;
  --surface: #14201d;
  --surface-2: #182824;
  --surface-3: #21332f;
  --border: #2b403b;
  --border-light: #223530;
  --text: #edf6f3;
  --text-secondary: #c4d3cf;
  --text-muted: #8fa19c;
  --text-soft: #61736e;
  --primary: #38b2a5;
  --primary-dark: #2aa397;
  --primary-hover: #5cc5ba;
  --primary-soft: rgba(56, 178, 165, .13);
  --primary-gradient: linear-gradient(135deg, #228d82 0%, #38b2a5 100%);
  --focus-ring: 0 0 0 3px rgba(56, 178, 165, .2);
  --sb-bg1: #081310;
  --sb-bg2: #10221e;
}

html,
body {
  font-size: 14px;
}

body {
  background:
    radial-gradient(circle at 88% -10%, rgba(15, 118, 110, .055), transparent 28rem),
    var(--bg);
}

body.modal-open {
  overflow: hidden;
}

/* Application frame */
.sidebar {
  padding: 12px 9px;
  background:
    radial-gradient(circle at 20% 0%, rgba(56, 178, 165, .13), transparent 18rem),
    linear-gradient(180deg, var(--sb-bg1), var(--sb-bg2));
  border-right-color: rgba(255,255,255,.055);
  box-shadow: 3px 0 18px rgba(13, 32, 28, .12);
}

.sidebar::before {
  display: none;
}

.brand {
  min-height: 52px;
  padding: 6px 9px 12px;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f2d28d, #c89137);
  color: #17332d;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.brand-logo:hover,
.nav-item:hover,
.nav-item:hover svg {
  transform: none;
}

.brand-name {
  font-size: 14px;
  letter-spacing: -.1px;
}

.brand-sub {
  color: rgba(255,255,255,.45);
}

.nav {
  gap: 1px;
  padding: 3px 0;
}

.nav-section {
  padding: 13px 11px 5px;
  color: rgba(255,255,255,.34);
  font-size: 9.5px;
  letter-spacing: 1.25px;
}

.nav-section::after {
  display: none;
}

.nav-section-content {
  gap: 1px;
}

.nav-item {
  min-height: 36px;
  padding: 8px 11px;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255,255,255,.66);
  font-size: 12.75px;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.055);
  box-shadow: none;
}

.nav-item.active {
  color: #fff;
  background: rgba(56, 178, 165, .16);
  border-color: rgba(91, 198, 187, .17);
  box-shadow: none;
}

.nav-item.active::before {
  left: -9px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #5cc5ba;
  box-shadow: none;
}

.nav-submenu {
  margin: 2px 0 4px 12px;
  padding-left: 8px;
}

.nav-submenu .nav-item {
  min-height: 31px;
  padding: 5px 10px;
  font-size: 12px;
}

.sidebar-footer {
  padding-top: 7px;
}

.header {
  height: var(--header-h);
  gap: 12px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 0 rgba(20,43,38,.02);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="dark"] .header {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-bottom-color: var(--border-light);
}

.header-title-block {
  min-width: 170px;
  gap: 1px;
}

.page-title {
  color: var(--text);
  background: none;
  -webkit-text-fill-color: currentColor;
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -.25px;
}

[data-theme="dark"] .page-title {
  color: var(--text);
  background: none;
  -webkit-text-fill-color: currentColor;
}

.breadcrumb {
  gap: 5px;
  font-size: 10.5px;
}

.search-box {
  max-width: 480px;
  margin-left: clamp(0px, 2vw, 24px);
}

.search-box input {
  height: 36px;
  padding-right: 66px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.search-box input:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

.search-box input:focus {
  box-shadow: var(--focus-ring);
}

.search-shortcut {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-bottom-color: color-mix(in srgb, var(--border) 65%, var(--text-muted));
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
  pointer-events: none;
}

.search-box:focus-within .search-shortcut {
  opacity: 0;
}

.header-actions {
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border-color: transparent;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.icon-btn:hover,
.avatar:hover {
  transform: none;
  box-shadow: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-light);
}

.icon-btn.quick-action,
.icon-btn.quick-action:hover {
  background: var(--primary);
  box-shadow: none;
}

.notification-btn {
  display: none;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #254f48;
  box-shadow: none;
}

/* Content density and hierarchy */
.content {
  padding: 20px clamp(16px, 2vw, 28px) 30px;
}

.content > * {
  animation: workspaceEnter .2s ease-out both;
}

@keyframes workspaceEnter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-head,
.page-header {
  margin-bottom: 16px;
}

.page-head-title,
.page-heading {
  font-size: 21px;
  letter-spacing: -.35px;
}

.page-head-desc {
  margin-top: 2px;
  font-size: 12.5px;
}

.card,
.stat-card,
.summary-card,
.report-card,
.report-category-card {
  border-color: var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.card:hover,
.stat-card:hover,
.summary-card:hover,
.report-card:hover,
.report-category-card:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  min-height: 48px;
  padding: 12px 16px;
}

.card-header h3 {
  font-size: 14px;
}

.card-pad,
.card-body {
  padding: 16px;
}

.section-gap {
  margin-top: 14px;
}

.stats-grid {
  gap: 10px;
}

.stat-card {
  min-height: 112px;
  padding: 15px;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.stat-value {
  margin-top: 4px;
  font-size: clamp(18px, 1.5vw, 23px);
  letter-spacing: -.45px;
}

.stat-label {
  font-size: 10.5px;
  letter-spacing: .35px;
}

.summary-strip {
  gap: 8px;
}

.summary-mini {
  min-height: 78px;
  padding: 12px 14px;
  border-radius: 9px;
  box-shadow: none;
}

.summary-mini .value {
  font-size: 17px;
}

.proj-hero {
  min-height: 132px;
  padding: 26px 28px;
  margin-bottom: 16px !important;
  border-radius: 8px;
  background: linear-gradient(105deg, rgba(20, 184, 166, .08) 0%, rgba(255, 255, 255, .96) 28%, var(--surface) 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
}

.proj-hero-top {
  min-height: 80px;
  align-items: center;
  gap: 28px;
}

.proj-hero-main {
  gap: 16px;
  min-width: 520px;
}

.proj-avatar {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  background: #0f8f82;
  box-shadow: 0 10px 24px rgba(15, 143, 130, .18);
}

.proj-avatar svg {
  width: 24px;
  height: 24px;
}

.proj-title h2 {
  font-size: 25px;
  letter-spacing: 0;
  color: var(--text);
}

.proj-title .badge {
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
}

.proj-meta {
  gap: 8px 15px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.proj-meta svg {
  width: 15px;
  height: 15px;
}

.proj-meta .proj-flag {
  padding: 1px 4px;
  border-radius: 0;
  background: rgba(14, 165, 233, .16);
}

.proj-hero-side {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.proj-hero-side > div {
  min-width: 0;
}

.proj-hero-side .btn {
  grid-column: 1 / -1;
  min-height: 40px;
  border-radius: 6px;
  background: #12897e;
  box-shadow: none;
  font-size: 14px;
  font-weight: 800;
}

.proj-gauge-head {
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

.proj-gauge-head strong {
  font-size: 19px;
  line-height: 1;
}

.proj-gauge-foot {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 700;
}

.proj-bar {
  height: 8px;
  border-radius: 999px;
  background: #d8e4e1;
}

.proj-bar i {
  border-radius: 999px;
  background: #12897e;
}

.proj-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px !important;
}

.proj-metric {
  min-height: 88px;
  padding: 20px 17px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(15, 23, 42, .045);
}

.proj-metric .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
}

.proj-metric .stat-icon svg {
  width: 21px;
  height: 21px;
}

.proj-metric .stat-label {
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 800;
}

.proj-metric .stat-value {
  margin-top: 5px;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
}

.proj-metric .tone-success {
  background: rgba(16, 185, 129, .22);
  color: #059669;
}

.proj-metric .tone-danger {
  background: rgba(239, 68, 68, .20);
  color: #dc2626;
}

.proj-metric .tone-warning {
  background: rgba(245, 158, 11, .24);
  color: #d97706;
}

@media (max-width: 1280px) {
  .proj-metrics {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 900px) {
  .proj-hero {
    padding: 20px;
  }

  .proj-hero-main {
    min-width: 0;
  }

  .proj-hero-side {
    width: 100%;
  }
}

.filter-panel,
.toolbar-row {
  padding: 10px;
  border-radius: 9px;
  background: var(--surface);
  border-color: var(--border-light);
}

/* High-speed forms */
.form-control {
  min-height: 38px;
  border-radius: 7px;
  border-color: var(--border);
  background: var(--surface);
  transition: border-color .13s ease, box-shadow .13s ease;
}

.form-control:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.form-group {
  gap: 5px;
}

.form-group label {
  font-size: 11.5px;
}

.form-section {
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 9px;
  background: var(--surface-2);
}

.form-section-grid {
  gap: 11px 12px;
}

.btn {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 7px;
  box-shadow: none;
  transition: background .13s ease, color .13s ease, border-color .13s ease;
}

.btn:hover {
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--primary);
  box-shadow: none;
}

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

/* Dense, readable accounting tables */
.table-wrap {
  min-height: 180px;
  overflow: auto;
}

table.data {
  font-size: 12.5px;
}

table.data th {
  height: 39px;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: .45px;
  border-bottom-color: var(--border);
}

table.data td {
  height: 43px;
  padding: 9px 12px;
  border-bottom-color: var(--border-light);
}

table.data tbody tr {
  transition: background .1s ease;
}

table.data tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 4.5%, var(--surface));
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

.badge,
.due-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10.5px;
}

.due-badge:hover {
  transform: none;
}

.project-finance-card {
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: none;
}

.project-finance-filters {
  margin-bottom: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.project-finance-filters .toolbar-row {
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.project-finance-filters .form-control {
  width: auto;
  min-width: 132px;
  min-height: 34px;
  height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 12px;
}

.project-finance-filters .search-control {
  width: min(260px, 100%);
  min-width: min(220px, 100%);
}

.project-finance-clear {
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.project-finance-table {
  min-height: 0;
}

.project-finance-table table.data {
  table-layout: fixed;
}

.project-finance-table table.data th {
  height: 36px;
  padding: 8px 14px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.project-finance-table table.data td {
  height: 50px;
  padding: 9px 14px;
  vertical-align: middle;
}

.project-finance-table table.data tbody tr:last-child td {
  border-bottom: 0;
}

.project-finance-table table.data tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.project-finance-table .finance-date {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}

.finance-expense-data th:nth-child(1) { width: 112px; }
.finance-expense-data th:nth-child(2) { width: 118px; }
.finance-expense-data th:nth-child(4) { width: 118px; }
.finance-expense-data th:nth-child(5) { width: 92px; }
.finance-expense-data th:nth-child(6) { width: 90px; }
.finance-expense-data th:nth-child(7) { width: 150px; }
.finance-expense-data th:nth-child(8) { width: 44px; }

.finance-income-data th:nth-child(1) { width: 112px; }
.finance-income-data th:nth-child(3) { width: 118px; }
.finance-income-data th:nth-child(4) { width: 92px; }
.finance-income-data th:nth-child(5) { width: 150px; }
.finance-income-data th:nth-child(6) { width: 44px; }

.finance-desc {
  max-width: 720px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-category,
.finance-payment {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.finance-source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 750;
  white-space: nowrap;
}

.finance-source-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.finance-source-cash { color: #0284c7; }
.finance-source-bank { color: #059669; }
.finance-source-cheque { color: #7c3aed; }
.finance-source-note { color: #d97706; }
.finance-source-company { color: #4f46e5; }
.finance-source-personnel { color: #db2777; }
.finance-source-project { color: var(--primary); }
.finance-source-source { color: var(--info); }

.finance-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 12px;
  font-weight: 750;
  max-width: 160px;
  text-decoration: none;
}

.finance-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-file svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.finance-empty {
  color: var(--text-soft);
  font-weight: 700;
}

.finance-amount-cell {
  text-align: right;
  white-space: nowrap;
}

.finance-amount {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0;
}

.finance-amount-in {
  color: var(--success);
}

.finance-amount-out {
  color: var(--danger);
}

.finance-action-cell {
  width: 44px;
  text-align: right;
}

[data-theme="dark"] .finance-source-cash { color: #7dd3fc; }
[data-theme="dark"] .finance-source-bank { color: #6ee7b7; }
[data-theme="dark"] .finance-source-cheque { color: #c4b5fd; }
[data-theme="dark"] .finance-source-note { color: #fcd34d; }
[data-theme="dark"] .finance-source-company { color: #a5b4fc; }
[data-theme="dark"] .finance-source-personnel { color: #f9a8d4; }
[data-theme="dark"] .finance-source-project { color: #6ee7b7; }

@media (max-width: 900px) {
  .project-finance-filters .form-control,
  .project-finance-filters .search-control {
    width: 100%;
  }

  .project-finance-table table.data {
    min-width: 860px;
  }

  .finance-desc {
    max-width: 280px;
  }
}

.pagination {
  gap: 4px;
}

.pagination button {
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
}

/* Dialogs feel faster and keep actions visible */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 3000;
}

.modal {
  position: relative;
  z-index: 3001;
  border-radius: 13px;
  border-color: var(--border);
  box-shadow: 0 24px 64px rgba(11, 30, 26, .22);
  animation: modalFastIn .16s ease-out;
}

@keyframes modalFastIn {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.swal2-container {
  z-index: 4000 !important;
}

.modal-header,
.modal-footer {
  padding: 13px 18px;
}

.modal-body {
  padding: 17px 18px;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface);
}

.chart-box {
  height: 260px;
}

.detail-hero {
  padding: 18px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 90% 10%, rgba(213,155,66,.18), transparent 18rem),
    linear-gradient(135deg, #153a34, #245149);
  box-shadow: var(--shadow-sm);
}

.detail-hero h1 {
  font-size: 24px;
}

/* Responsive flow */
@media (max-width: 1100px) {
  .header-title-block .breadcrumb {
    display: none;
  }

  .header-title-block {
    min-width: 130px;
  }

  .search-box {
    margin-left: 0;
  }
}

@media (max-width: 820px) {
  :root {
    --header-h: 58px;
  }

  .header {
    padding: 0 12px;
  }

  .header-title-block {
    min-width: 0;
  }

  .page-title {
    font-size: 15px;
  }

  .search-box {
    max-width: none;
  }

  .search-shortcut {
    display: none;
  }

  .search-box input {
    padding-right: 12px;
  }

  .content {
    padding: 14px 12px 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }
}

@media (max-width: 560px) {
  .header-title-block {
    display: none;
  }

  .header-actions {
    gap: 2px;
  }

  .header-actions .quick-action {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-head-title,
  .page-heading {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.card:has(.action-menu.open),
.table-wrap:has(.action-menu.open) {
  overflow: visible !important;
}

.row-actions,
table.data tr:has(.action-menu.open),
table.data td:has(.action-menu.open) {
  position: relative;
  overflow: visible;
  z-index: 120;
}

.row-actions:has(.action-menu.open),
table.data tr:has(.action-menu.open),
table.data td:has(.action-menu.open) {
  z-index: 90;
}

.action-menu.open .action-menu-panel {
  z-index: 90;
}
