:root {
  --navy: #002b5c;
  --navy-700: #013b7d;
  --bg: #f0f2f5;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #333333;
  --muted: #6a7280;
  --light: #9aa0a6;
  --fire: #e63946;
  --growth: #7cb518;
  --delegate: #1e90ff;
  --stop: #9aa0a6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 30, 54, .08), 0 6px 20px rgba(16, 30, 54, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--navy-700); }

/* ---------------------------------------------------------------- шапка */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 8px 24px;
  min-height: 56px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar span.who { color: #c7d4e4; text-decoration: none; font-size: 13px; }
.topbar a:hover { color: #fff; }
.topbar select {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
}
.topbar select option { color: #333; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 24px 120px; }

/* ---------------------------------------------------------------- слайд-карта */
.slide {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px 28px;
  margin-bottom: 22px;
}
.slide-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--light);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 14px;
}
.slide h2 {
  color: var(--navy);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}
.slide .hint { color: var(--muted); font-style: italic; font-size: 12.5px; margin: 0 0 14px; }
.cols { display: grid; grid-template-columns: 1fr 1.35fr; gap: 30px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- поля */
label.fld { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
input[type=text], textarea, select.inp {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, textarea:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(1, 59, 125, .1);
}
textarea { resize: vertical; min-height: 62px; }
input::placeholder, textarea::placeholder { color: #b9bec4; }

.head-grid { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 14px; margin-bottom: 20px; }
@media (max-width: 800px) { .head-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- списки-рядки */
.rowlist { display: flex; flex-direction: column; gap: 8px; }
.rowitem { display: flex; align-items: flex-start; gap: 8px; }
.rowitem .num {
  flex: 0 0 22px;
  text-align: center;
  color: var(--navy);
  font-weight: 700;
  font-size: 13px;
  padding-top: 8px;
}
.rowitem input, .rowitem textarea { flex: 1; }

.btn-x {
  flex: 0 0 26px;
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--light);
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  margin-top: 3px;
}
.btn-x:hover { color: var(--fire); border-color: #f2c4c8; background: #fff6f6; }

.btn-add {
  margin-top: 10px;
  border: 1px dashed #c8ced6;
  background: #fff;
  color: var(--navy-700);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
.btn-add:hover { border-color: var(--navy-700); background: #f6f9fd; }

.callout {
  background: var(--navy);
  color: #dce6f2;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 16px;
}

/* ---------------------------------------------------------------- таблиця показників */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th {
  background: var(--navy);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  padding: 9px 10px;
}
table.grid th:first-child { border-radius: 6px 0 0 0; }
table.grid th:last-child { border-radius: 0 6px 0 0; }
table.grid td { border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: middle; }
table.grid tr:nth-child(even) td { background: #fafbfc; }
table.grid input { border-color: transparent; background: transparent; padding: 6px 8px; }
table.grid input:hover { border-color: var(--line); background: #fff; }
table.grid input:focus { background: #fff; }
table.grid input.metric-name { font-weight: 600; }
td.tools { width: 34px; text-align: center; }

/* ---------------------------------------------------------------- панелі блокерів */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .panels { grid-template-columns: 1fr; } }
.panel { background: #f5f6f8; border-radius: 9px; padding: 16px 16px 14px; }
.panel h3 { margin: 0 0 2px; font-size: 14px; }
.panel .hint { margin-bottom: 12px; }

/* ---------------------------------------------------------------- матриця */
.matrix { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 6px; }
@media (max-width: 900px) { .matrix { grid-template-columns: 1fr; } }
.quad { border-radius: 9px; padding: 14px 15px 12px; border-top: 3px solid; }
.quad.fire { background: #fdf1f2; border-color: var(--fire); }
.quad.growth { background: #f6fbec; border-color: var(--growth); }
.quad.delegate { background: #eef6ff; border-color: var(--delegate); }
.quad.stop { background: #f4f5f7; border-color: var(--stop); }
.quad h4 { margin: 0; font-size: 13.5px; letter-spacing: .5px; display: inline-block; }
.quad.fire h4 { color: var(--fire); }
.quad.growth h4 { color: #5f8f0f; }
.quad.delegate h4 { color: #146fce; }
.quad.stop h4 { color: #6f757b; }
.quad .cap { font-size: 11px; color: var(--muted); margin-left: 8px; }
.quad table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.quad th {
  text-align: left; font-size: 10.5px; color: var(--muted);
  font-weight: 600; padding: 0 6px 5px; border-bottom: 1px solid rgba(0,0,0,.08);
}
.quad td { padding: 3px 3px; }
.quad input { background: rgba(255,255,255,.75); border-color: rgba(0,0,0,.06); font-size: 12.5px; padding: 6px 8px; }
.quad input:focus { background: #fff; }

/* ---------------------------------------------------------------- фокус тижня */
.focus-box { border: 2px solid var(--navy); border-radius: 10px; padding: 18px 20px; }
.focus-box .cap {
  text-align: center; color: var(--navy); font-weight: 700;
  letter-spacing: 1.2px; font-size: 13px; margin-bottom: 12px;
}
.focus-box textarea { font-size: 19px; border: none; min-height: 76px; text-align: left; }
.focus-box textarea:focus { box-shadow: none; }
.quote { text-align: center; color: var(--navy); font-style: italic; margin: 22px 0 4px; font-size: 14px; }

/* ---------------------------------------------------------------- нижня панель */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 14px;
  z-index: 60;
}
.savebar .inner { max-width: 1240px; margin: 0 auto; width: 100%; display: flex; align-items: center; gap: 14px; }
.status { font-size: 12.5px; color: var(--muted); }
.status.ok { color: #2e7d32; }
.status.err { color: var(--fire); }

.btn {
  border: none; border-radius: 8px; padding: 10px 20px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: var(--navy); color: #fff;
}
.btn:hover { background: var(--navy-700); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f4f7fb; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- логін */
.center-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #002b5c 0%, #013b7d 100%);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 14px; padding: 38px 36px;
  width: 100%; max-width: 430px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-card h1 { font-size: 21px; margin: 0 0 6px; color: var(--navy); }
.auth-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 14px; font-weight: 600; color: #3c4043;
  text-decoration: none; cursor: pointer;
}
.gbtn:hover { background: #f7f8fa; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--light); font-size: 11.5px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.err { background: #fdf1f2; color: #a4262c; border-radius: 7px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- адмінка */
table.admin { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.admin th { background: var(--navy); color: #fff; font-size: 12px; text-align: left; padding: 11px 14px; font-weight: 600; }
table.admin td { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.admin tr:hover td { background: #f8fafc; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.done { background: #e7f5e9; color: #2e7d32; }
.badge.part { background: #fff6e5; color: #b26a00; }
.badge.none { background: #f2f3f5; color: #8a9099; }
.bar { height: 5px; background: #eceef1; border-radius: 4px; overflow: hidden; width: 90px; }
.bar > i { display: block; height: 100%; background: var(--navy); }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
table.admin .lbl { display: none; }   /* подписи к иконкам — только на мобильных */

/* ---- шапка на планшетах и телефонах: две строки, неделя на всю ширину ---- */
@media (max-width: 900px) {
  .topbar { padding: 10px 14px 12px; gap: 10px 14px; }
  .topbar h1 { font-size: 15px; flex: 1 1 auto; }
  .topbar .spacer { display: none; }
  .topbar .who { display: none; }
  .topbar a { font-size: 13px; white-space: nowrap; }
  .topbar select { order: 10; flex: 1 0 100%; padding: 9px 10px; font-size: 15px; }
}

/* ================================================================ МОБИЛЬНАЯ ВЕРСИЯ */
@media (max-width: 760px) {

  .wrap { padding: 14px 12px 150px; }

  .slide { padding: 18px 14px 20px; border-radius: 12px; margin-bottom: 14px; }
  .slide h2 { font-size: 18px; }
  .slide .hint { font-size: 12px; }
  .slide-tag { font-size: 10px; margin-bottom: 12px; }
  .cols, .panels, .matrix { gap: 22px; }

  /* 16px — иначе iOS зумит страницу при фокусе на поле */
  input[type=text], textarea, select.inp, input[type=password] { font-size: 16px; padding: 10px 12px; }

  /* ---- списки побед / блокеров ---- */
  .rowitem .num { flex: 0 0 18px; padding-top: 10px; font-size: 12px; }
  .rowitem .btn-x { flex: 0 0 34px; height: 38px; margin-top: 2px; font-size: 17px; }
  .btn-add { padding: 9px 16px; font-size: 13.5px; }
  .callout { font-size: 12.5px; }

  /* ---- таблицы превращаются в карточки ---- */
  table.grid thead, .quad table thead { display: none; }
  table.grid, table.grid tbody, table.grid tr, table.grid td,
  .quad table, .quad tbody, .quad tr, .quad td { display: block; width: 100%; }

  table.grid tr, .quad tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 12px 8px;
    margin-bottom: 10px;
  }
  table.grid tr:nth-child(even) td { background: transparent; }

  table.grid td, .quad td {
    border-bottom: none;
    padding: 3px 0;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  table.grid td::before, .quad td::before {
    content: attr(data-label);
    flex: 0 0 29%;
    font-size: 11px;
    color: var(--muted);
    line-height: 1.2;
  }
  table.grid input, .quad input { border-color: var(--line); background: #fff; flex: 1; }
  table.grid input.metric-name { font-weight: 600; }

  /* кнопка удаления строки — отдельной строкой снизу карточки */
  td.tools, .quad td:last-child {
    width: auto;
    justify-content: flex-end;
    padding-top: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
  }
  td.tools::before, .quad td:last-child::before { content: none; }
  td.tools .btn-x, .quad td:last-child .btn-x {
    flex: 0 0 auto;
    width: auto;
    height: 34px;
    padding: 0 14px;
    font-size: 0;
    margin: 0;
  }
  td.tools .btn-x::after, .quad td:last-child .btn-x::after {
    content: "Удалить";
    font-size: 12.5px;
  }

  .quad { padding: 14px 12px 12px; }
  .quad tr { background: rgba(255, 255, 255, .8); }
  .quad .cap { display: block; margin: 4px 0 0; }

  /* ---- фокус недели ---- */
  .focus-box { padding: 14px 14px 12px; }
  .focus-box .cap { font-size: 12px; letter-spacing: .8px; }
  .focus-box textarea { font-size: 17px; min-height: 108px; }
  .quote { font-size: 13px; }

  /* ---- нижняя панель сохранения ---- */
  .savebar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .savebar .inner { flex-wrap: wrap; gap: 8px 10px; }
  .savebar .btn { flex: 1 1 auto; padding: 12px 14px; }
  .status { flex: 1 0 100%; font-size: 12px; order: 10; }

  /* ---- вход / пароль администратора ---- */
  .center-page { padding: 14px; align-items: flex-start; padding-top: 40px; }
  .auth-card { padding: 26px 20px; border-radius: 12px; }
  .auth-card h1 { font-size: 19px; }

  /* ---- админка: строки таблицы как карточки ---- */
  table.admin, table.admin tbody, table.admin tr, table.admin td { display: block; width: 100%; }
  table.admin thead { display: none; }
  table.admin { background: transparent; box-shadow: none; }
  table.admin tr {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    padding: 12px 14px;
  }
  table.admin tr:hover td { background: transparent; }
  table.admin td { border-bottom: none; padding: 3px 0; display: flex; gap: 10px; align-items: center; }
  table.admin td::before {
    content: attr(data-label);
    flex: 0 0 34%;
    font-size: 11.5px;
    color: var(--muted);
  }
  table.admin td[data-label=""]::before, table.admin td:first-child::before { content: none; }
  table.admin td:first-child { display: block; margin-bottom: 6px; }
  table.admin td:last-child { gap: 8px; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); }
  table.admin td:last-child a {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 15px; padding: 7px 12px; text-decoration: none;
    border: 1px solid var(--line); border-radius: 7px;
  }
  table.admin .lbl { display: inline; font-size: 12.5px; }
  .bar { width: 100%; max-width: 160px; }

  .toolbar { gap: 10px; }
  .toolbar .btn { flex: 1 1 46%; text-align: center; }

  /* ---- просмотр формы администратором ---- */
  .ro { font-size: 14px; }
}

/* совсем узкие экраны */
@media (max-width: 380px) {
  .topbar h1 { font-size: 14px; }
  .wrap { padding-left: 8px; padding-right: 8px; }
  .slide { padding-left: 11px; padding-right: 11px; }
  table.grid tr, .quad tr { padding-left: 9px; padding-right: 9px; }
  table.grid td::before, .quad td::before { flex-basis: 27%; font-size: 10.5px; }
}

/* ---------------------------------------------------------------- поля с календарём */
input[type=date] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 8px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
input[type=date]:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(1, 59, 125, .1);
}
/* пустая дата не должна кричать серым «дд.мм.гггг» сильнее, чем заполненная */
input[type=date]:invalid, input[type=date]:not(:focus):placeholder-shown { color: var(--light); }
.quad input[type=date] {
  background: rgba(255, 255, 255, .75);
  border-color: rgba(0, 0, 0, .06);
  font-size: 12px;
  padding: 6px 4px;
}
.quad input[type=date]:focus { background: #fff; }
@media (max-width: 760px) {
  input[type=date] { font-size: 16px; padding: 10px 10px; }
  .quad input[type=date] { font-size: 16px; }
}
