:root {
  --bg: #f2f2f0;
  --surface: #ffffff;
  --ink: #202020;
  --muted: #6a6a6a;
  --line: #d8d8d4;
  --primary: #df0614;
  --primary-strong: #a9000b;
  --accent: #2d2f32;
  --warning: #a66b00;
  --danger: #b00020;
  --soft: #f4f4f2;
  --steel: #36393b;
  --shadow: 0 14px 34px rgba(24, 24, 24, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Roboto Condensed", Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.26)),
    url("https://images.unsplash.com/photo-1565008447742-97f6f38c985c?auto=format&fit=crop&w=1800&q=80") center / cover;
}

.login-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(100%, 430px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-top: 5px solid var(--primary);
}

.brand-mark {
  width: max-content;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 54px;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  transform: skew(-10deg);
}

.brand-mark.small {
  margin: 0;
  font-size: 34px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  font-weight: 900;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 111, 90, 0.12);
}

.primary,
.secondary,
.ghost {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  color: #fff;
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  color: var(--accent);
  background: var(--soft);
  border: 1px solid var(--line);
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.large {
  min-height: 56px;
  padding-inline: 22px;
  font-size: 17px;
}

.wide {
  width: 100%;
}

svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.demo-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  font-size: 22px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  color: #fff;
  background: var(--steel);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.page {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 4vw, 36px) 40px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.action-row.end {
  justify-content: flex-end;
  margin-top: 14px;
  margin-bottom: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.admin-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.visit-list {
  display: grid;
  gap: 10px;
}

.visit-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.visit-item.offline {
  border-color: #f1c46b;
  background: #fffaf0;
}

.visit-item strong {
  font-size: 15px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.tag.warn {
  background: #fff4df;
  color: var(--warning);
}

.offline-panel {
  margin-bottom: 16px;
  border-color: #f1c46b;
}

.form-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.visit-form {
  display: grid;
  gap: 16px;
}

.form-panel {
  box-shadow: none;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-grid .full {
  grid-column: 1 / -1;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
  min-height: 44px;
}

.check-line input {
  width: 18px;
  height: 18px;
}

.form-note {
  margin: 0;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  background: var(--soft);
  color: var(--muted);
  font-weight: 700;
}

.search-results {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.search-result {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background: var(--soft);
}

.map {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #e8ece7;
}

.visit-map {
  margin-bottom: 14px;
}

.admin-map {
  min-height: 500px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  color: var(--primary);
}

.filters {
  margin-bottom: 16px;
}

.admin-filters {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.summary-lists {
  display: grid;
  gap: 16px;
}

.summary-block h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.bar-row:last-child {
  border-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

@media (max-width: 980px) {
  .grid.two,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .metrics-grid,
  .admin-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-brand {
    width: 100%;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
  }

  .field-grid,
  .metrics-grid,
  .admin-filters {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .map {
    min-height: 280px;
  }

  .admin-map {
    min-height: 360px;
  }

  .primary,
  .secondary,
  .ghost {
    width: 100%;
  }
}
