/* ============================================================
   Conga Insolvenz-Viewer — Main Stylesheet
   ============================================================ */

:root {
  --primary:        #1a1a2e;
  --primary-light:  #16213e;
  --accent:         #0f3460;
  --accent-hover:   #0a2747;
  --highlight:      #e94560;
  --text-sidebar:   #e0e0e0;
  --text-muted:     #9aa5b4;
  --text-content:   #333;
  --bg:             #f5f5f5;
  --card-bg:        #fff;
  --border:         #dde3ec;
  --shadow:         0 2px 8px rgba(0,0,0,.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);
  --sidebar-width:  250px;
  --radius:         6px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text-content);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 48px 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: #777;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #555;
  margin-bottom: 6px;
}

.form-group input,
.filter-bar input,
.filter-bar select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-content);
  background: #fff;
  transition: border-color .15s;
  outline: none;
}

.form-group input:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  color: #999;
  font-size: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

.btn-secondary {
  background: #e8ecf0;
  color: var(--text-content);
}
.btn-secondary:hover:not(:disabled) { background: #d8dde5; }

.btn-export {
  background: #27ae60;
  color: #fff;
}
.btn-export:hover:not(:disabled) { background: #219a52; }

.btn-logout {
  background: rgba(255,255,255,.1);
  color: var(--text-sidebar);
  border: 1px solid rgba(255,255,255,.2);
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.btn-logout:hover { background: rgba(255,255,255,.2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ============================================================
   ERROR / SUCCESS MESSAGES
   ============================================================ */
.error-message {
  color: #c0392b;
  font-size: 13px;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: #fdf2f2;
  border-left: 3px solid #e74c3c;
  border-radius: var(--radius);
}

.success-message {
  color: #1e8449;
  font-size: 13px;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: #f0faf3;
  border-left: 3px solid #27ae60;
  border-radius: var(--radius);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--primary);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--highlight);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-company {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-list {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav-link.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--highlight);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label { flex: 1; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-user-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ============================================================
   HAMBURGER (mobile)
   ============================================================ */
.hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  transition: all .2s;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 28px 28px 40px;
}

#content-area {
  max-width: 1400px;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.page-header .page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent);
  position: relative;
}

.kpi-card.accent-red   { border-left-color: #e74c3c; }
.kpi-card.accent-green { border-left-color: #27ae60; }
.kpi-card.accent-blue  { border-left-color: #2980b9; }
.kpi-card.accent-orange{ border-left-color: #e67e22; }
.kpi-card.accent-purple{ border-left-color: #8e44ad; }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #888;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.kpi-sub {
  font-size: 12px;
  color: #999;
  margin-top: 6px;
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.card-body {
  padding: 20px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.filter-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-bar .filter-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #777;
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 140px;
}

.filter-bar .filter-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table thead th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

table.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
table.data-table thead th.sortable:hover { background: var(--accent); }
table.data-table thead th .sort-icon { margin-left: 4px; opacity: .5; font-size: 10px; }

table.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef0f3;
  color: var(--text-content);
  vertical-align: middle;
}

table.data-table tbody tr:nth-child(even) td { background: #f9fafb; }
table.data-table tbody tr:hover td { background: #eef4fc; cursor: pointer; }

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

.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: #d5f5e3; color: #1e8449; }
.badge-red    { background: #fdecea; color: #c0392b; }
.badge-blue   { background: #d6eaf8; color: #1a5276; }
.badge-orange { background: #fef9e7; color: #b7770d; }
.badge-gray   { background: #eaecee; color: #555; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 4px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 6px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-content);
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.pagination button:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination button:disabled { opacity: .45; cursor: not-allowed; }

.pagination-info {
  font-size: 12px;
  color: #888;
  text-align: center;
  padding-bottom: 8px;
}

/* ============================================================
   MODAL / DETAIL OVERLAY
   ============================================================ */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.detail-card {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  width: 100%;
  max-width: 860px;
  position: relative;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.detail-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  transition: color .12s;
}
.detail-close:hover { color: #333; }

.detail-body {
  padding: 24px;
}

/* detail table inside modal */
.detail-body table.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-body table.detail-table th {
  text-align: left;
  color: #888;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 6px 8px 6px 0;
  width: 38%;
  vertical-align: top;
}

.detail-body table.detail-table td {
  padding: 6px 8px 6px 0;
  color: var(--text-content);
  vertical-align: top;
}

.detail-body table.detail-table tr { border-bottom: 1px solid #f0f0f0; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #dde3ec;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ============================================================
   UTILITY
   ============================================================ */
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #888; }
.text-bold { font-weight: 700; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.no-data {
  text-align: center;
  padding: 48px 20px;
  color: #aaa;
  font-size: 15px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ============================================================
   MODULE HEADER
   ============================================================ */
.module-header {
  margin-bottom: 24px;
}

.module-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.module-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   KPI CARD VARIANTS (dashboard)
   ============================================================ */
.kpi-card.kpi-accent {
  border-left-color: var(--highlight);
}

.kpi-card.kpi-accent .kpi-value {
  color: var(--highlight);
}

.kpi-card.kpi-wide {
  grid-column: span 2;
}

.kpi-card.kpi-wide .kpi-value {
  font-size: 18px;
}

/* ============================================================
   CHARTS SECTION (dashboard)
   ============================================================ */
.charts-section {
  margin-bottom: 20px;
}

.charts-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-wide {
  /* full width — single column */
}

.chart-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.chart-wrap {
  position: relative;
  padding: 16px;
  height: 280px;
}

.chart-wrap-tall {
  height: 320px;
}

/* ============================================================
   RESPONSIVE — DASHBOARD
   ============================================================ */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }

  #main-content {
    margin-left: 0;
    padding: 60px 14px 32px;
  }

  .hamburger { display: flex; }

  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  .page-header { flex-direction: column; }

  .filter-bar { flex-direction: column; }
  .filter-bar input,
  .filter-bar select { min-width: unset; width: 100%; }

  .detail-overlay { padding: 12px; }

  .charts-two-col {
    grid-template-columns: 1fr;
  }

  .kpi-card.kpi-wide {
    grid-column: span 1;
  }

  .chart-wrap { height: 240px; }
  .chart-wrap-tall { height: 260px; }
}

/* ============================================================
   SORTABLE TABLE HEADERS
   ============================================================ */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
