/* Kinpany Design Tokens (Product Experience v1) - see
   kinpany-back-office-pwa/style.css's own identical block for the
   rationale; this app mirrors that one exactly, token-for-token. */
:root {
  color-scheme: light dark;
  --border: #ddd6ec;
  --muted: #6b6478;
  --accent: #7e14ff;
  --accent-contrast: #fff;
  --danger: #b3261e;
  --warning: #92600a;
  --success: #1e7b34;
  --bg-subtle: #f6f4fb;
  --bg: #fff;
  --text: #1a1625;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(30, 10, 60, 0.06), 0 4px 10px rgba(30, 10, 60, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --border: #362f47;
    --muted: #a79fc0;
    --accent: #b98bff;
    --accent-contrast: #1a0f2e;
    --bg-subtle: #211c2e;
    --bg: #16121f;
    --text: #eee6fb;
  }
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 { font-size: 1.1rem; margin: 0; }

.brand { display: inline-flex; align-items: center; gap: 0.5rem; }
.brand__mark { display: block; flex: none; }
.brand__product { font-weight: 400; color: var(--muted); }

#top-bar { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
#top-bar nav { display: flex; gap: 0.4rem; }
#top-bar nav button {
  background: transparent;
  color: var(--accent);
  border: 1px solid transparent;
}
#top-bar nav button.nav-active {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-weight: 600;
}

main { padding: 1.25rem; max-width: 1040px; margin: 0 auto; }

form.stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 320px; }

/* Product Experience v1 (section 6, branding alignment) - identical to
   kinpany-back-office-pwa/style.css's own auth-card. */
.auth-card {
  max-width: 380px;
  margin: 10vh auto 0;
  padding: 2rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle);
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-card__mark { display: block; margin: 0 auto 0.75rem; }
.auth-card h2 { margin: 0 0 0.5rem; }
.auth-card .stack { max-width: none; text-align: left; margin-top: 1.25rem; }

label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

textarea { width: 100%; display: block; margin: 0.5rem 0; resize: vertical; }

.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

button.secondary { background: transparent; color: var(--accent); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
.toolbar h2 { margin: 0; }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.5rem 0; }
.row input, .row select { flex: 1 1 180px; }

.panel { border: 1px solid var(--border); border-radius: 6px; padding: 0.9rem; margin: 1rem 0; }
.panel h3 { margin-top: 0; }

.error-banner {
  background: #fdecea;
  color: var(--danger);
  border: 1px solid #f5c6c2;
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.notice-banner {
  background: #e6f4ea;
  color: #1e7b34;
  border: 1px solid #bfe3c9;
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

/* Product Experience v1 (section 4/7, responsive) - same reasoning as
   kinpany-back-office-pwa/style.css's own identical rule. */
@media (max-width: 720px) {
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--bg-subtle); }
li.clickable { cursor: pointer; padding: 0.2rem 0; }
li.clickable:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; }
.badge.status-open { background: #e6f4ea; color: #1e7b34; }
.badge.status-completed { background: #e8eefb; color: var(--accent); }
.badge.status-cancelled { background: #eee; color: var(--muted); }
.badge.status-pending { background: #fdf3e3; color: var(--warning); }

.fields dt { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.fields dd { margin: 0 0 0.5rem 0; }

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

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1.25rem; }
.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.stat-tile:disabled { cursor: default; opacity: 1; }
.stat-tile__value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-tile__label { font-size: 0.85rem; color: var(--muted); }

/* Property Intelligence-specific: property grid/cards */
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.9rem; margin: 0.75rem 0; }
.property-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem;
  background: #fff;
  cursor: pointer;
  color: inherit;
}
.property-card:hover { border-color: var(--accent); }
.property-card__title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.2rem; }
.property-card__label { margin: 0; font-size: 1rem; }
.property-card__address { margin: 0 0 0.35rem 0; color: var(--muted); font-size: 0.9rem; }
.property-card__meta { display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }

/* Internal-vs-client-facing distinction (MVP requirement #14) */
.notes-panel { border-radius: 6px; padding: 0.9rem; margin: 0.75rem 0; }
.notes-panel--client { border: 1px solid #bcd3f6; background: #f3f7fe; }
.notes-panel--internal { border: 2px dashed var(--warning); background: #fffaf0; }
.notes-panel h4 { margin: 0 0 0.3rem 0; display: flex; align-items: center; gap: 0.4rem; }
.notes-panel textarea { min-height: 4.5rem; }
.scope-tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; padding: 0.05rem 0.4rem; border-radius: 3px; font-weight: 700; }
.scope-tag--client { background: var(--accent); color: #fff; }
.scope-tag--internal { background: var(--warning); color: #fff; }

/* Timeline (history of Work Orders per Property) */
.timeline { list-style: none; margin: 0.75rem 0; padding: 0; border-left: 2px solid var(--border); }
.timeline__entry { position: relative; padding: 0 0 1.1rem 1.1rem; }
.timeline__entry::before {
  content: "";
  position: absolute;
  left: -0.42rem;
  top: 0.2rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}
.timeline__entry--cancelled::before { background: var(--muted); }
.timeline__header { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.timeline__date { font-weight: 600; }
.timeline__body { margin-top: 0.3rem; }
.timeline__body button.secondary { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.evidence-gallery { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.evidence-tile { width: 140px; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--bg-subtle); }
.evidence-tile img, .evidence-tile video { display: block; width: 100%; height: 100px; object-fit: cover; background: #000; }
.evidence-tile__meta { font-size: 0.72rem; color: var(--muted); padding: 0.2rem 0.35rem; }

.step-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.step-list button { font-size: 0.82rem; padding: 0.3rem 0.6rem; }
.step-list button.secondary.step-active { background: var(--bg-subtle); border-color: var(--accent); font-weight: 600; }

.search-bar { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.search-bar input { flex: 1 1 auto; }
