/* Base layout */

:root {
  --bg: #020617;
  --bg-alt: #0b1220;
  --card: #020617;
  --border: #1f2937;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.18);
  --accent-hover: #1d4ed8;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f97316;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%);
  color: var(--text);
}

/* Header */

.app-header {
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header-title {
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header-title span.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 235, 0.5);
  text-transform: uppercase;
}

.app-header-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-left: 16px;
}

.app-header-nav a:hover {
  color: var(--text);
}

/* Page container */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0px 16px 40px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 20px;
}

/* Cards & sections */

.card {
  background: radial-gradient(circle at top left, #111827 0, #020617 55%);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.card h2 {
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.card .card-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Grid layout */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 18px;
}

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

/* Forms */

form {
  margin: 0;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.form-field {
  flex: 1 1 180px;
  min-width: 180px;
}

label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 0.9rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.5);
}

textarea {
  resize: vertical;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.5);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--danger);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Tables */

.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  padding: 8px 10px;
  text-align: left;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.9);
}

tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.9);
}

tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.7);
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.16);
}

/* Status pills */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}

.status-created { background: rgba(148, 163, 184, 0.18); color: #cbd5f5; }
.status-client_confirmed { background: rgba(245, 158, 11, 0.22); color: #fcd34d; }
.status-engineer_assigned { background: rgba(59, 130, 246, 0.22); color: #bfdbfe; }
.status-in_progress { background: rgba(34, 197, 94, 0.24); color: #bbf7d0; }
.status-revisit_required { background: rgba(249, 115, 22, 0.24); color: #fed7aa; }
.status-hold { background: rgba(148, 163, 184, 0.18); color: #e2e8f0; }
.status-completed { background: rgba(16, 185, 129, 0.2); color: #a7f3d0; }
.status-canceled { background: rgba(239, 68, 68, 0.22); color: #fecaca; }

/* Small elements */

.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(148, 163, 184, 0.18);
  color: var(--muted);
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 6px;
  padding: 2px 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.link {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.85rem;
}

.link:hover {
  text-decoration: underline;
}
/* Tracker Visit Styles */

.visit-title {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: normal;
    word-break: break-word;
    margin-bottom: 6px;
}

.address-card {
    border: 1px solid #2c3440;
    border-radius: 10px;
    padding: 10px 12px;
    background: #0e1520;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-top: 6px;
}

.address-card div {
    margin-bottom: 2px;
}

.muted {
    color: #8a8f9c !important;
}
/* --- Visit card layout --- */

.visit-card {
    border-radius: 16px;
    border: 1px solid #1f2937;
    background: radial-gradient(circle at top left, #111827, #020617);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.visit-card-main {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.visit-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}

.visit-tracking {
    font-size: 0.75rem;
    color: #9ca3af;
}

.visit-status-pill {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* you can map your statuses to colors however you like */
.visit-status-created  { background: #0f172a; color: #e2e8f0; border: 1px solid #334155; }
.visit-status-confirmed{ background: #78350f; color: #fde68a; }
.visit-status-assigned { background: #1e3a8a; color: #bfdbfe; }
.visit-status-in_progress { background: #14532d; color: #bbf7d0; }
.visit-status-completed{ background: #065f46; color: #a7f3d0; }
.visit-status-revisit  { background: #7c2d12; color: #fed7aa; }
.visit-status-hold { background: #1f2937; color: #e2e8f0; }
.visit-status-canceled { background: #7f1d1d; color: #fecaca; }

.address-card {
    border-radius: 10px;
    border: 1px solid #1f2937;
    background-color: #020617;
    padding: 6px 8px;
    font-size: 0.8rem;
    line-height: 1.3;
    color: #e5e7eb;
}

.address-card div {
    margin-bottom: 1px;
}

.visit-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.78rem;
    color: #9ca3af;
}

.visit-meta-label {
    color: #6b7280;
}

.visit-progress {
    margin-top: 4px;
}

.visit-progress-bar-outer {
    height: 4px;
    border-radius: 999px;
    background: #111827;
    overflow: hidden;
}

.visit-progress-bar-inner {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #22c55e, #a3e635);
}

.visit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.visit-actions a {
    font-size: 0.75rem;
}
.edit-form-section {
  border-radius: 16px;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 12px 14px;
  margin-top: 16px;
}
.edit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.form-field label {
  color: #9ca3af;
}
.form-field input,
.form-field textarea {
  background-color: #020617;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 6px 8px;
  color: #e5e7eb;
  font-size: 0.85rem;
}
.form-field textarea {
  min-height: 80px;
  resize: vertical;
}
.edit-form-actions {
  margin-top: 12px;
  text-align: right;
}
.btn-primary {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #2563eb;
  background: #1d4ed8;
  color: #f9fafb;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary:hover {
  background: #1e40af;
}
/* Odoo vendor search dropdown */
.vendor-search-wrapper {
  position: relative;
}
.vendor-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 8px;
  margin-top: 2px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 20;
}
.vendor-suggestion-item {
  padding: 6px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid #0b1120;
}
.vendor-suggestion-item:last-child {
  border-bottom: none;
}
.vendor-suggestion-item:hover {
  background: #111827;
}
.vendor-suggestion-name {
  color: #e5e7eb;
}
.vendor-suggestion-sub {
  color: #9ca3af;
}
.task-input {
  width: 100%;
  background-color: #020617;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 4px 6px;
  color: #e5e7eb;
  font-size: 0.85rem;
}
.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #020617;
  border: 1px solid #1f2937;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
}
.info-column {
  margin-top: 8px;
  font-size: 0.85rem;
}
.info-label {
  color: #9ca3af;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.info-value {
  color: #e5e7eb;
}
.info-value.muted {
  color: #6b7280;
}
.visit-progress-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #020617;
  border: 1px solid #1f2937;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  /* width is set inline via style="width: XX%;" */
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.progress-label {
  font-size: 0.78rem;
  color: #e5e7eb;
  min-width: 32px;
  text-align: right;
}

  .log-list {
    display: flex;
    flex-direction: column;
    gap: 3px; /* very small gap between notes */
  }

  .log-item {
    border-radius: 6px;
    border: 1px solid #111827;
    background: #020617;
    padding: 4px 6px;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1px;
  }

  .log-actor {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .log-role-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    border: 1px solid #1f2937;
  }

  .log-role-admin {
    background: rgba(37, 99, 235, 0.15);
    border-color: #2563eb;
    color: #bfdbfe;
  }

  .log-role-engineer {
    background: rgba(22, 163, 74, 0.15);
    border-color: #16a34a;
    color: #bbf7d0;
  }

  .log-role-system {
    background: rgba(148, 163, 184, 0.15);
    border-color: #6b7280;
    color: #e5e7eb;
  }

  .log-timestamp {
    font-size: 0.65rem;
    color: #9ca3af;
    white-space: nowrap;
  }

  .log-message {
    white-space: pre-wrap;
    color: #d1d5db;
  }

  .log-toggle-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
  }

  .log-toggle-btn {
    cursor: pointer;
    border-radius: 999px;
    border: 1px solid #374151;
    background: #020617;
    color: #e5e7eb;
    font-size: 0.7rem;
    padding: 3px 8px;
  }
  .log-toggle-btn:hover {
    border-color: #60a5fa;
  }
  .map-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #0f172a;
    border: 1px solid #1e293b;
    color: #93c5fd;
    font-size: 0.8rem;
    text-decoration: none;
  }
  .map-link:hover {
    background: #1e293b;
    color: #bfdbfe;
    border-color: #3b82f6;
  }
  .site-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 12px;
    }
    .site-card {
      border-radius: 12px;
      border: 1px solid #e5e7eb;
      padding: 10px 12px;
      background: #ffffff;
    }
    .site-card-header {
      margin-bottom: 6px;
    }
    .site-title {
      font-weight: 600;
      font-size: 0.95rem;
    }
    .site-address-muted {
      font-size: 0.8rem;
      color: #6b7280;
    }
    .site-visit-list {
      list-style: none;
      padding-left: 0;
      margin: 0;
      font-size: 0.85rem;
    }
    .site-visit-item {
      border-top: 1px solid #f3f4f6;
      padding: 4px 0;
    }
    .site-visit-item:first-child {
      border-top: none;
    }
    .site-visit-main {
      display: flex;
      flex-direction: column;
    }
    .site-visit-link {
      font-weight: 500;
      text-decoration: none;
      color: #111827;
    }
    .site-visit-link:hover {
      text-decoration: underline;
    }
    .site-visit-date {
      font-size: 0.78rem;
      color: #6b7280;
    }
    .site-visit-meta {
      display: flex;
      gap: 6px;
      align-items: center;
      margin-top: 2px;
      font-size: 0.78rem;
    }
    .site-visit-engineer {
      color: #4b5563;
    }

    @media (max-width: 640px) {
      .site-grid {
        grid-template-columns: 1fr;
      }
    }
    .visit-name-link {
      color: #e5e7eb;
      text-decoration: none;
      font-weight: 500;
    }
    .visit-name-link:hover {
      text-decoration: underline;
    }
    .lock-switch {
      position: relative;
      display: inline-block;
      width: 38px;
      height: 20px;
    }

    .lock-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .lock-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #4b5563;
      transition: 0.2s;
      border-radius: 999px;
    }

    .lock-slider:before {
      position: absolute;
      content: "";
      height: 14px;
      width: 14px;
      left: 3px;
      top: 3px;
      background-color: #e5e7eb;
      transition: 0.2s;
      border-radius: 999px;
    }

    .lock-switch input:checked + .lock-slider {
      background-color: #22c55e;
    }

    .lock-switch input:checked + .lock-slider:before {
      transform: translateX(16px);
    }

    /* Dropdown styling */
    .dropdown-item {
      display: block;
      width: 100%;
      text-align: left;
      padding: 6px 10px;
      font-size: 13px;
      background: transparent;
      border: none;
      color: #e5e7eb;
      cursor: pointer;
      border-radius: 4px;
    }

    .dropdown-item:hover {
      background-color: #1e293b;
    }

    .dropdown-separator {
      height: 1px;
      margin: 4px 0;
      background-color: #334155;
    }
    .table-wrapper table tbody td {
      padding-top: 9px;
      padding-bottom: 9px;
    }
    .table-wrapper table tbody tr {
      border-radius: 6px;
      overflow: hidden;
      border-bottom: 1px solid #334155;
    }
    .page-container {
      max-width: 1280px;
      margin: 24px auto;
      padding: 0 16px 40px;
    }

    /* Shared header layout (visit + project) */
    .visit-header,
    .project-header {
      display: flex;
      justify-content: space-between;
      gap: 16px;
      align-items: flex-start;
      margin-bottom: 16px;
      flex-wrap: wrap;
    }

    /* Title style used on both visit + project headers */
    .visit-title-main,
    .project-title-main {
      font-size: 1.25rem;
      font-weight: 600;
      line-height: 1.3;
    }

    /* Right-side stacked actions (top-right) */
    .top-actions {
      text-align: right;
      display: flex;
      flex-direction: column;
      gap: 4px;
      align-items: flex-end;
      flex: 1 1 auto;
    }

    /* Small pill button */
    .btn-small,
    .btn-icon,
    .btn-primary,
    .btn-ghost {
      font-family: inherit;
    }

    .btn-small {
      display: inline-block;
      padding: 4px 10px;
      border-radius: 999px;
      border: 1px solid #374151;
      font-size: 0.78rem;
      text-decoration: none;
      color: #e5e7eb;
      background: #111827;
      cursor: pointer;
      white-space: nowrap;
    }

    .btn-small:hover {
      border-color: #60a5fa;
    }

    /* Ghost button (if you need it) */
    .btn-ghost {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 5px 12px;
      border-radius: 999px;
      border: 1px solid #374151;
      background: #020617;
      color: #e5e7eb;
      font-size: 0.8rem;
      cursor: pointer;
      text-decoration: none;
      white-space: nowrap;
    }

    .btn-ghost:hover {
      border-color: #60a5fa;
    }

    /* Danger variant for delete buttons */
    .btn-small.btn-danger {
      background: #7f1d1d;
      border-color: #b91c1c;
      color: #fecaca;
    }
    .btn-small.btn-danger:hover {
      background: #991b1b;
    }

    /* Secondary variant if needed */
    .btn-small.btn-secondary {
      background: #020617;
      border-color: #1f2937;
      color: #cbd5e1;
    }
    .btn-small.btn-secondary:hover {
      border-color: #4b5563;
    }
