/* static/css/app.css */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: rgba(16,24,40,0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #23456e; /* from your logo */
  --accent-soft: rgba(35,69,110,0.12);
  --radius-lg: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 54px;
  background: #23456e;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.topbar-right {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.user-pill {
  background: rgba(255,255,255,0.12);
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .875rem;
}

.btn-sm {
  background: rgba(255,255,255,0.1);
  padding: .35rem .75rem;
  border-radius: .5rem;
  color: #fff;
  text-decoration: none;
  font-size: .8rem;
}

.btn-sm.btn-primary {
  background: #fff;
  color: #23456e;
  font-weight: 600;
}

.btn-sm.btn-danger {
  background: rgba(255,99,99,0.25);
}

.icon-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: .5rem;
  height: 32px;
  width: 32px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 1rem;
  position: fixed;
  top: 54px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.side-link {
  text-decoration: none;
  padding: .55rem .7rem;
  border-radius: .6rem;
  color: #1f2937;
  display: block;
  font-size: .9rem;
}

.side-link:hover,
.side-link:focus {
  background: var(--accent-soft);
  color: #0f172a;
}

.side-label {
  margin-top: .7rem;
  font-size: .65rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .08em;
}

.content {
  flex: 1;
  padding: 1.3rem 1.3rem 2rem;
  margin-left: 230px;
  margin-top: 54px;
}

.flash-container {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}

.flash {
  padding: .7rem 1rem;
  border-radius: .6rem;
  background: #dbeafe;
  border: 1px solid rgba(59,130,246,0.35);
  color: #0f172a;
  font-size: .85rem;
}

.flash-success { background: #ecfdf3; border-color: rgba(22,163,74,.35); }
.flash-danger { background: #fef2f2; border-color: rgba(248,113,113,.35); }
.flash-warning { background: #fffbeb; border-color: rgba(252,211,77,.35); }

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15,23,42,0.03);
  box-shadow: 0 10px 30px rgba(15,23,42,0.05);
  padding: 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  margin-bottom: .3rem;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(15,23,42,0.1);
  border-radius: .5rem;
  padding: .5rem .6rem;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 80px;
}

.btn-primary-lg {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #23456e;
  color: #fff;
  border: none;
  border-radius: .6rem;
  padding: .6rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

.table-card {
  width: 100%;
  border-collapse: collapse;
}

.table-card th,
.table-card td {
  padding: .6rem .4rem;
  border-bottom: 1px solid rgba(148,163,184,0.2);
  text-align: left;
  font-size: .8rem;
}

.badge {
  padding: .1rem .4rem;
  border-radius: .4rem;
  font-size: .63rem;
}

.badge.green { background: #ecfdf3; color: #166534; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.blue { background: #eff6ff; color: #1d4ed8; }

@media (max-width: 880px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease-out;
    z-index: 80;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .content {
    margin-left: 0;
  }
  .topbar-right .user-pill {
    display: none;
  }
}


.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #fff;
  border: 1px solid rgba(35,69,110,0.35);
  color: #23456e;
  border-radius: .5rem;
  padding: .35rem .7rem;
  font-size: .75rem;
  cursor: pointer;
}
.btn-outline:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.preview-pop {
  position: fixed;
  pointer-events: none;
  border: 1px solid rgba(15,23,42,0.15);
  background: #fff;
  border-radius: .5rem;
  padding: .25rem;
  box-shadow: 0 10px 40px rgba(15,23,42,0.15);
  z-index: 9999;
  display: none;
}
.preview-pop img {
  max-width: 180px;
  border-radius: .35rem;
}
.link-btn {
  background:none;
  border:none;
  color:#23456e;
  cursor:pointer;
  font-size:.75rem;
  padding:0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* mobile-friendly form layout */
.card form,
.form-grid {
  gap: 0.75rem;
}

/* section titles */
.section-title {
  margin-top: 1.25rem;
  margin-bottom: .35rem;
  font-weight: 600;
  font-size: 1rem;
}
.section-hint {
  margin-bottom: .75rem;
  font-size: .72rem;
  color: #64748b;
}

/* discovery block */
.questionnaire {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.question-row {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: .9rem;
  padding: .55rem .65rem .65rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.question-row label {
  font-size: .72rem;
  color: #0f172a;
  font-weight: 500;
}
.question-row .input {
  width: 100%;
  font-size: .8rem;
}

/* general input */
.input,
textarea {
  width: 100%;
}

/* make the whole add-visit page single column on small screens */
@media (max-width: 768px) {
  .form-grid {
    display: flex !important;
    flex-direction: column;
  }
  .form-grid > div {
    width: 100%;
  }
  #map {
    width: 100%;
  }
  .btn-primary-lg {
    width: 100%;
    justify-content: center;
  }
}

.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid #e2e8f0;
  padding: .4rem .75rem 0;
  background: #f8fafc;
  border-radius: .75rem .75rem 0 0;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: .5rem .85rem;
  font-size: .78rem;
  cursor: pointer;
  color: #475569;
  border-bottom: 2px solid transparent;
}
.tab-btn.active {
  color: #0f172a;
  border-bottom-color: #23456e;
  font-weight: 600;
}
.tab-panel {
  display: none;
  padding-top: .75rem;
}
@media (max-width: 768px) {
  .tabs {
    overflow-x: auto;
  }
  .tab-btn {
    white-space: nowrap;
  }
}


