:root {
  --bg: #e4e9f0;
  --surface: #f2f5f9;
  --dashboard-bg: #eef2f7;
  --text: #1a2b4a;
  --muted: #5c6b82;
  --border: #d0d9e4;
  --accent: #1f4f9c;
  --dgc-logo-blue: #26a2db;
  --metric-down: #dc2626;
  --shadow: 0 12px 40px rgba(26, 43, 74, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select,
.file-field input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: var(--surface);
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  background: #e8eef8;
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 43, 74, 0.35);
  backdrop-filter: blur(2px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 36px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 220px;
}

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

.loading-text {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

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

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  max-width: min(520px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(26, 43, 74, 0.18);
}

.toast[hidden] {
  display: none;
}

.toast--success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.toast--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.dashboard {
  position: relative;
  background: var(--dashboard-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 16px;
  overflow: hidden;
}

.dashboard-logo {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 3;
  height: 80px;
  width: auto;
  max-width: 302px;
  object-fit: contain;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 0;
}

.dashboard-header--center {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 12px 180px 8px;
  min-height: auto;
}

.datetime-card--corner {
  position: absolute;
  top: 0;
  right: 0;
  color: #26a2db;
  width: max-content;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.datetime-card--corner .datetime-row + .datetime-row {
  margin-top: 4px;
}

.datetime-icon-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #173b78;
}

.dashboard-header--idp .dashboard-subtitle {
  margin-top: 8px;
}

.dashboard-header h1 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.15;
  color: #173b78;
}

.dashboard-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.datetime-card {
  min-width: 170px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
}

.datetime-card.datetime-card--corner {
  border: 1px solid #173b78;
  min-width: 0;
  max-width: 158px;
  padding: 9px 12px;
}

.datetime-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.datetime-row + .datetime-row {
  margin-top: 8px;
}

.columns {
  display: grid;
  grid-template-columns: repeat(10, minmax(88px, 1fr));
  gap: 0;
  min-height: 500px;
  border-top: 0;
  padding-bottom: 20px;
}

.dashboard-columns {
  margin-top: 22px;
}

.columns--idp {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  min-height: 530px;
}

.metric-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 0;
  border-right: 1px solid #b8c4d4;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-card__export {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.metric-card:hover .metric-card__export,
.metric-card:focus-within .metric-card__export {
  opacity: 1;
}

.metric-icon {
  width: auto;
  height: 50px;
  min-height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0px;
  margin-bottom: 7px;
}

.metric-icon--image {
  background: transparent;
  overflow: visible;
}

.metric-icon--image img {
  height: 50px;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.metric-icon--idp {
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.metric-icon--idp img {
  height: 50px;
  width: auto;
  max-width: 100%;
  border-radius: 0;
  object-fit: contain;
}

.metric-icon svg {
  width: 28px;
  height: 28px;
}

.metric-name {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  min-height: 26px;
  color: #173b78;
}

.metric-chart-label {
  margin: 10px 0 0;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  color: #173b78;
}

.metric-daily {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1.1;
}

.metric-daily__value {
  font-size: clamp(18px, 1.5vw, 28px);
  font-weight: 700;
}

.metric-daily__change {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
}

.metric-daily__change--up {
  color: var(--dgc-logo-blue);
}

.metric-daily__change--down {
  color: var(--metric-down);
}

.metric-divider {
  width: 72%;
  max-width: 88px;
  height: 0;
  margin: 10px 0 8px;
  border: 0;
  border-top: 1px solid #d4dce6;
}

.metric-total {
  margin: 0 0 24px;
  font-size: 14px;
  color: #173b78;
}

.metric-total span {
  font-weight: 700;
  color: #173b78;
}

.chart-area {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 18px 0;
}

.chart-bar {
  width: 58%;
  max-width: 72px;
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.35s ease;
}

.chart-body {
  position: relative;
  width: 100%;
  height: 240px;
}

.chart-baseline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: #173b78;
}

.metric-card .chart-wrap {
  position: relative;
  width: 100%;
  margin-top: auto;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.idp-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border: 1px solid #e8edf5;
  overflow: hidden;
  background: #fff;
}

.idp-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.idp-logo--square {
  border-radius: 16px;
}

.idp-logo__fallback {
  font-size: 18px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .columns {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .columns--idp {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .columns,
  .columns--idp {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

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

/* Headless / Telegram PNG export (?print=1) */
body.print-mode .toolbar,
body.print-mode .panel-toolbar,
body.print-mode .metric-card__export,
body.print-mode .loading-overlay,
body.print-mode .toast {
  display: none !important;
}

body.print-mode .app {
  max-width: none;
  padding: 12px;
}

body.print-mode .panel[hidden] {
  display: none !important;
}

body.print-mode .dashboard {
  box-shadow: none;
}

.dashboard-no-data-banner {
  margin: 24px auto;
  padding: 16px 24px;
  max-width: 520px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #173b78;
  background: #fff;
  border: 1px solid #d0d9e4;
  border-radius: 12px;
}
