#agrodrone-modern-root {
  --agd-green: #166534;
  --agd-green-2: #15803d;
  --agd-green-soft: #ecfdf3;
  --agd-blue: #2563eb;
  --agd-red: #dc2626;
  --agd-amber: #d97706;
  --agd-ink: #0f172a;
  --agd-muted: #64748b;
  --agd-line: #dbe3ef;
  --agd-bg: #f6f8fb;
  --agd-panel: #ffffff;
  --agd-soft: #f8fafc;
  color: var(--agd-ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.agrodrone-modern-host > *:not(#agrodrone-modern-root) {
  display: none !important;
}

body.agrodrone-modern-active .Toastify__toast-body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.agd-page {
  min-height: calc(100vh - 1px);
  padding: 24px 28px 34px;
  background: var(--agd-bg);
}

.agd-shell {
  max-width: 1640px;
  margin: 0 auto;
}

.agd-head {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.agd-kicker {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--agd-green);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.agd-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 0;
}

.agd-subtitle {
  max-width: 980px;
  margin: 8px 0 0;
  color: var(--agd-muted);
  font-size: 15px;
  line-height: 1.5;
}

.agd-actions,
.agd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.agd-actions {
  justify-content: flex-end;
}

.agd-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.agd-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.agd-btn:active {
  transform: translateY(1px);
}

.agd-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.agd-btn-primary {
  border-color: var(--agd-green);
  background: var(--agd-green);
  color: #fff;
}

.agd-btn-primary:hover {
  border-color: #14532d;
  background: #14532d;
}

.agd-btn-soft {
  border-color: #bbf7d0;
  background: var(--agd-green-soft);
  color: var(--agd-green);
}

.agd-btn-danger {
  border-color: #fecaca;
  background: #fff;
  color: var(--agd-red);
}

.agd-btn-icon {
  width: 42px;
  padding: 0;
}

.agd-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 14px;
  margin-bottom: 12px;
}

.agd-tab {
  white-space: nowrap;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1e293b;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.agd-tab.is-active {
  border-color: var(--agd-green);
  background: var(--agd-green);
  color: #fff;
}

.agd-card {
  background: var(--agd-panel);
  border: 1px solid var(--agd-line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.agd-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.agd-stat {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--agd-line);
  border-radius: 10px;
}

.agd-stat span {
  display: block;
  color: var(--agd-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.agd-stat strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  color: var(--agd-ink);
}

.agd-grid {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.agd-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--agd-line);
}

.agd-panel-head h2,
.agd-section-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 800;
}

.agd-panel-body {
  padding: 16px 18px 18px;
}

.agd-filter {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--agd-line);
  background: #fff;
}

.agd-input,
.agd-select,
.agd-textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  outline: none;
}

.agd-textarea {
  min-height: 86px;
  padding: 10px 12px;
  resize: vertical;
}

.agd-input:focus,
.agd-select:focus,
.agd-textarea:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .14);
}

.agd-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.agd-list {
  max-height: calc(100vh - 372px);
  min-height: 420px;
  overflow: auto;
}

.agd-list-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--agd-line);
  cursor: pointer;
  background: #fff;
}

.agd-list-item:hover {
  background: #f8fafc;
}

.agd-list-item.is-active {
  background: #fff7ed;
  box-shadow: inset 4px 0 0 #22c55e;
}

.agd-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 999px;
  background: #94a3b8;
}

