:root {
  --bg-dark: #090d16;
  --bg-card: #131b2e;
  --bg-header: #131224;
  --bg-subnav: #0d1322;
  --bg-input: #1a243b;
  --bg-hover: #1e2a45;
  --border-subtle: rgba(255, 255, 255, 0.04);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-blue: #38bdf8;
  --accent-red: #f43f5e;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-blue);
  text-decoration: none;
}

header.app-header {
  background-color: var(--bg-header);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 1.15rem;
  color: #fff;
}

.header-logo img {
  height: 24px;
}

nav.main-nav {
  display: flex;
  gap: 1.5rem;
}

nav.main-nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

nav.main-nav a:hover, nav.main-nav a.active {
  color: #fff;
  border-bottom-color: var(--accent-gold);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 500;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: rgba(244, 63, 94, 0.1);
  color: var(--accent-red);
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background-color: var(--accent-red);
  color: #fff;
}

.subnav {
  background-color: var(--bg-subnav);
  padding: 0.5rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subnav-links {
  display: flex;
  gap: 1.5rem;
}

.subnav-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.25rem 0;
  transition: color 0.15s ease;
}

.subnav-links a:hover, .subnav-links a.active {
  color: var(--accent-gold);
}

.container {
  max-width: 1100px;
  margin: 1.75rem auto;
  padding: 0 1rem;
}

.card {
  background-color: var(--bg-card);
  border-radius: 10px;
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  overflow-x: auto;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none !important;
}

.btn-primary {
  background-color: var(--accent-gold);
  color: #0f172a;
}

.btn-primary:hover {
  background-color: #d97706;
  color: #0f172a;
}

.btn-green {
  background-color: var(--accent-green);
  color: #ffffff !important;
}

.btn-green:hover {
  background-color: #059669;
  color: #ffffff !important;
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main) !important;
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
  color: #ffffff !important;
}

.btn-danger {
  background-color: rgba(244, 63, 94, 0.15);
  color: var(--accent-red) !important;
}

.btn-danger:hover {
  background-color: var(--accent-red);
  color: #ffffff !important;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 5px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background-color: var(--bg-input);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--bg-hover);
  color: #ffffff !important;
}

.btn-icon-danger:hover {
  background-color: var(--accent-red);
  color: #ffffff !important;
}

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

.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background-color: var(--bg-input);
  border: none;
  border-radius: 6px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: background-color 0.15s ease;
}

