/* ============================================
   Komforease Dashboard — Brand Theme
   Palette from komforease.com
   ============================================ */

:root {
  --bg: #f4f0e7;
  --bg-card: #ffffff;
  --bg-section: #ece8df;
  --border: #d9d3c7;
  --text: #212529;
  --text-dim: #645a52;
  --text-muted: #8c8078;
  --accent: #645a52;
  --accent-light: rgba(100, 90, 82, 0.08);
  --orange: #f2984b;
  --orange-light: rgba(242, 152, 75, 0.10);
  --green: #5a9a6e;
  --red: #c9544d;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* ---- Header ---- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.logo-sub {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 16px;
  margin-left: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.date-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.date-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.date-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.date-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.date-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}

.date-input.hidden {
  display: none;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  display: inline-block;
}

.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-grey { background: var(--text-muted); }

/* ---- Sections ---- */
.section {
  margin-bottom: 36px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

/* ---- KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(100, 90, 82, 0.06);
}

.kpi-card.accent {
  border-color: var(--orange);
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--orange-light) 100%);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.kpi-unit {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-top: 4px;
}

/* ---- Charts ---- */
.chart-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.chart-row:has(.chart-small) {
  grid-template-columns: 2fr 1fr;
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  height: 240px;
  position: relative;
  box-shadow: 0 1px 3px rgba(100, 90, 82, 0.06);
}

/* ---- Sync Bar ---- */
.sync-bar {
  margin-top: 40px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 1px 3px rgba(100, 90, 82, 0.06);
}

.sync-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.sync-items {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.sync-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.sync-time {
  color: var(--text-muted);
  font-size: 11px;
}

/* ---- Loading State ---- */
.kpi-value.loading {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-card) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent;
  min-width: 60px;
  min-height: 28px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Auth Gate ---- */
.auth-gate {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.auth-box {
  text-align: center;
  padding: 48px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(100, 90, 82, 0.10);
  min-width: 320px;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.auth-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.auth-btn:hover {
  opacity: 0.9;
}

.auth-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .shell { padding: 16px 12px 32px; }
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row, .chart-row:has(.chart-small) { grid-template-columns: 1fr; }
  .sync-bar { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 480px) {
  .kpi-value { font-size: 22px; }
  .date-controls { flex-wrap: wrap; }
}
