@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap');

/* --- Base --- */
body {
  font-family: "Manrope", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: #f3f4f6; /* light neutral */
  color: #1f2937;      /* slate-800 */
  margin: 0;
  padding: 2rem;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2rem, 3vw, 2.7rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}

#header {
  text-align: center;
  margin-bottom: 2rem;
  width: 100%;
}

#header p {
  font-size: 1.15rem;
  font-weight: 600;
  color: #4b5563;
}

/* --- Grid stays untouched --- */
.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Responsive grid rules unchanged --- */
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }
@media (min-width: 481px) and (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 901px) {
  .grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Cards: modern clean style --- */
.card {
  background: #ffffff;
  padding: 1.1rem 1.5rem;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  box-sizing: border-box;
  min-width: 320px;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.card:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  transform: translateY(-2px);
}

/* No layout change */
@media (max-width: 800px) {
  .card { flex: 1 1 100%; }
}

.card.med {
  grid-column: span 2;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

td:first-child {
  color: #6b7280; /* slate-500 */
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e5e7eb; /* neutral border */
}

table tr:nth-child(even) {
  background: #f9fafb; /* subtle zebra */
}

/* --- Charts --- */
canvas {
  width: 100% !important;
  max-width: 1000px;
  height: 360px !important;
  display: block;
  margin: 0 auto;
}

.chart-container {
  position: relative;
}

.chart-host {
  position: relative;
  min-height: 360px;
}

.chart-placeholder {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6b7280;
  padding: 2rem;
}

.enlarge-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #e5e7eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 1rem;
  transition: background 0.15s;
  z-index: 5;
}

.enlarge-btn:hover {
  background: #d1d5db;
}

/* --- Fullscreen chart mode --- */
.fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100vh !important;
  background: #ffffff;
  z-index: 9999;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.fullscreen h2 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.fullscreen canvas {
  flex: 1;
  width: 100% !important;
  height: 80vh !important;
  max-height: 90% !important;
  max-width: 90% !important;
}

.fullscreen .chart-host,
.fullscreen .chart-placeholder {
  flex: 1;
  min-height: 80vh;
}

.fullscreen .enlarge-btn {
  top: 1rem;
  right: 1rem;
  font-size: 1.2rem;
  background: #e5e7eb;
}

/* --- Drag & Drop feedback --- */
.dragghost {
  opacity: 0.25 !important;
  border: 2px dashed #9ca3af !important;
  background: #e5e7eb !important;
  border-radius: 12px;
}

.dragging {
  opacity: 0.4;
  transform: scale(1.02);
}

.chosen {
  outline: 2px solid #3b82f6;
  outline-offset: 3px;
}

/* --- Small stat cards --- */
.card.small,
.card.sysmetrics {
  padding: 1.15rem 1.1rem 1.2rem;
  border-radius: 12px;
  background: #111827;  /* slate-900 */
  color: #f9fafb;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.card.small > div {
  line-height: 1.25;
  font-size: clamp(2.1rem, 3.6vw, 3rem);
  font-weight: 600;
  margin-top: 0.7rem;
}

#active {
  color: #10b981; /* green-500 */
  margin: 0.4rem 0 0.1rem;
}

.card h2,
.card h3 {
  text-align: center;
  font-size: clamp(1.55rem, 1.85vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0.2rem 0 0.35rem;
}

/* --- Sys metrics rows --- */
.card.sysmetrics h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: #f9fafb;
}

.card.sysmetrics .row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
}

.card.sysmetrics .label {
  opacity: 0.75;
}

.card.sysmetrics .value {
  font-weight: 600;
  text-align: right;
  min-width: 80px;
  display: inline-block;
}

/* Center everything inside small stat cards */
.card.small,
.card.small > div {
  text-align: center;
}

/* Center titles inside fullscreen charts */
.fullscreen h2 {
  text-align: center;
}
.alt-text {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  margin-top: 0.35rem;
  display: block;
  width: 100%;
}

.notice {
  max-width: 1100px;
  margin: 0 auto 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  font-weight: 700;
}

.notice-success {
  background: #dcfce7;
  color: #166534;
}

.notice-error {
  background: #fee2e2;
  color: #991b1b;
}

.auth-shell,
.dashboard-shell {
  max-width: 1400px;
  margin: 0 auto;
}

.auth-shell {
  padding: 2rem 1rem;
}

.auth-intro {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 2rem;
}

.auth-intro p,
.tracker-card p {
  color: #4b5563;
  font-size: 1rem;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.auth-card,
.auth-card-wide,
.tracker-card {
  min-width: 0;
}

.auth-card-wide {
  max-width: 560px;
  margin: 0 auto;
}

.stack-form {
  display: grid;
  gap: 0.75rem;
}

.stack-form label {
  font-weight: 700;
}

.stack-form input,
.inline-form input,
.inline-form select,
.stack-form button,
.inline-form button {
  font: inherit;
}

.stack-form input,
.inline-form input,
.inline-form select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-sizing: border-box;
  background: #fff;
}

.stack-form input:focus,
.inline-form input:focus,
.inline-form select:focus {
  outline: 2px solid rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #111827;
  color: #f9fafb;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  opacity: 0.95;
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
}

.inline-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form-compact {
  justify-content: flex-end;
}

.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 0 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions .inline-form {
  background: #fff;
  padding: 0.8rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.toolbar-actions input,
.toolbar-actions select {
  min-width: 210px;
}

.tracker-panel {
  padding: 0 1.5rem;
  margin-bottom: 1.5rem;
}

.tracker-card pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tracker-meta {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  font-weight: 700;
}

.tracker-meta code {
  background: #e5e7eb;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

@media (max-width: 900px) {
  body {
    padding: 1rem;
  }

  .dashboard-toolbar,
  .tracker-panel,
  .grid {
    padding-left: 0;
    padding-right: 0;
  }

  .toolbar-actions .inline-form,
  .inline-form {
    width: 100%;
  }

  .toolbar-actions input,
  .toolbar-actions select {
    min-width: 0;
    flex: 1 1 100%;
  }
}

#webVsApp {
  margin-top: 0.35rem;
}

#webVsApp .kpi-total {
  font-size: clamp(2.3rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 0.55rem;
}

#webVsApp .kpi-breakdown {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 0 auto;
  max-width: 260px;
}

#webVsApp .kpi-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.9rem;
  margin-top: 0.2rem;
}

#webVsApp .kpi-label {
  color: #cbd5e1;
  font-weight: 700;
}

#webVsApp .kpi-value {
  color: #f9fafb;
  font-weight: 700;
}

#webVsApp .kpi-pct {
  color: #94a3b8;
  font-weight: 700;
}
