/* Amphia internal tools — brand: red #FF2A2A, black, white, #DCDCDC.
   Headings: Archivo expanded caps. Body: Inter. Squared strokes, 45° motif. */

:root {
  --red: #FF2A2A;
  --pink: #FF3089;
  --mid: #FF2D5A;
  --black: #000000;
  --white: #FFFFFF;
  --gray: #DCDCDC;
  --gray-soft: #F3F3F3;
  --text-dim: #666666;
  --gradient: radial-gradient(120% 120% at 50% 40%, #FF2E71 0%, #FF2D5A 45%, #FF2A2A 80%);
  --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--black);
  background: var(--white);
}

h1, h2, h3, .display {
  font-family: 'Archivo', 'Space Grotesk', system-ui, sans-serif;
  font-stretch: 125%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }

a { color: inherit; }

/* ── Shell ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-top { border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.sidebar .logo { padding: 22px 18px 26px; }
.sidebar .logo img { width: 140px; display: block; }

/* Hamburger — mobile only */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--white);
  transition: transform 0.18s, opacity 0.18s;
}
.sidebar.open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar.open .nav-toggle span:nth-child(2) { opacity: 0; }
.sidebar.open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav { display: flex; flex-direction: column; padding: 14px 0; flex: 1; }

.nav a {
  padding: 11px 18px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav a:hover { color: var(--white); background: rgba(255, 255, 255, 0.06); }
.nav a.active {
  color: var(--white);
  border-left-color: var(--red);
  background: rgba(255, 42, 42, 0.12);
}
.nav .count {
  margin-left: auto;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.sidebar .user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.sidebar .user form { display: inline; }
.sidebar .user button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.sidebar .user button:hover { border-color: var(--red); color: var(--white); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 28px 32px; max-width: 1100px; width: 100%; }
.page.wide { max-width: none; padding: 0; display: flex; flex-direction: column; flex: 1; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* ── Components ────────────────────────── */
.btn {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border: 2px solid var(--black);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--gray-soft); }

.btn-primary { background: var(--black); color: var(--white); }
.btn-primary:hover { background: #1a1a1a; }

.btn-red { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-red:hover { background: var(--gradient); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-ghost { border-color: var(--gray); }

.card {
  border: 1px solid var(--gray);
  background: var(--white);
  padding: 18px 20px;
}

.card h2 { margin-bottom: 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  border: 1px solid var(--gray);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 34px; height: 4px;
  background: var(--red);
  transform: skewX(-45deg) translateX(8px);
}
.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}
.stat .value {
  font-family: 'Archivo', sans-serif;
  font-stretch: 125%;
  font-size: 30px;
  font-weight: 800;
  margin-top: 4px;
}
.stat .value small { font-size: 14px; color: var(--text-dim); font-weight: 600; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border: 1px solid var(--black);
  background: var(--white);
}
.badge.new { border-color: var(--gray); color: var(--text-dim); }
.badge.contacted { background: var(--black); color: var(--white); }
.badge.visited { background: var(--gray); border-color: var(--gray); color: var(--black); }
.badge.interested { background: var(--red); border-color: var(--red); color: var(--white); }
.badge.not_interested { border-color: var(--gray); color: #aaa; text-decoration: line-through; }
.badge.pending { border-color: var(--black); }
.badge.approved { background: var(--black); color: var(--white); }
.badge.rejected { background: var(--gray-soft); border-color: var(--gray); color: var(--text-dim); }

/* Forms */
form .field { margin-bottom: 14px; }
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 5px;
}
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="url"], input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--red);
  outline-offset: -1px;
  border-color: var(--red);
}
.errorlist { color: var(--red); font-size: 12px; list-style: none; margin: 4px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 10px;
  border-bottom: 2px solid var(--black);
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--gray); vertical-align: middle; }
table.data tr:hover td { background: var(--gray-soft); }
.muted { color: var(--text-dim); }

/* Messages */
.messages { margin-bottom: 16px; }
.msg { padding: 10px 14px; border-left: 3px solid var(--red); background: var(--gray-soft); margin-bottom: 6px; }

