:root {
  --ink: #202124;
  --muted: #5f6368;
  --line: #e8eaed;
  --bg: #fff;
  --soft: #f8f9fa;
  --green: #188038;
  --green-soft: #e6f4ea;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --amber: #e37400;
  --amber-soft: #fef7e0;
  --blue: #1a73e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.15), 0 1px 3px 1px rgba(60, 64, 67, 0.08);
  --font: "Google Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 28px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 600; font-size: 20px; }
.brand:hover { text-decoration: none; }
.mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #34a853, #188038);
  color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.nav { display: flex; gap: 8px; }
.nav a {
  color: var(--ink); padding: 8px 14px; border-radius: 999px; text-decoration: none; font-size: 14px;
}
.nav a:hover, .nav a.active { background: var(--soft); text-decoration: none; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.who button, .btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font: inherit; color: var(--ink);
}
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { filter: brightness(0.95); }
.btn-danger { color: var(--red); border-color: #f6aea9; }
.btn-ghost { background: transparent; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 24px 80px; }
h1 { font-size: 28px; font-weight: 500; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 28px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px;
  background: #fff; box-shadow: var(--shadow); min-height: 148px;
  display: flex; flex-direction: column; gap: 8px;
}
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1; }
.card .go { font-size: 13px; font-weight: 600; color: var(--green); }
.soon { opacity: 0.55; pointer-events: none; }

.auth {
  min-height: 100vh; display: grid; place-items: center; background: var(--soft);
}
.auth-box {
  width: min(420px, 92vw); background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow);
}
.auth-box h1 { font-size: 22px; }
label { display: block; font-size: 13px; margin: 14px 0 6px; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid #dadce0; border-radius: 8px; padding: 10px 12px; font: inherit;
}
textarea { min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c4e2cb; border-color: var(--green); }
.err { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.ok { background: var(--green-soft); color: var(--green); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.warn { background: var(--amber-soft); color: #8a4b08; padding: 10px 12px; border-radius: 8px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.match { background: var(--green-soft); color: var(--green); }
.badge.mismatch { background: var(--red-soft); color: var(--red); }
.badge.needs_review, .badge.needs_format, .badge.queued { background: var(--amber-soft); color: var(--amber); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.matched, .badge.awaiting_sign, .badge.signed_externally { background: var(--green-soft); color: var(--green); }
.badge.amount_mismatch, .badge.opening_mismatch, .badge.closing_mismatch { background: var(--amber-soft); color: var(--amber); }
.badge.only_theirs, .badge.only_ours, .badge.sent_rework { background: var(--red-soft); color: var(--red); }
.badge.saved { background: var(--soft); color: var(--muted); }
tr.row-matched td { background: #f8f9fa; }
tr.row-amount_mismatch td, tr.row-opening_mismatch td, tr.row-closing_mismatch td { background: #fff8e5; }

.drop {
  border: 2px dashed #dadce0; border-radius: 12px; padding: 36px 20px; text-align: center; background: var(--soft);
}
.muted { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 16px 0; }
.filters { display:grid; grid-template-columns:2fr 1.4fr 1fr 1fr auto; gap:12px; align-items:end; }
.block-title { font-size: 18px; font-weight: 600; margin: 28px 0 10px; }
.block-title .muted { font-weight: 400; }
.doc-name { font-weight: 600; color: inherit; }
table.docs td { padding-top: 12px; padding-bottom: 12px; }
@media (max-width: 800px) {
  .filters { grid-template-columns: 1fr; }
}
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 14px; }
.kv b { font-weight: 500; color: var(--muted); }
