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

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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', Arial, sans-serif;
  font-size: 12px;
  min-height: 100vh;
}

/* ---- Top nav ---- */
nav {
  background: rgba(15,23,42,.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
nav::-webkit-scrollbar { display: none; }

.nav-back {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 12px; font-weight: 500;
  text-decoration: none;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  transition: all .15s;
  margin-right: 8px;
}
.nav-back:hover { background: var(--surface); color: var(--text); }

nav a.tab {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  transition: all .15s;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
nav a.tab:hover { color: var(--text); background: var(--surface); }
nav a.tab.active {
  color: #fff;
  background: #1d4ed8;
  border-color: #2563eb;
}

.nav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* ---- Page title bar ---- */
.page-title {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 12px;
}
.page-title-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.page-title-text { font-size: 15px; font-weight: 700; }
.page-title-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---- Table wrapper ---- */
.table-wrapper {
  overflow: auto;
  max-height: calc(100vh - 96px);
  background: var(--bg);
}

table { border-collapse: collapse; white-space: nowrap; }

th, td {
  border: 1px solid #2a3a50;
  padding: 4px 10px;
  text-align: center;
  vertical-align: middle;
  min-width: 82px;
  height: 28px;
  font-size: 11px;
}

/* ---- Sticky header rows ---- */
thead tr:nth-child(1) th { position: sticky; top: 0;    z-index: 3; }
thead tr:nth-child(2) th { position: sticky; top: 29px; z-index: 3; }
thead tr:nth-child(3) th { position: sticky; top: 58px; z-index: 3; }

/* ---- Sticky cols ---- */
.col-channel {
  position: sticky; left: 0; z-index: 2;
  min-width: 120px;
}
.col-metric {
  position: sticky; left: 120px; z-index: 2;
  min-width: 175px; text-align: left !important;
  padding-left: 12px !important;
}
thead .col-channel, thead .col-metric { z-index: 5; }

/* ---- Header rows styling ---- */
.row-date th {
  background: #0f2040;
  color: #93c5fd;
  font-weight: 700; font-size: 11px; height: 29px;
  letter-spacing: .3px;
}
.row-admin th {
  background: #162035;
  color: #cbd5e1;
  font-size: 11px; height: 29px;
}
.row-label th {
  background: #0d1f35;
  color: #64748b;
  font-size: 10px; height: 29px;
}

.header-corner {
  background: #0f2040 !important;
  color: #93c5fd !important;
  font-weight: 700; text-align: left !important;
  padding-left: 14px !important;
}

/* ---- Channel cell ---- */
.channel-cell {
  color: #fff !important;
  font-weight: 700; font-size: 11px;
}

/* ---- Metric rows ---- */
tr.metric-default td { background: #13202f; color: #cbd5e1; }
tr.metric-bronj   td { background: #2a1a14; color: #fed7aa; }
tr.metric-earned  td { background: #0f2218; color: #bbf7d0; }
tr.metric-konv    td { background: #1a102e; color: #c084fc; font-weight: 600; }

tr.metric-default .col-metric { background: #13202f; }
tr.metric-bronj   .col-metric { background: #2a1a14; }
tr.metric-earned  .col-metric { background: #0f2218; }

/* ---- Input cells ---- */
input[type="text"] {
  width: 100%; border: none; background: transparent;
  text-align: center; font-size: 11px; outline: none;
  color: inherit; cursor: pointer; font-family: inherit;
}
input[type="text"]:focus {
  background: rgba(59,130,246,.1);
  border-radius: 4px;
  color: #93c5fd;
}

/* ---- Separator rows ---- */
.sep-row td { height: 5px; background: #0a1520; padding: 0; border-color: #0a1520; }

/* ---- ИТОГО sticky column ---- */
.itogo-sticky {
  position: sticky; right: 0; z-index: 2;
  background: #1c1400 !important;
  color: #fcd34d !important;
  font-weight: 700;
  border-left: 2px solid #5a4000 !important;
}

/* ================================================================
   SVODNA styles
   ================================================================ */
.part-title {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid;
  padding: 10px 20px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  margin-top: 24px;
}
.part-title.p1 { border-top-color: #3b82f6; color: #93c5fd; }
.part-title.p2 { border-top-color: #a855f7; color: #d8b4fe; }

.sv-col-kompleks {
  position: sticky; left: 0; z-index: 2; min-width: 70px;
  background: inherit;
}
.sv-col-kanal {
  position: sticky; left: 70px; z-index: 2; min-width: 120px;
  background: inherit; text-align: left !important; padding-left: 10px !important;
}
.sv-col-metric {
  position: sticky; left: 190px; z-index: 2; min-width: 185px;
  background: inherit; text-align: left !important; padding-left: 10px !important;
}
thead .sv-col-kompleks, thead .sv-col-kanal, thead .sv-col-metric { z-index: 5; }

.konv-col-kompleks {
  position: sticky; left: 0; z-index: 2; min-width: 70px; background: inherit;
}
.konv-col-admin {
  position: sticky; left: 70px; z-index: 2; min-width: 130px;
  background: inherit; text-align: left !important; padding-left: 10px !important;
}
thead .konv-col-kompleks, thead .konv-col-admin { z-index: 5; }

#part1 thead tr:nth-child(1) th { position: sticky; top: 0;    z-index: 4; }
#part1 thead tr:nth-child(2) th { position: sticky; top: 30px; z-index: 4; }
#part2 thead tr:nth-child(1) th { position: sticky; top: 0;    z-index: 4; }
#part2 thead tr:nth-child(2) th { position: sticky; top: 30px; z-index: 4; }
#part2 thead tr:nth-child(3) th { position: sticky; top: 60px; z-index: 4; }

tr.sv-default td { background: #13202f; color: #cbd5e1; }
tr.sv-bronj   td { background: #2a1a14; color: #fed7aa; }
tr.sv-earned  td { background: #0f2218; color: #bbf7d0; }
tr.sv-default .sv-col-kompleks, tr.sv-default .sv-col-kanal, tr.sv-default .sv-col-metric { background: #13202f; }
tr.sv-bronj   .sv-col-kompleks, tr.sv-bronj   .sv-col-kanal, tr.sv-bronj   .sv-col-metric { background: #2a1a14; }
tr.sv-earned  .sv-col-kompleks, tr.sv-earned  .sv-col-kanal, tr.sv-earned  .sv-col-metric { background: #0f2218; }

.itogo-cell { background: #1c1400 !important; color: #fcd34d !important; font-weight: 700; }
.konv-percent { background: #1a102e !important; color: #d8b4fe !important; font-weight: 600; }
tr.konv-row td { background: #13202f; color: #cbd5e1; }

section { overflow-x: auto; }

/* ================================================================
   MOBILE RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
  /* Nav back button — shorter */
  .nav-back { padding: 5px 8px; font-size: 11px; }

  /* Page title */
  .page-title { padding: 8px 12px; }
  .page-title-text { font-size: 13px; }
  .page-title-sub  { font-size: 10px; }

  /* Sync bar — wrap on mobile */
  .sync-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .sync-hint { display: none; }
  #fbTokenInput { width: 100% !important; order: 10; }

  /* Table — smaller cells */
  td, th { min-width: 64px !important; padding: 3px 5px !important; font-size: 10px; }
  .col-channel { min-width: 80px !important; font-size: 10px; }
  .col-metric  { min-width: 120px !important; font-size: 10px; }

  /* Table wrapper — full height */
  .table-wrapper { max-height: calc(100vh - 140px); }
}