.agd-dot.ready { background: #2563eb; }
.agd-dot.planned { background: #a855f7; }
.agd-dot.reserved { background: #0ea5e9; }
.agd-dot.in_progress { background: #f59e0b; }
.agd-dot.fact_imported { background: #22c55e; }
.agd-dot.closed { background: #64748b; }
.agd-dot.cancelled { background: #ef4444; }

.agd-item-title {
  margin: 0 0 5px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
}

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

.agd-detail-title {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  margin: 0;
}

.agd-detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--agd-muted);
  font-size: 14px;
  margin-top: 8px;
}

.agd-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.agd-badge.green {
  background: #dcfce7;
  color: #166534;
}

.agd-badge.red {
  background: #fee2e2;
  color: #991b1b;
}

.agd-badge.amber {
  background: #fef3c7;
  color: #92400e;
}

.agd-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  border-top: 1px solid var(--agd-line);
  border-bottom: 1px solid var(--agd-line);
}

.agd-summary-cell {
  padding: 18px 20px;
  border-right: 1px solid var(--agd-line);
}

.agd-summary-cell:last-child {
  border-right: 0;
}

.agd-summary-cell span {
  display: block;
  color: var(--agd-muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.agd-summary-cell strong {
  display: block;
  color: #243047;
  font-size: 25px;
  line-height: 1.15;
  font-weight: 700;
}

.agd-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--agd-line);
}

.agd-section:last-child {
  border-bottom: 0;
}

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

.agd-work-grid {
  display: grid;
  gap: 12px;
}

.agd-work-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--agd-line);
  border-radius: 10px;
  background: var(--agd-soft);
}

.agd-work-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 800;
}

.agd-work-card p {
  margin: 4px 0;
  color: #334155;
  font-size: 14px;
}

.agd-table-wrap {
  overflow: auto;
  border: 1px solid var(--agd-line);
  border-radius: 10px;
  background: #fff;
}

.agd-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  font-size: 14px;
}

.agd-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  background: #f1f5f9;
  text-align: left;
  font-weight: 800;
  color: #334155;
  border-bottom: 1px solid var(--agd-line);
}

.agd-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--agd-line);
  vertical-align: top;
}

.agd-table tr:last-child td {
  border-bottom: 0;
}

.agd-empty,
.agd-error {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--agd-muted);
  text-align: center;
}

.agd-error {
  border-style: solid;
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  text-align: left;
}

.agd-device-grid,
.agd-report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
}

.agd-device-card {
  padding: 16px;
  border: 1px solid var(--agd-line);
  border-radius: 10px;
  background: #fff;
}

.agd-device-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
}

.agd-device-card p {
  margin: 5px 0;
  color: #334155;
  font-size: 14px;
}

.agd-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15, 23, 42, .58);
}

.agd-modal {
  width: min(980px, 100%);
  max-height: min(92vh, 940px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .32);
}

.agd-modal.small {
  width: min(680px, 100%);
}

.agd-modal-head,
.agd-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--agd-line);
}

.agd-modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--agd-line);
  border-bottom: 0;
}

.agd-modal-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.agd-modal-body {
  padding: 20px 22px;
  overflow: auto;
}

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

.agd-form-grid .wide {
  grid-column: 1 / -1;
}

.agd-label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.agd-mini {
  color: var(--agd-muted);
  font-size: 12px;
}

.agd-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1300;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--agd-line);
  box-shadow: 0 18px 44px rgba(15, 23, 42, .2);
  color: #0f172a;
  font-size: 14px;
}

.agd-toast.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.agd-toast.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

@media (max-width: 1280px) {
  .agd-grid {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .agd-summary,
  .agd-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agd-device-grid,
  .agd-report-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 980px) {
  .agd-page {
    padding: 16px 14px 24px;
  }

  .agd-head,
  .agd-grid,
  .agd-work-card {
    grid-template-columns: 1fr;
  }

  .agd-actions {
    justify-content: flex-start;
  }

  .agd-list {
    max-height: 420px;
    min-height: 280px;
  }

  .agd-form-grid,
  .agd-device-grid,
  .agd-report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .agd-title,
  .agd-detail-title {
    font-size: 24px;
  }

  .agd-summary,
  .agd-stats,
  .agd-filter-row {
    grid-template-columns: 1fr;
  }

  .agd-summary-cell {
    border-right: 0;
    border-bottom: 1px solid var(--agd-line);
  }

  .agd-summary-cell:last-child {
    border-bottom: 0;
  }

  .agd-btn,
  .agd-tab {
    width: 100%;
  }

  .agd-modal-backdrop {
    align-items: stretch;
    padding: 10px;
  }
}
