:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel2: #f3f6fb;
  --panel3: #f9fbff;
  --line: #d8e0ef;
  --text: #1c2434;
  --muted: #5d6f91;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --chip: #eef3fb;
  --accent: #2563eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #eef3fb 0%, #f8fbff 100%);
  color: var(--text);
}

.wrap {
  max-width: 1550px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.2px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

input, select, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

input::placeholder {
  color: #7c90b0;
}

.theme-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  z-index: 100;
}

.theme-fab:hover {
  background: var(--panel2);
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #f7fbff 0%, #edf4fb 100%);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #8aa7d1;
}

.error-box {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.22);
  color: #991b1b;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel3) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.card h2 {
  margin: 0 0 14px 0;
  font-size: 18px;
}

.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-12 { grid-column: span 12; }

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.stat {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(37,99,235,0.04), rgba(37,99,235,0.015));
  border: 1px solid var(--line);
}

.stat .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.stat .value {
  font-size: 29px;
  font-weight: bold;
  line-height: 1;
}

.stat .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar-note {
  color: var(--muted);
  font-size: 12px;
}

.chart {
  display: flex;
  align-items: end;
  gap: 12px;
  height: 280px;
  padding-top: 10px;
}

.bar-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bar-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 30px;
}

.bar-outer {
  width: 100%;
  height: 215px;
  display: flex;
  align-items: end;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(37,99,235,0.04), rgba(37,99,235,0.01));
}

.bar {
  width: 100%;
  min-height: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 6px;
  color: #1c2434;
  font-weight: bold;
  transition: height 0.35s ease;
  background: linear-gradient(180deg, #d7dce5 0%, #9fb2cc 100%);
}

.mini-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mini-row {
  display: grid;
  grid-template-columns: 92px 1fr 42px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.mini-label {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-track {
  height: 12px;
  border-radius: 999px;
  background: #edf4fb;
  border: 1px solid var(--line);
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #67e8f9, #38bdf8);
}

.mini-value {
  text-align: right;
  color: var(--text);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 960px;
  background: rgba(255,255,255,0.88);
}

/* Column widths: Item | Status | People | Asset | Service | Languages | Req date | Deadline | Final del | Time | Rush | W/C | Cost */
table th:nth-child(1),  table td:nth-child(1)  { width: 160px; min-width: 160px; max-width: 160px; }
table th:nth-child(2),  table td:nth-child(2)  { width: 80px;  white-space: nowrap; }
table th:nth-child(3),  table td:nth-child(3)  { width: 90px; }
table th:nth-child(4),  table td:nth-child(4)  { width: 80px; }
table th:nth-child(5),  table td:nth-child(5)  { width: 80px; }
table th:nth-child(6),  table td:nth-child(6)  { min-width: 110px; }
table th:nth-child(7),  table td:nth-child(7)  { width: 72px; white-space: nowrap; }
table th:nth-child(8),  table td:nth-child(8)  { width: 72px; }
table th:nth-child(9),  table td:nth-child(9)  { width: 72px; }
table th:nth-child(10), table td:nth-child(10) { width: 60px; white-space: nowrap; }
table th:nth-child(11), table td:nth-child(11) { width: 44px; text-align: center; }
table th:nth-child(12), table td:nth-child(12) { width: 55px; text-align: right; white-space: nowrap; }
table th:nth-child(13), table td:nth-child(13) { width: 70px; text-align: right; white-space: nowrap; }

th, td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table td { vertical-align: top; }

/* Keep content wrapping nicely */
table td:first-child div,
table td:first-child .small {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Prevent long links stretching the table */
table td:first-child a {
  word-break: break-all;
}

th {
  color: var(--muted);
  font-weight: normal;
  position: sticky;
  top: 0;
  background: #eef3fb;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

tr:hover td {
  background: rgba(0,0,0,0.025);
}

.sort-indicator {
  margin-left: 6px;
  color: #4f78c7;
  font-size: 11px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--chip);
  border: 1px solid var(--line);
  margin: 2px 6px 2px 0;
}

.chip.done {
  background: rgba(22, 163, 74, 0.08);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.22);
}

.chip.not-done {
  background: rgba(0,0,0,0.02);
  color: var(--text);
}

.chip.default-chip {
  background: rgba(59,130,246,0.08);
  color: #1d4ed8;
  border-color: rgba(59,130,246,0.2);
}

.lang-cell {
  min-width: 140px;
  max-width: 220px;
}

.lang-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.lang-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.lang-progress {
  position: relative;
  width: 70px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b1322;
}

.lang-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #10b981);
}

.lang-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lang-preview .chip {
  margin: 0;
  padding: 4px 8px;
  font-size: 11px;
}

.lang-more {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  border: 1px dashed var(--line);
  background: rgba(0,0,0,0.015);
}

.status {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.done-status { background: rgba(22,163,74,0.12); color: #166534; }
.working-status { background: rgba(217,119,6,0.12); color: #92400e; }
.stuck-status { background: rgba(220,38,38,0.12); color: #991b1b; }
.default-status { background: rgba(37,99,235,0.10); color: #1d4ed8; }

.small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.pagination button {
  padding: 6px 16px;
  font-size: 13px;
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

#paginationInfo {
  font-size: 13px;
  color: var(--muted);
  min-width: 100px;
  text-align: center;
}

.pie-svg {
  display: block;
  width: 180px;
  height: 180px;
  /*margin: 8px auto;*/
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  float: left;
  padding-right: 25px;
}

.pie-legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.pie-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-legend-label {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pie-legend-count {
  color: var(--muted);
  white-space: nowrap;
}

.no-data {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

.donut-svg {
  display: block;
  width: 180px;
  height: 180px;
  margin: 8px auto;
}

.donut-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.donut-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.summary-box {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px;
  background: linear-gradient(180deg, rgba(37,99,235,0.03), rgba(37,99,235,0.015));
}

.summary-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-value {
  font-size: 24px;
  font-weight: bold;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 14px;
  border: 1px solid var(--line);
}

.checkbox-pill.true {
  background: rgba(217,119,6,0.14);
  color: #92400e;
  border-color: rgba(217,119,6,0.24);
}

.checkbox-pill.false {
  background: rgba(0,0,0,0.02);
  color: var(--muted);
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 247, 251, 0.78);
  backdrop-filter: blur(6px);
  z-index: 9999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(420px, calc(100vw - 40px));
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel3) 100%);
  box-shadow: 0 20px 50px rgba(15,23,42,0.08);
  text-align: center;
}

.loading-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 8px;
}

.loading-text {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.loading-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #edf4fb;
}

.loading-bar-fill {
  width: 35%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #67e8f9, #38bdf8);
  animation: loadingSlide 1.1s ease-in-out infinite;
}

@keyframes loadingSlide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(320%); }
}

@media (max-width: 1120px) {
  .span-5, .span-7, .span-12 {
    grid-column: span 12;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Expandable subitem rows */
.expand-toggle {
  cursor: pointer;
  color: var(--accent, #3b82f6);
  user-select: none;
  margin-top: 4px;
}
.expand-toggle:hover { text-decoration: underline; }

.subitem-detail-row.hidden { display: none; }

.subitem-detail-row td {
  padding: 0 !important;
  background: var(--panel-alt, var(--panel));
}

.subitem-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.subitem-table th,
.subitem-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.subitem-table thead th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-alt, var(--panel));
}
