/* ==========================================================================
   JollyProp Operations Portal — visual system
   Source of truth: docs/UI_DESIGN_REFERENCE.md
   ========================================================================== */

:root {
  --ink: #111827;
  --muted: #64748b;
  --line: #e5e7eb;

  --paper: #ffffff;
  --soft: #f7f8f5;

  --green: #1f6f5c;
  --green-dark: #154d40;
  --green-soft: #e8f2ee;

  --lime: #dff36b;

  --navy: #101a27;
  --navy-soft: #182535;

  --warning: #f59e0b;
  --warning-soft: #fff5dd;
  --success-soft: #e7f7ec;
  --blue-gray-soft: #f1f5f9;

  --danger: #d64545;

  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-soft: 0 1px 2px rgba(16, 26, 39, 0.04);
  --shadow-elevated: 0 8px 24px rgba(16, 26, 39, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--soft);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ==========================================================================
   App shell
   ========================================================================== */

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

/* --- Sidebar ------------------------------------------------------------ */

.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* --- Navigation --------------------------------------------------------- */

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--soft); color: var(--ink); }
.nav-item.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

/* --- Workspace footer --------------------------------------------------- */

.workspace {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.workspace-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.workspace-provider {
  font-size: 12px;
  color: var(--muted);
}

/* --- Content column ----------------------------------------------------- */

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- Top bar (utility) -------------------------------------------------- */

.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 40px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.org {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.integration {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.integration::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.auth-area { display: flex; align-items: center; gap: 12px; }
.login-form { display: flex; gap: 8px; }
.login-form input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  background: var(--paper);
  color: var(--ink);
}
.login-form input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-email { color: var(--muted); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 700;
  font-size: 13px;
}

/* --- Main --------------------------------------------------------------- */

.main {
  flex: 1;
  padding: 40px 40px 56px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.view { display: block; }

/* ==========================================================================
   Page headers
   ========================================================================== */

.page-head { margin-bottom: 28px; }

.eyebrow {
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green);
  margin-bottom: 8px;
}

.page-title {
  font-family: "Manrope", sans-serif;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.lede {
  font-size: 15px;
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 560px;
}

.view-head { margin-bottom: 20px; }
.view-head h2 {
  font-family: "Manrope", sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}
.hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

/* Section heading with count badge */
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.section-head h3 {
  font-family: "Manrope", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
.section-head .sub { font-size: 13px; color: var(--muted); }

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.count-badge.amber { background: var(--warning-soft); color: #a16207; }
.count-badge.green { background: var(--green-soft); color: var(--green-dark); }

/* ==========================================================================
   Status pills
   ========================================================================== */

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.green { background: #e7f4ef; color: var(--green); }
.status-pill.amber { background: var(--warning-soft); color: #a16207; }
.status-pill.blue { background: var(--blue-gray-soft); color: #52607a; }
.status-pill.neutral { background: #eef2f7; color: var(--muted); }
.status-pill.red { background: #fdecec; color: var(--danger); }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.card h2 { margin: 0 0 8px; font-size: 20px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }

.gate { display: flex; justify-content: center; padding-top: 60px; }
.gate-card { max-width: 420px; text-align: center; }
.gate-card h2 { font-size: 24px; }

/* ==========================================================================
   Dashboard summary metrics
   ========================================================================== */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.summary-card {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-value {
  font-family: "Manrope", sans-serif;
  font-size: 34px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.summary-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* Dominant "needs your attention" metric — dark operational surface */
.summary-card.dark {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.summary-card.dark .summary-value { color: #fff; }
.summary-card.dark .summary-label { color: #b8c2cf; }
.summary-link {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--lime);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: "DM Sans", sans-serif;
}
.summary-link:hover { text-decoration: underline; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ==========================================================================
   Lists & rows
   ========================================================================== */

.list { display: flex; flex-direction: column; gap: 12px; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 14px;
}
.row-main { font-weight: 600; }

/* ==========================================================================
   Attention queue
   ========================================================================== */

.attention-item {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.attention-item.owner-approval { border-color: #f5dea3; }

.attention-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.attention-title { font-weight: 700; font-size: 15px; }
.attention-meta { font-size: 13px; color: var(--muted); }

.attention-reason {
  font-size: 14px;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid #eef2ef;
  border-radius: 14px;
  padding: 12px 14px;
}

/* Nested context boxes (ticket-meta) */
.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.context-box {
  background: #fbfcfb;
  border: 1px solid #e8ede9;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.context-label { font-size: 12px; color: var(--muted); }
.context-value { font-size: 14px; font-weight: 700; }

.controls { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* ==========================================================================
   Workflow cards
   ========================================================================== */

.workflow-card {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.workflow-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.workflow-title { font-weight: 700; font-size: 15px; }
.workflow-meta { font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Case cards (properties, people, vendors, rules, agents)
   ========================================================================== */

.case-card {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.case-title { font-weight: 700; font-size: 15px; }
.case-meta { font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Buttons
   ========================================================================== */

button {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
button.primary { background: var(--green); color: #fff; }
button.primary:hover { background: var(--green-dark); }
button.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #cbd5e1;
}
button.secondary:hover { border-color: var(--muted); }
button.danger { background: var(--paper); color: var(--danger); border: 1px solid #f3c1c1; }
button.danger:hover { background: #fdecec; }

/* ==========================================================================
   Filters & tabs
   ========================================================================== */

.filters { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  background: var(--paper);
  color: var(--ink);
}
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.tabs { display: flex; gap: 8px; margin-top: 12px; }
.tab {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
}
.tab.active { background: var(--green); color: #fff; border-color: var(--green); }

/* ==========================================================================
   Maintenance detail
   ========================================================================== */

.case-header { margin-bottom: 20px; }
.case-header .eyebrow { margin-bottom: 6px; }
.case-header h2 {
  font-family: "Manrope", sans-serif;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.case-header .case-meta { font-size: 14px; }
.case-header .controls { margin-top: 16px; }

/* Current status panel */
.status-panel {
  background: #f7fbf8;
  border: 1px solid #dbe6df;
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 16px;
}
.status-panel .eyebrow { margin-bottom: 6px; }
.status-panel h3 {
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
}
.status-panel p { margin: 0; font-size: 15px; color: var(--ink); }

/* Case context metrics */
.context-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.context-metrics .context-box { background: #fbfcfb; border: 1px solid #e8ede9; border-radius: 14px; padding: 12px 14px; }

/* Workflow progress */
.workflow-progress {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #edf2ef;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fbfcfb;
  border: 1px solid #eef2ef;
  border-radius: 14px;
  padding: 10px 14px;
}
.stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: #eef2f7;
  color: var(--muted);
}
.stage-label { font-size: 14px; font-weight: 600; }
.stage-row.completed { background: #f8faf8; }
.stage-row.completed .stage-num { background: #dff1e8; color: var(--green); }
.stage-row.current { background: #eff8f4; border-color: #cde6d8; }
.stage-row.current .stage-num { background: var(--green); color: #fff; }

/* Approval box */
.approval-box {
  background: #fbfcfb;
  border: 1px solid #e8ede9;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.approval-box h3 { margin: 0 0 12px; font-size: 16px; }
.approval-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* Policy line */
.policy-line {
  background: #fff8e8;
  border: 1px solid #f5dea3;
  border-radius: 14px;
  padding: 12px 16px;
  color: #8a5a00;
  font-size: 14px;
  margin-bottom: 16px;
}

/* Activity timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #edf1ee;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-soft);
  border: 2px solid var(--green);
  margin-top: 5px;
  flex-shrink: 0;
}
.timeline-time { font-size: 12px; color: var(--muted); font-weight: 600; }
.timeline-title { font-size: 14px; font-weight: 700; }
.timeline-detail { font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Empty & loading states
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed #d7ddd8;
  border-radius: var(--radius-md);
}
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.empty-state.error h3 { color: var(--danger); }
.empty-state.error { border-color: #f3c1c1; }

.loading-card {
  background: var(--paper);
  border: 1px solid #e7ece8;
  border-radius: var(--radius-md);
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 100;
  box-shadow: var(--shadow-elevated);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

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

@media (max-width: 900px) {
  .sidebar { width: 220px; padding: 20px 12px; }
  .main { padding: 28px 24px 48px; }
  .topbar { padding: 0 24px; }
  .integration { display: none; }
}

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    flex: 1;
  }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .workspace { display: none; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .login-form { flex-wrap: wrap; }
}
