/* ── HGK DESIGN TOKENS ────────────────────────────────────────────────────── */
:root {
  --red:        #E30613;
  --dark-red:   #961423;
  --yellow:     #FDC300;
  --blue:       #009DCC;
  --green:      #00975F;
  --grey:       #54616C;
  --light-grey: #B3B3B3;
  --bg:         #E8EAED;
  --card:       #FFFFFF;
  --text:       #222222;
  --muted:      #6D7780;
  --border:     #DDDEE1;

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── HEADER ───────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0;
  height: 72px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  background: #fff;
  color: var(--red);
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: -.02em;
  width: 120px;
  height: 100%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
}

.header-sub {
  font-size: .75rem;
  color: rgba(255,255,255,.75);
  margin-top: 2px;
}

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

.header-date {
  font-size: .78rem;
  color: rgba(255,255,255,.8);
}

.header-badge {
  background: var(--yellow);
  color: #1a1a1a;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 9px;
  border-radius: 3px;
}

.install-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 4px;
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.install-btn:hover { background: rgba(255,255,255,.25); }

/* ── NAVIGATION ───────────────────────────────────────────────────────────── */
.app-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  height: 46px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--grey);
  font-size: .88rem;
  font-weight: 600;
  padding: 0 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
  flex-shrink: 0;
  min-height: 44px;
}
.nav-btn:hover { background: #fff5f5; color: var(--text); }
.nav-btn.active {
  color: var(--red);
  border-bottom-color: var(--red);
  background: #fff8f8;
}

/* ── MAIN CONTENT ─────────────────────────────────────────────────────────── */
.app-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 20px 32px;
}

/* ── SPLASH ───────────────────────────────────────────────────────────────── */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
}
.splash-logo {
  width: 80px; height: 80px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  font-size: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}
.splash-text { color: var(--muted); font-size: .9rem; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.95); opacity: .7; }
}

/* ── STATUS BAR ───────────────────────────────────────────────────────────── */
.app-statusbar {
  background: var(--dark-red);
  color: rgba(255,255,255,.9);
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 26px;
  flex-shrink: 0;
}

/* ── SECTION CARD ─────────────────────────────────────────────────────────── */
.section-card {
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  margin-bottom: 16px;
}
.section-card-header {
  background: var(--dark-red);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 9px 14px;
}
.section-card-header.blue { background: var(--blue); }
.section-card-header.green { background: var(--green); }
.section-card-header.grey { background: var(--grey); }
.section-card-body { padding: 14px; }

/* ── KPI CARD ─────────────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: default;
  transition: box-shadow .15s;
}
.kpi-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.kpi-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--red);
}
.kpi-sub { font-size: .78rem; color: #8C949B; }

/* ── GRID LAYOUTS ─────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}
.cards-list { display: flex; flex-direction: column; gap: 12px; }

/* ── WIDGET CARD ──────────────────────────────────────────────────────────── */
.widget-card {
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.widget-header {
  background: var(--dark-red);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  padding: 9px 14px;
}
.widget-body { padding: 14px; min-height: 60px; }
.widget-body canvas { height: 240px !important; }

/* ── TOOLBAR ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar-input {
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 12px;
  flex: 1;
  min-width: 200px;
  color: var(--text);
}
.toolbar-input:focus { outline: 2px solid var(--red); border-color: transparent; }

/* ── BUTTONS ──────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  min-height: 36px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn:hover { filter: brightness(.9); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-primary   { background: var(--red);      color: #fff; }
.btn-secondary { background: var(--grey);     color: #fff; }
.btn-ghost     { background: transparent; color: var(--grey); border: 1px solid var(--border); }
.btn-danger    { background: var(--dark-red); color: #fff; }
.btn-blue      { background: var(--blue);     color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .76rem; }
.nav-btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-blue {
  min-width: 44px;
}

/* ── TABLES ───────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.data-table th {
  background: #f5f5f5;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
}
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eee;
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

/* ── FORM ELEMENTS ────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-row label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-input, .form-select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: .87rem;
  color: var(--text);
  background: #fff;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  outline: 2px solid var(--red);
  border-color: transparent;
}
.col-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .8rem;
  padding: 3px 8px;
  background: #f5f5f5;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.check-label input { accent-color: var(--red); }

/* ── IMPORT DROPZONE ──────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--light-grey);
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  background: #fafafa;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--red);
  background: #fff5f5;
}
.dropzone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.dropzone p { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.progress-bar-wrap {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  margin: 14px 0 4px;
}
.progress-bar {
  height: 100%;
  background: var(--red);
  border-radius: 3px;
  transition: width .3s ease;
}
.import-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
  font-size: .86rem;
  line-height: 1.35;
  margin-top: 12px;
  max-width: 680px;
}
.import-option input {
  accent-color: var(--red);
  margin-top: 2px;
  flex: 0 0 auto;
}

/* ── WIDGET BUILDER ───────────────────────────────────────────────────────── */
.widget-builder-list { display: flex; flex-direction: column; gap: 8px; }
.widget-builder-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wbi-info { flex: 1; min-width: 0; }
.wbi-info strong { font-size: .9rem; display: block; }
.wbi-meta { font-size: .76rem; color: var(--muted); }
.wbi-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── MODAL ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  border-radius: 10px;
  width: min(560px, 100%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: slideUp .2s;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  background: var(--dark-red);
  color: #fff;
  padding: 14px 18px;
  font-weight: 700;
  font-size: .95rem;
  border-radius: 10px 10px 0 0;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-radius: 0 0 10px 10px;
}

/* ── TOAST NOTIFICATIONS ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 40px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  padding: 11px 16px;
  font-size: .83rem;
  font-weight: 600;
  max-width: 340px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  pointer-events: auto;
  animation: slideLeft .25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--dark-red); }
.toast.info    { background: var(--blue); }
@keyframes slideLeft { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── BADGES ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: 3px;
  padding: 2px 7px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-green { background: #d4f3e3; color: #005f3a; }
.badge-red   { background: #fddde0; color: var(--dark-red); }

/* ── EMPTY STATE ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 2.4rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; font-size: .92rem; }

/* ── LIST ITEM ────────────────────────────────────────────────────────────── */
.list-item { cursor: default; }

/* ── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--light-grey); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey); }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .header-sub { display: none; }
  .header-title { font-size: .9rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .widget-grid { grid-template-columns: 1fr; }
  .modal { width: 100%; margin: 0; border-radius: 10px 10px 0 0; align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
