/* Dashveba — ადმინ-პანელი. ფერები ESP32-ის ეკრანისას ემთხვევა. */

/* BPG Glaho — ფაილები fonts/-შია, font.php აწვდის (იხ. README) */
@font-face {
  font-family: "BPG Glaho";
  src: url("font.php?f=glaho") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BPG Glaho";
  src: url("font.php?f=glaho-bold") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --blue: #1e4e8c;
  --blue-soft: #e8eef7;
  --green: #2e7d32;
  --green-soft: #e6f2e7;
  --orange: #e65100;
  --orange-soft: #fdeee3;
  --red: #b71c1c;
  --red-soft: #fbe9e9;
  --amber: #8a6100;
  --amber-soft: #fff4d6;
  --grey: #5f6b76;
  --grey-soft: #eef0f2;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e2e6ea;
  --bg: #f4f6f9;
  --card: #ffffff;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

/* ჰორიზონტალური სქროლი არსად არ გვინდა (iPhone) — განიერი ცხრილები
   თავიანთ ბლოკში სრიალებს, გვერდი კი ეკრანის სიგანეზე რჩება. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.55 "BPG Glaho", "BPG Glaho WEB Caps", "BPG Arial", "Segoe UI",
    "Noto Sans Georgian", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

img,
table {
  max-width: 100%;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 600;
}

h3 {
  margin: 0 0 10px;
  font-size: 19px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

main.wrap {
  padding-top: 24px;
  padding-bottom: 48px;
}

.muted {
  color: var(--muted);
  font-weight: normal;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.nowrap {
  white-space: nowrap;
}

.right {
  text-align: right;
}

/* ---------------------------------------------------------------- ზედა ზოლი */

.topbar {
  background: var(--blue);
  color: #fff;
}

.topbar-inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px 12px;
  min-height: 60px;
}

.brand {
  flex: none;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

/* ბმულები ერთ ხაზზე რჩება; თუ არ ეტევა, ზოლი თვითონ გასრიალდება */
.menu {
  display: flex;
  flex: 1;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.menu::-webkit-scrollbar {
  display: none;
}

.menu a {
  color: rgba(255, 255, 255, 0.82);
  padding: 8px 7px;
  border-radius: 6px;
  font-size: 15.5px;
  white-space: nowrap;
}

/* ჰამბურგერი — მხოლოდ ვიწრო ეკრანზე */
.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 38px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  cursor: pointer;
}

.burger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: #fff;
}

.menu a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.menu a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.account {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  font-size: 15.5px;
}

.account a,
.account .link-button {
  color: rgba(255, 255, 255, 0.9);
}

.account form {
  margin: 0;
}

.link-button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------- ბლოკები */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.page-head p {
  margin: -10px 0 16px;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.flash-ok {
  background: var(--green-soft);
  color: var(--green);
}

.flash-error {
  background: var(--red-soft);
  color: var(--red);
}

.flash-info {
  background: var(--blue-soft);
  color: var(--blue);
}

.secret {
  background: var(--amber-soft);
  border-color: #f0d68a;
}

.secret dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 8px;
}

.secret dt {
  color: var(--muted);
}

.secret dd {
  margin: 0;
  font-size: 20px;
  word-break: break-all;
}

/* ---------------------------------------------------------------- სტატისტიკა */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.stat b {
  display: block;
  font-size: 30px;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 15px;
}

.stat-blue {
  border-left-color: var(--blue);
}

.stat-grey {
  border-left-color: #b8c0c8;
}

.stat-orange {
  border-left-color: var(--orange);
}

.stat-red {
  border-left-color: var(--red);
}

.stat-amber {
  border-left-color: #e0a800;
}

/* ---------------------------------------------------------------- ცხრილი */

