:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --primary: #0f172a;
  --primary-text: #ffffff;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
}

.stack {
  display: grid;
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.title {
  margin: 0 0 6px 0;
  font-size: 28px;
  font-weight: 700;
}

.section-title {
  margin-top: 0;
}

.subtitle {
  margin: 0 0 20px 0;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  margin-bottom: 16px;
}

.top-gap {
  margin-top: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input[type="text"],
input[type="file"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.panel {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #e2e8f0;
}

.switch-row:first-child {
  border-top: 0;
}

.button {
  display: inline-block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.alert {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  display: none;
  white-space: pre-wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
}

.result-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.map {
  min-height: 800px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.leaflet-tooltip.marker-label-tooltip {
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  opacity: 1 !important;
  z-index: 700;
}

.copy-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

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

.copy-value {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  word-break: break-all;
  min-height: 50px;
}

.copy-value a {
  color: #2563eb;
}

.mini-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.actions a {
  display: inline-block;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  text-align: center;
  background: #fff;
}

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

.list {
  display: grid;
  gap: 12px;
}

.item {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}

.list-draggable .order-item {
  cursor: grab;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.list-draggable .order-item:active {
  cursor: grabbing;
}
.list-draggable .order-item.dragging {
  opacity: 0.5;
}
.list-draggable .order-item.drag-over {
  box-shadow: 0 0 0 2px var(--primary);
}
.list-draggable.loading {
  pointer-events: none;
  opacity: 0.7;
}

.badge {
  min-width: 28px;
  height: 28px;
  border-radius: 10px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .stats,
  .actions {
    grid-template-columns: 1fr;
  }
}


.hidden {
  display: none !important;
}

.stack {
  display: grid;
}

.gap-16 {
  gap: 16px;
}

.panel-title {
  font-weight: 700;
  margin-bottom: 12px;
}

.flex-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entry-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

.entry-table th {
  text-align: left;
  padding: 0 8px 4px 0;
  vertical-align: bottom;
}

.entry-table td {
  vertical-align: top;
  padding-right: 8px;
}

.entry-table input,
.entry-table select {
  width: 100%;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
  font-size: 18px;
}

.icon-btn:hover {
  background: #f8fafc;
}

.actions a:only-child,
.actions button:only-child {
  grid-column: 1 / -1;
}


.layout-stack {
  display: grid;
  gap: 24px;
}

.hero-card {
  padding-bottom: 12px;
}

.top-input-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: start;
}

.top-input-left-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.button-reset {
  background: #991b1b;
  color: #fff;
  border: 0;
}

.button-reset:hover {
  background: #b91c1c;
}

.link-download {
  color: var(--primary);
  text-decoration: underline;
}

.link-download:hover {
  color: #1d4ed8;
}

.bottom-result-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: start;
}

.compact-field {
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .top-input-grid,
  .bottom-result-grid {
    grid-template-columns: 1fr;
  }
}


.hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 13px;
  color: var(--muted, #64748b);
}

.pagination-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text);
  text-decoration: none;
}

.pagination-btn:hover {
  background: var(--bg);
  border-color: var(--accent, #3b82f6);
}

.depots-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.depots-form-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px 24px;
}

@media (max-width: 640px) {
  .depots-form-grid {
    grid-template-columns: 1fr;
  }
}

.depots-table td:nth-child(2) {
  white-space: normal;
  word-break: break-word;
  max-width: 320px;
}

.depots-table .depot-coords,
.depots-table .edit-coords-readonly {
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.admin-table {
  border-spacing: 0 6px;
}

.admin-table th,
.admin-table td {
  white-space: nowrap;
  font-size: 13px;
}

.admin-create-user-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-create-user-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}

@media (max-width: 640px) {
  .admin-create-user-grid {
    grid-template-columns: 1fr;
  }
}

.recent-calculations-table td:last-child {
  white-space: normal;
  word-break: break-word;
  max-width: 320px;
}

.recent-calculations-table td.error-cell {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  max-height: 2.8em;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.admin-row-form {
  flex-wrap: nowrap;
}

.admin-row-form select {
  min-width: 72px;
  padding: 6px 8px;
}

.admin-row-form input[type="password"] {
  min-width: 70px;
  width: 70px;
  padding: 6px 8px;
}

.admin-row-form .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .hero-head {
    flex-direction: column;
  }
}
