:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --error: #dc2626;
  --border: #e2e8f0;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

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

.page {
  height: 100vh;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo svg { width: 32px; height: 32px; }

.logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

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

.header-meta {
  text-align: right;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
}

.header-meta strong { color: var(--text); }

.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  grid-template-rows: 1fr auto;
  gap: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.status-card {
  grid-column: 1;
  grid-row: 1;
}

.action-card {
  grid-column: 2;
  grid-row: 1;
}

.info-card {
  grid-column: 1 / -1;
  grid-row: 2;
  padding: 10px 16px;
}

.status-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.office-row {
  margin-bottom: 10px;
}

.office-row label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.office-input-row {
  display: flex;
  gap: 8px;
}

.office-input-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.office-row .hint {
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.pending { background: #94a3b8; }
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }
.status-dot.err { background: var(--error); }

.status-item strong {
  display: block;
  font-size: 0.8rem;
}

.status-item p {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.action-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 0;
}

.steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  color: var(--muted);
}

.step span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 600;
  flex-shrink: 0;
}

.action-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.secondary-btn {
  flex: 0 0 auto;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.secondary-btn:hover:not(:disabled) { background: #f8fafc; }
.secondary-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  width: auto;
  padding: 11px 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.generate-btn:hover:not(:disabled) { background: var(--primary-hover); }
.generate-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #eff6ff;
  border-radius: 6px;
}

.progress.hidden { display: none; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bfdbfe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

#progressText {
  font-size: 0.75rem;
  color: var(--primary);
}

.result {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.3;
}

.result.hidden { display: none; }
.result.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.result.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.format-preview {
  display: flex;
  gap: 3px;
  font-size: 0.62rem;
  font-weight: 600;
}

.format-preview .col {
  padding: 5px 6px;
  border-radius: 3px;
  text-align: center;
  white-space: nowrap;
}

.sr { background: #d9d9d9; }
.party { background: #bdd7ee; flex: 1; }
.bills { background: #ffc000; }
.bill1 { background: #f1948a; color: #fff; }
.bill2 { background: #82e0aa; }
.more { background: #e2e8f0; color: var(--muted); }
.onacct { background: #f4b183; }
.total { background: #c6e0b4; }

.footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
}

.install-help {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.install-help.hidden { display: none; }

.install-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.install-panel h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.install-panel p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.install-panel ol {
  font-size: 0.72rem;
  color: var(--text);
  padding-left: 18px;
  margin-bottom: 14px;
  line-height: 1.6;
}

.install-panel code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.68rem;
}

.dismiss-btn {
  width: 100%;
  padding: 9px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.dismiss-btn:hover { background: var(--primary-hover); }

.status-item.clickable { cursor: pointer; }
.status-item.clickable:hover { background: #eff6ff; }

@media (max-width: 640px) {
  .page { padding: 10px 12px 8px; }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .header-meta { text-align: left; }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .status-card { grid-column: 1; grid-row: 1; }
  .action-card { grid-column: 1; grid-row: 2; }
  .info-card { grid-column: 1; grid-row: 3; }

  .steps { grid-template-columns: 1fr; }
}