.table-wrap {
  padding: 0;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th.right,
.table td.right {
  text-align: right;
}

.table th {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  background: #fafbfc;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: #fafbfd;
}

.table tr.weekend td {
  background: #fafafa;
  color: var(--muted);
}

.table tr.inactive td {
  color: var(--muted);
}

.table tr.total td {
  font-weight: 600;
  background: #fafbfc;
}

.num-red {
  color: var(--red);
  font-weight: 600;
}

.num-orange {
  color: var(--orange);
  font-weight: 600;
}

/* ---------------------------------------------------------------- სტატუსები */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 15px;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-present,
.badge-left {
  background: var(--green-soft);
  color: var(--green);
}

.badge-at_work {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-incomplete {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-absent {
  background: var(--red-soft);
  color: var(--red);
}

.badge-late {
  background: var(--orange-soft);
  color: var(--orange);
}

.badge-not_yet,
.badge-off {
  background: var(--grey-soft);
  color: var(--grey);
}

/* ---------------------------------------------------------------- დღის ფერები */

/* ყოველ სტატუსს თავისი ფონი და ზოლი აქვს; უჯრა, ბარათი და ლეგენდა ერთსა და
   იმავე ცვლადებს იყენებს, ამიტომ ფერი ერთ ადგილას იცვლება. */
.day-present,
.day-left {
  --day-bg: var(--green-soft);
  --day-line: var(--green);
}

.day-at_work {
  --day-bg: var(--blue-soft);
  --day-line: var(--blue);
}

.day-incomplete {
  --day-bg: var(--amber-soft);
  --day-line: #e0a800;
}

.day-absent {
  --day-bg: var(--red-soft);
  --day-line: var(--red);
}

.day-not_yet {
  --day-bg: var(--grey-soft);
  --day-line: #b8c0c8;
}

.day-off {
  --day-bg: #f7f8f9;
  --day-line: #dfe3e7;
}

.table tbody tr.day td,
.table tbody tr.day:hover td {
  background: var(--day-bg, transparent);
}

.table tbody tr.day td:first-child {
  box-shadow: inset 4px 0 0 var(--day-line, transparent);
}

.table td.day {
  background: var(--day-bg, transparent);
}

.legend-days {
  gap: 6px 14px;
  color: var(--muted);
  font-size: 15px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item i.day {
  width: 14px;
  height: 14px;
  border: 1px solid var(--day-line, var(--line));
  border-radius: 4px;
  background: var(--day-bg, #fff);
}

.section-head {
  margin: 26px 0 10px;
  font-size: 21px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- დღეს: ბარათები */

.group {
  margin-bottom: 22px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 600;
}

.group-head .dot {
  width: 12px;
  height: 12px;
  border: 1px solid var(--day-line, var(--line));
  border-radius: 50%;
  background: var(--day-bg, #fff);
}

.group-head .count {
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.person {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--day-line, var(--line));
  border-radius: var(--radius);
  background: var(--day-bg, var(--card));
  color: var(--text);
}

.person:hover {
  border-color: var(--day-line, var(--blue));
  text-decoration: none;
}

.person b {
  display: block;
  font-size: 19px;
}

.person-name {
  color: var(--text);
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.person-actions form {
  margin: 0;
}

/* დღის ჩასწორება: ტიპი, დრო და წაშლა ერთ ხაზზე */
.event-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.form .event-row select,
.form .event-row input {
  display: inline-block;
  width: auto;
  margin-top: 0;
}

.person-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 16px;
}

.person-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------- დღეების ბადე */

.table.grid th,
.table.grid td {
  padding: 8px 10px;
}

.table.grid .grid-name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 170px;
  background: var(--card);
}

.table.grid thead .grid-name,
.table.grid tr.total .grid-name {
  z-index: 2;
  background: #fafbfc;
}

.table.grid .grid-col {
  min-width: 58px;
  padding: 6px 5px;
  text-align: center;
  font-size: 15px;
  white-space: nowrap;
}

.table.grid thead .grid-col {
  background: #fafbfc;
}

.grid-num {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.grid-wd {
  display: block;
  font-weight: normal;
}

/* ---------------------------------------------------------------- ფორმები */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.quick a {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 16px;
}

.quick a:hover {
  border-color: var(--blue);
  text-decoration: none;
}

.form label {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
}

.form.narrow {
  max-width: 620px;
}

.form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* 22px — iPhone-ზე ველში შესვლისას ეკრანი რომ არ გაადიდოს */
input,
select,
textarea {
  font: inherit;
  font-size: 22px;
  color: var(--text);
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #cdd3da;
  border-radius: 7px;
  background: #fff;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

/* წაშლის ბლოკი — ჩაკეცილი, რომ შემთხვევით არ დააჭირო */
.danger-zone summary {
  color: var(--red);
  cursor: pointer;
  font-weight: 600;
}

.danger-zone p {
  margin: 10px 0;
}

.form input:not([type="checkbox"]),
.form select {
  display: block;
  width: 100%;
  margin-top: 4px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(30, 78, 140, 0.35);
  border-color: var(--blue);
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
}

label.check input {
  width: 16px;
  height: 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 2px;
  margin: 0 0 16px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 15px;
}

fieldset label.check {
  margin-bottom: 10px;
}

.days {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 8px;
}

.hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: normal;
}

.field-error {
  margin-top: 4px;
  color: var(--red);
  font-size: 15.5px;
  font-weight: normal;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: #173f73;
  text-decoration: none;
}

.btn-secondary {
  background: #fff;
  color: var(--blue);
}

.btn-secondary:hover {
  background: var(--blue-soft);
}

.btn-small {
  padding: 5px 14px;
  font-size: 16px;
}

.btn-danger {
  border-color: var(--red);
  background: var(--red);
}

.btn-danger:hover {
  background: #8f1414;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ---------------------------------------------------------------- შესვლა */

.login {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card label {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
}

.login-brand {
  color: var(--blue);
  font-size: 30px;
  font-weight: 700;
}

.login-card p {
  margin: 0 0 18px;
}

/* ---------------------------------------------------------------- ტელეფონი */

/* ვიწრო ეკრანზე ცხრილი ბარათებად იშლება: სათაური თითო უჯრის გვერდით
   data-label-იდან ჩნდება, ჰორიზონტალური სქროლი აღარ სჭირდება. */
/* ვიწრო ლეპტოპზეც: ზოლში მხოლოდ ლოგო და ჰამბურგერი, დანარჩენი ღილაკქვეშ */
@media (max-width: 1200px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 0 12px;
    min-height: 54px;
    padding: 6px 0;
  }

  .brand {
    flex: 1;
  }

  .burger {
    display: flex;
  }

  .menu,
  .account {
    display: none;
  }

  .nav-toggle:checked ~ .menu,
  .nav-toggle:checked ~ .account {
    display: flex;
    flex: none;
    width: 100%;
  }

  .nav-toggle:checked ~ .menu {
    order: 3;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0 4px;
    overflow: visible;
  }

  .menu a {
    padding: 11px 12px;
    border-radius: 8px;
    font-size: 18px;
  }

  .nav-toggle:checked ~ .account {
    order: 4;
    justify-content: space-between;
    padding: 10px 12px 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 17px;
  }
}

@media (max-width: 860px) {
  .table.cards thead {
    display: none;
  }

  .table.cards,
  .table.cards tbody,
  .table.cards tr,
  .table.cards td {
    display: block;
    width: 100%;
  }

  .table.cards tbody tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid var(--day-line, transparent);
    background: var(--day-bg, transparent);
  }

  .table.cards tbody tr:last-child {
    border-bottom: 0;
  }

  .table.cards tbody tr.day td,
  .table.cards tbody tr.day:hover td,
  .table.cards tbody tr:hover td {
    background: transparent;
  }

  .table.cards tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    min-width: 0;
    padding: 3px 0;
    border: 0;
    overflow-wrap: anywhere;
    text-align: right;
  }

  .table.cards tbody td:first-child {
    box-shadow: none;
  }

  .table.cards tbody td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 15.5px;
    text-align: left;
  }

  .table.cards tbody td:not([data-label]) {
    justify-content: flex-start;
    text-align: left;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 24px;
  }

  .form .row {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat b {
    font-size: 26px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar label,
  .toolbar select,
  .toolbar input,
  .toolbar .btn,
  .toolbar button,
  .page-head > .btn {
    width: 100%;
  }

  .toolbar label input {
    flex: 1;
    min-width: 0;
  }

  .toolbar form.toolbar {
    width: 100%;
  }

  .person-grid {
    grid-template-columns: 1fr;
  }

  .wrap {
    padding: 0 12px;
  }

  .card {
    padding: 16px;
  }
}

/* ---------------------------------------------------------------- ბეჭდვა */

@media print {
  .topbar,
  .toolbar,
  .quick,
  .page-head .btn {
    display: none;
  }

  body {
    background: #fff;
  }

  .card {
    border-color: #ccc;
    break-inside: avoid;
  }

  .table.grid .grid-col {
    min-width: 0;
    padding: 4px 2px;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

/* ---------------------------------------------------------------- შეერთების სქემა */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.pin-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14.5px;
  white-space: nowrap;
}

.pin-tag-pn532 {
  background: var(--green-soft);
  border-color: #bcdcbf;
  color: var(--green);
}

.pin-tag-tft {
  background: var(--blue-soft);
  border-color: #c3d3ea;
  color: var(--blue);
}

.pin-tag-set {
  background: var(--orange-soft);
  border-color: #f6cdae;
  color: var(--orange);
}

.pin-tag-power {
  background: var(--red-soft);
  border-color: #f0c2c2;
  color: var(--red);
}

.pin-tag-busy {
  background: var(--grey-soft);
  border-color: #d9dde1;
  color: var(--grey);
}

.pin-tag-usb {
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}

.pinmap-card {
  overflow-x: auto;
}

.pinmap {
  display: grid;
  grid-template-columns: 1fr auto 60px auto 1fr;
  min-width: 540px;
  max-width: 760px;
  margin: 0 auto;
}

.pin-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
}

.pin-tags.pin-left {
  justify-content: flex-end;
}

.pin-name,
.board-body {
  background: #23313f;
  border-top: 1px solid #2f3f50;
}

.pin-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  padding: 4px 8px;
  color: #8796a4;
  font: 15px/1.4 Consolas, "Courier New", monospace;
}

.pin-name.pin-right {
  justify-content: flex-end;
}

/* ფინის "ანაკი" — დაფის გარე კიდეზე */
.pin-name::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6d6030;
}

.pin-name.pin-right::before {
  order: 2;
}

.pin-name.pin-used {
  color: #fff;
  font-weight: 700;
}

.pin-name.pin-used::before {
  background: #e0b83a;
  box-shadow: 0 0 0 2px rgba(224, 184, 58, 0.25);
}

.pin-gpio {
  color: #647382;
  font-size: 13px;
  font-weight: normal;
}

.board-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-title {
  color: #cfd8e0;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.board-cap {
  grid-column: span 3;
  padding: 6px;
  background: #1a2530;
  color: #8796a4;
  font-size: 14px;
  text-align: center;
}

.board-top {
  border-radius: 12px 12px 0 0;
}

.board-bottom {
  border-radius: 0 0 12px 12px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0 20px;
}

.card ul,
.card ol.steps {
  margin: 0 0 10px;
  padding-left: 22px;
}

.card li {
  margin-bottom: 6px;
}

.table.compact th,
.table.compact td {
  padding: 6px 10px;
}
