:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1b2a3b;
  --sidebar-bg-2: #152232;
  --sidebar-text: #c5d0dc;
  --sidebar-active: #0d6efd;
  --content-bg: #f3f5f8;
  --card-border: #e6ebf1;
  --primary: #0d6efd;
  --success: #198754;
  --warning: #e6a23c;
  --danger: #dc3545;
  --muted: #6c757d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--content-bg);
  color: #1f2933;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.925rem;
}

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

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  overflow-y: auto;
  transition: transform .2s ease;
}

.sidebar-brand {
  display: flex;
  gap: .85rem;
  align-items: center;
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.6rem; color: #7eb6ff; }
.sidebar-brand strong { display: block; color: #fff; font-size: 1rem; }
.sidebar-brand small { color: #8ea0b5; }

.sidebar-nav { padding: .75rem 0 1.5rem; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.15rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: .9rem;
}
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-link.active {
  background: rgba(13,110,253,.18);
  color: #fff;
  border-left-color: var(--sidebar-active);
}
.sidebar-link i { width: 1.2rem; text-align: center; }

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  padding: .85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
}
.breadcrumb { font-size: .8rem; }
.breadcrumb a { text-decoration: none; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.global-search { min-width: 260px; max-width: 360px; }
.search-results {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .5rem;
  max-height: 420px;
  overflow: auto;
  z-index: 1050;
}
.search-group-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: .5rem .75rem .25rem;
}
.search-item {
  display: block;
  padding: .5rem .75rem;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid #f1f3f6;
}
.search-item:hover { background: #f8fafc; }
.search-item small { color: var(--muted); }

.app-content { padding: 1.25rem; }

.stat-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .65rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  height: 100%;
}
.stat-card .stat-label { color: var(--muted); font-size: .8rem; margin-bottom: .35rem; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-icon {
  width: 2.4rem; height: 2.4rem; border-radius: .55rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}
.stat-icon.blue { background: #e7f1ff; color: #0d6efd; }
.stat-icon.orange { background: #fff4e5; color: #e6a23c; }
.stat-icon.yellow { background: #fff8db; color: #b78103; }
.stat-icon.green { background: #e8f6ee; color: #198754; }
.stat-icon.red { background: #fdecee; color: #dc3545; }

.card-panel {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .65rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-panel .card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  padding: .85rem 1rem;
  font-weight: 600;
}
.card-panel .card-body { padding: 1rem; }

.table-compact th, .table-compact td {
  padding: .55rem .65rem;
  vertical-align: middle;
  font-size: .875rem;
}
.table-compact thead th {
  background: #f8fafc;
  color: #52606d;
  font-weight: 600;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.badge-status-new { background: #e7f1ff; color: #0d6efd; }
.badge-status-review { background: #fff4e5; color: #b78103; }
.badge-status-approved { background: #e8f6ee; color: #198754; }
.badge-status-rejected { background: #fdecee; color: #dc3545; }
.badge-status-archived { background: #eef1f4; color: #6c757d; }
.badge-pay-unpaid { background: #fff4e5; color: #b78103; }
.badge-pay-partial { background: #e7f1ff; color: #0d6efd; }
.badge-pay-paid { background: #e8f6ee; color: #198754; }
.badge-pay-na { background: #eef1f4; color: #6c757d; }
.badge-soft {
  font-weight: 600;
  border-radius: .35rem;
  padding: .3em .55em;
  font-size: .75rem;
}

.filter-bar {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .65rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(13,110,253,.12), transparent 40%),
    linear-gradient(160deg, #f5f7fa 0%, #e8eef5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: .75rem;
  box-shadow: 0 10px 30px rgba(16,24,40,.08);
  padding: 2rem;
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: .25rem; }
.auth-logo { color: #0d6efd; font-size: 2rem; }

.dropzone {
  border: 2px dashed #c5d0dc;
  border-radius: .65rem;
  padding: 1.5rem;
  text-align: center;
  background: #fafbfc;
  transition: .15s ease;
}
.dropzone.dragover { border-color: #0d6efd; background: #e7f1ff; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1035;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .global-search { min-width: 160px; }
  .app-topbar { flex-wrap: wrap; }
}

@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-main { margin: 0; }
}