/* ── Login ─────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box { width: 340px; }
.login-box .logo { width: 200px; margin-bottom: 36px; }
.login-box label { color: rgba(255, 255, 255, 0.7); }
.login-box input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--white);
}
.login-box .btn-red { width: 100%; margin-top: 8px; padding: 12px; }
.login-box .error { color: var(--pink); font-size: 12px; margin-bottom: 12px; }
.login-orb {
  position: fixed;
  right: -120px;
  bottom: -120px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: var(--gradient);
  opacity: 0.9;
}

/* ── Prospecting map layout ────────────── */
.prospect { display: flex; flex: 1; min-height: 0; height: calc(100vh); }
.prospect-side {
  width: 380px;
  flex-shrink: 0;
  border-right: 1px solid var(--gray);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.prospect-filters {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.prospect-filters input[type="text"] { flex: 1 1 100%; }
.prospect-filters select { flex: 1; width: auto; }
.prospect-list { flex: 1; overflow-y: auto; }
.biz-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-soft);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.biz-row:hover { background: var(--gray-soft); }
.biz-row .name { font-weight: 600; font-size: 13px; }
.biz-row .meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.prospect-map { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

.panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 340px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  background: var(--white);
  border: 2px solid var(--black);
  z-index: 1000;
  padding: 16px;
}
.panel .close { float: right; cursor: pointer; font-size: 16px; border: none; background: none; }
.panel h2 { text-transform: none; letter-spacing: 0; font-stretch: 110%; font-size: 17px; }
.panel .sub { font-size: 12px; color: var(--text-dim); margin: 3px 0 12px; }
.status-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.status-btn {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid var(--gray);
  background: var(--white);
  cursor: pointer;
}
.status-btn.active { background: var(--red); border-color: var(--red); color: var(--white); }
.note {
  border-left: 3px solid var(--gray);
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 12px;
}
.note.system { color: var(--text-dim); font-style: italic; border-left-style: dashed; }
.note .who { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-top: 3px; }
.note-form textarea { min-height: 56px; margin-bottom: 6px; }

/* Map picker on business form */
#picker-map { height: 300px; border: 1px solid var(--gray); margin-bottom: 14px; }

/* Time tracking */
.clock-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--black);
  color: var(--white);
  margin-bottom: 22px;
}
.clock-bar .since { font-size: 12px; color: rgba(255,255,255,0.6); }
.clock-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
/* Timesheet grid */
table.timesheet {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 860px;
}
.timesheet th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 6px;
  border-bottom: 2px solid var(--black);
  text-align: left;
}
.timesheet th.ts-today { background: var(--black); color: var(--white); }
.timesheet .ts-hour {
  width: 58px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-align: right;
  padding-right: 8px;
  vertical-align: top;
}
.timesheet td.ts-slot { border: 1px solid var(--gray); padding: 0; height: 34px; }
.timesheet td.ts-slot.ts-today { background: var(--gray-soft); }
.timesheet th.ts-weekend { color: #B0B0B0; background: var(--gray-soft); }
.timesheet td.ts-slot.ts-weekend { background: #F7F7F7; }
.timesheet td.ts-slot.ts-weekend .ts-cell:not(.filled) { opacity: 0.75; }
.ts-cell {
  min-height: 34px;
  padding: 7px 8px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-cell .ts-plus { color: transparent; font-weight: 700; }
.ts-cell:hover .ts-plus { color: var(--red); }
.ts-cell:hover { background: var(--gray-soft); }
.ts-cell.filled { border-left: 3px solid var(--red); font-weight: 500; }
.ts-cell.editing { padding: 0; }
.ts-cell.editing input {
  width: 100%;
  height: 34px;
  border: none;
  outline: 2px solid var(--red);
  outline-offset: -2px;
  font-size: 12px;
  padding: 0 8px;
}
.timesheet .ts-totals td {
  padding: 8px 8px;
  font-weight: 700;
  font-size: 12px;
  border-top: 2px solid var(--black);
}
.ts-cell.readonly { cursor: default; }
.ts-cell.readonly:hover { background: inherit; }
.ts-cell.selected {
  outline: 2px solid var(--red);
  outline-offset: -2px;
  background: #FFECEC;
}

.ts-banner {
  padding: 12px 16px;
  margin-bottom: 14px;
  border-left: 4px solid var(--black);
  background: var(--gray-soft);
  font-size: 13px;
}
.ts-banner.approved { border-left-color: var(--black); background: var(--gray); }
.ts-banner.rejected { border-left-color: var(--red); background: #FFECEC; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* Dashboard */
.greeting { margin-bottom: 20px; }
.greeting h1 { margin-bottom: 2px; }
.greeting p { font-size: 13px; }

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  vertical-align: baseline;
}
.swatch.red { background: var(--red); }

.pipe-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pipe-label {
  width: 110px;
  flex-shrink: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  text-align: right;
}
.pipe-track { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.pipe-bar {
  display: block;
  height: 14px;
  background: #1A1A1A;
  border-radius: 0 4px 4px 0;
  min-width: 2px;
  flex-shrink: 0;
  max-width: calc(100% - 44px);
}
.pipe-bar.accent { background: var(--red); }
.pipe-n { font-size: 12px; font-weight: 700; }

.multiples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.multiple { border: 1px solid var(--gray-soft); padding: 10px 12px 6px; }
.multiple-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 4px;
}

.chart-table { margin-top: 10px; font-size: 12px; }
.chart-table summary { cursor: pointer; color: var(--text-dim); }
.chart-table table { margin-top: 8px; max-width: 300px; }

/* Team / org chart */
.org-tree { max-width: 640px; }
.org-node + .org-node { margin-top: 12px; }
.org-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--gray);
  padding: 12px 16px;
  background: var(--white);
}
.org-avatar {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Archivo', sans-serif;
  font-stretch: 125%;
  font-weight: 800;
  font-size: 16px;
}
.org-name { font-weight: 700; font-size: 14px; }
.org-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-top: 2px;
}
.org-children {
  margin: 12px 0 0 18px;
  padding-left: 18px;
  border-left: 2px solid var(--red);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 1500; /* above Leaflet panes/controls */
  }
  .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
    padding-right: 8px;
  }
  .sidebar .logo { padding: 14px 16px; }
  .sidebar .logo img { width: 108px; }
  .nav-toggle { display: flex; }
  /* Collapsed: only the top bar shows */
  .sidebar .nav, .sidebar .user { display: none; }
  .sidebar.open .nav {
    display: flex;
    flex-direction: column;
    padding: 6px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }
  .sidebar.open .nav a {
    padding: 14px 18px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .sidebar.open .nav a:last-child { border-bottom: none; }
  .sidebar.open .user {
    display: flex;
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
  }
  .sidebar.open .user button { padding: 8px 16px; }
  .prospect { flex-direction: column; height: auto; }
  .prospect-side { width: 100%; max-height: 40vh; }
  .prospect-map { min-height: 55vh; }
  .form-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .panel { width: calc(100% - 28px); max-width: 340px; }
  .page { padding: 18px 16px; }
  .page-head { flex-wrap: wrap; }
  /* Wide data tables scroll sideways instead of breaking the page */
  .card table.data { display: block; overflow-x: auto; }
  .card table.data th, .card table.data td { white-space: nowrap; }
  .card .form-grid input, .card .form-grid select { min-width: 0; }
}