.form-control:focus {
  background-color: var(--bg-hover);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.form-row {
  display: flex;
  gap: 1.25rem;
}

.form-row .form-group {
  flex: 1;
}

.segmented-control {
  display: inline-flex;
  background-color: var(--bg-input);
  border-radius: 6px;
  padding: 3px;
  gap: 3px;
}

.segment-option {
  position: relative;
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.segment-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-option span {
  display: block;
  padding: 0.45rem 1.5rem;
  border-radius: 5px;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.segment-option input:checked + span {
  background-color: var(--bg-card);
  color: #fff;
  font-weight: 600;
}

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

table.data-table td.col-wrap, table.data-table th.col-wrap {
  white-space: normal;
}

table.data-table th {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background-color: transparent;
}

table.data-table tr:hover td {
  background-color: var(--bg-hover);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-paid {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-unpaid {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-overdue {
  background-color: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.metrics-grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.metric-card {
  background-color: var(--bg-card);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  text-decoration: none !important;
  transition: all 0.15s ease;
}

.metric-card:hover {
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

.metric-card.active {
  background-color: #1a253e;
}

.metric-card.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.metric-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: var(--accent-green);
  background-color: rgba(16, 185, 129, 0.1);
  flex-shrink: 0;
}

.metric-icon.red-speaker {
  color: var(--accent-red);
  background-color: rgba(244, 63, 94, 0.1);
}

.metric-content {
  flex: 1;
}

.metric-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.metric-title-row .title {
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

.metric-title-row .total {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.metric-sub-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.invoice-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-input-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 280px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.search-input-wrapper .toolbar-search {
  padding-left: 2.35rem;
  padding-right: 2.35rem;
  height: 38px;
  border-radius: 6px;
}

.search-clear-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  text-decoration: none !important;
  transition: all 0.15s ease;
  border: none;
  cursor: pointer;
}

.search-clear-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff !important;
}

.toolbar-sort-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sort-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toolbar-select {
  height: 38px;
  padding: 0.25rem 0.6rem;
}

.sort-toggle-btns {
  display: inline-flex;
  background-color: var(--bg-input);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}

.btn-toggle {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 4px;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-toggle.active {
  background-color: var(--bg-card);
  color: #fff !important;
  font-weight: 600;
}

.invoice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.invoice-block h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
  padding-bottom: 0.25rem;
}

.invoice-block p {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.total-hero {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  margin: 1.75rem 0 1rem 0;
  letter-spacing: normal;
  word-spacing: 0.04em;
}

.payment-log {
  background-color: rgba(255, 255, 255, 0.015);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background-color: var(--bg-card);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.dashboard-chart-wrapper {
  display: flex;
  height: 250px;
  margin-top: 1rem;
  position: relative;
}

.chart-y-axis {
  position: relative;
  width: 100px;
  height: 200px;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
  user-select: none;
}

.chart-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chart-plot-area {
  position: relative;
  height: 200px;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

.chart-grid-lines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.grid-line {
  border-top: 1px stroke rgba(255, 255, 255, 0.04);
  width: 100%;
}

.chart-line-svg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.chart-bars-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.chart-col {
  flex: 1;
  height: 100%;
  position: relative;
  cursor: pointer;
  z-index: 4;
}

.chart-bar-fill {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44%;
  max-width: 36px;
  background-color: #10b981;
  border-radius: 4px 4px 0 0;
  transition: background-color 0.15s ease;
}

.chart-col:hover .chart-bar-fill {
  background-color: #34d399;
}

.chart-node {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background-color: #131b2e;
  border: 3px solid #f59e0b;
  border-radius: 50%;
  z-index: 5;
}

.chart-x-axis {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 40px;
  margin-top: 4px;
}

.x-label-item {
  flex: 1;
  text-align: center;
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.chart-hover-tooltip {
  position: absolute;
  display: none;
  background-color: #1a253e;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 100;
  pointer-events: none;
  min-width: 220px;
}

.tooltip-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.6rem;
}

.tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.tooltip-label-group {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 1.5rem;
}

.indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.indicator.green { background-color: #10b981; }
.indicator.red { background-color: #f43f5e; }
.indicator.yellow { background-color: #f59e0b; }

.tooltip-row .val {
  color: #fff;
  font-weight: 600;
  text-align: right;
}

.tooltip-divider {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.06);
  margin: 0.6rem 0;
}

@media (max-width: 768px) {
  header.app-header {
    height: auto;
    padding: 0.85rem 1rem;
    flex-direction: column;
    gap: 0.85rem;
    align-items: stretch;
  }

  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
  }

  nav.main-nav {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.25rem;
    gap: 1rem;

    -webkit-overflow-scrolling: touch;
  }

  .header-right {
    justify-content: space-between;
    width: 100%;
  }

  .subnav {
    padding: 0.5rem 1rem;
  }

  .subnav-links {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    gap: 1rem;

    -webkit-overflow-scrolling: touch;
  }

  .container {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  .card {
    padding: 1.1rem;
    border-radius: 8px;
  }

  .metrics-grid-container {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .metric-card {
    padding: 1rem;
  }

  .invoice-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .search-input-wrapper {
    width: 100%;
  }

  .toolbar-sort-group {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .toolbar-select {
    flex: 1;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .invoice-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal-box {
    padding: 1.25rem;
    margin: 0 1rem;
  }

  .total-hero {
    font-size: 1.35rem;
  }
}
