:root {
  --bg: #f7f8fb;
  --bg-alt: #ffffff;
  --surface: #ffffff;
  --border: #e4e7ee;
  --text: #12151c;
  --text-dim: #565f74;
  --accent: #2f5fd6;
  --accent-dim: #dce6ff;
  --danger: #c62828;
  --danger-bg: #fdecea;
  --warning: #a15c00;
  --warning-bg: #fff3da;
  --radius: 12px;
}

:root[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-alt: #10141d;
  --surface: #151a24;
  --border: #232a38;
  --text: #e9edf5;
  --text-dim: #9aa4b8;
  --accent: #4f8dff;
  --accent-dim: #1c3a6e;
  --danger: #ff6b6b;
  --danger-bg: #3a1a1a;
  --warning: #ffb454;
  --warning-bg: #3a2a10;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}
a { color: var(--accent); }

/* Full banner image, with header_extra/theme-toggle overlaid on top and
   the left ~70% (icon + wordmark, per the banner's own layout) doubling
   as the home link - same treatment as site/css/style.css's header, see
   that file's comment for why. Source: app/issynow_app/static/banner.jpg
   (untouched original also kept in site/img/originals/). */
.app-header.banner-header {
  position: relative;
  padding: 0;
  background: rgb(24, 19, 82);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.banner-image {
  width: 100%;
  height: 92px;
  /* contain, not cover - see site/css/style.css's comment on the same
     property for why. */
  object-fit: contain;
  object-position: left center;
  display: block;
}
.banner-home-link {
  position: absolute;
  inset: 0;
  width: 70%;
  z-index: 1;
}
.header-right {
  position: absolute;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 10, 20, 0.45);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.header-right .btn-ghost {
  background: rgba(10, 10, 20, 0.45);
  backdrop-filter: blur(6px);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--warning-bg);
  color: var(--warning);
  border-bottom: 1px solid var(--warning);
  font-weight: 600;
  font-size: 0.9rem;
}
.impersonation-banner form { margin: 0; }

.app-main { display: flex; justify-content: center; padding: 48px 20px; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.auth-card-wide { max-width: 440px; text-align: center; }

h1 { font-size: 1.4rem; margin: 0 0 6px; }
.muted { color: var(--text-dim); font-size: 0.92rem; margin: 0 0 20px; }
.muted strong { color: var(--text); }
.auth-switch { text-align: center; margin: 20px 0 0; }
.auth-switch a { font-weight: 600; }

form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="tel"],
form input[type="date"],
form input[type="number"],
form select,
form textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
form textarea { resize: vertical; min-height: 5rem; }
form input:focus, form select:focus, form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; width: 100%; margin-top: 22px; }
.btn-ghost { background: transparent; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
.checkbox-row input { width: auto; }
.muted.small { font-size: 0.78rem; margin: 6px 0 0; }

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.form-note {
  background: var(--accent-dim);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.qr-wrap { display: flex; justify-content: center; margin: 18px 0; }
.qr-wrap img { background: #fff; padding: 10px; border-radius: 8px; }
.manual-entry { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 6px; }
.manual-entry code { display: block; margin-top: 8px; word-break: break-all; background: var(--bg-alt); padding: 8px; border-radius: 6px; }

.modules-wrap { width: 100%; max-width: 960px; }
.module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.module-card {
  display: flex;
  flex-direction: column;
  height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.module-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.module-card-head { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.module-card-head h3 { margin: 0; font-size: 1.1rem; }
.module-card-open { font-size: 0.8rem; font-weight: 600; color: var(--accent); }
.module-card-desc { color: var(--text-dim); font-size: 0.85rem; margin: 4px 0 16px; flex-shrink: 0; }
/* Every card is a fixed, equal height (above) - whatever's below the
   head/desc (a preview list, an empty-state message, or - the Staff
   card - a list plus an inline form) lives in this scrollable region
   instead of stretching the card to fit, so a long list or a busy form
   never makes one card taller than its neighbors. Mouse wheel/trackpad
   scroll works on this div natively; no extra JS needed. */
.module-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* Brand-colored scrollbar (same --accent as buttons/links/badges
     everywhere else) instead of the browser's default gray, so it reads
     as part of the design rather than a generic OS control. Firefox
     uses scrollbar-color; everything else (Chrome/Edge/Safari) needs
     the -webkit- pseudo-elements below - there's no single standard
     property that covers both yet. */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.module-card-body::-webkit-scrollbar { width: 8px; }
.module-card-body::-webkit-scrollbar-track { background: transparent; }
.module-card-body::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 999px;
}

.module-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.module-preview-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.module-preview-list li:last-child { border-bottom: none; }
.preview-who { font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.preview-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
}
.preview-snippet {
  font-size: 0.8rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- repairs --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent-dim);
  color: var(--accent);
  white-space: nowrap;
}
.status-badge.is-completed { background: var(--border); color: var(--text-dim); }
.status-badge.is-cancelled { background: var(--danger-bg); color: var(--danger); }
.status-badge.is-priority { background: var(--danger-bg); color: var(--danger); }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.filters select, .filters input { width: auto; }

.repairs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.repairs-table th, .repairs-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.repairs-table th {
  background: var(--bg-alt);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.repairs-table tbody tr:last-child td { border-bottom: none; }
.repairs-table tbody tr:hover { background: var(--bg-alt); }
.repairs-table a { color: var(--text); text-decoration: none; }
.repairs-table a:hover { color: var(--accent); }

.table-scroll { overflow-x: auto; }
.table-scroll .repairs-table { min-width: 640px; }

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 52rem) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.detail-card h2 { font-size: 1rem; margin: 0 0 14px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 0.9rem; }
.detail-row dt { color: var(--text-dim); }
.detail-row dd { margin: 0; text-align: right; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 0 10px 18px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
  position: relative;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline .timeline-meta { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

/* --- invoices --- */
.invoice-sheet {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.invoice-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.invoice-brand { font-weight: 700; font-size: 1.1rem; }
.invoice-meta { min-width: 200px; }
.invoice-meta .detail-row { padding: 2px 0; }
.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.invoice-parties h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 0 0 8px; }
.invoice-parties p { margin: 0; color: var(--text); font-size: 0.92rem; }
@media (max-width: 40rem) {
  .invoice-parties { grid-template-columns: 1fr; }
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
.invoice-table th, .invoice-table td {
  text-align: left;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.invoice-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.invoice-table td:not(:first-child), .invoice-table th:not(:first-child) { text-align: right; }

.invoice-totals { max-width: 280px; margin-left: auto; }
.invoice-total-row { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.invoice-notes { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 0.9rem; }
.invoice-due { font-weight: 700; margin-top: 20px; }

@media print {
  .app-header, .no-print { display: none !important; }
  .app-main { padding: 0; display: block; }
  body { background: #fff; color: #000; }
  .invoice-sheet {
    max-width: 100%;
    border: none;
    box-shadow: none;
    padding: 0;
    background: #fff;
    color: #000;
  }
  .invoice-parties h2, .invoice-notes, .detail-row dt { color: #444; }
}
