:root {
  --bg: #eef1f7;
  --bg2: #f7f9fc;
  --card: #ffffff;
  --card2: #f3f5fa;
  --line: rgba(28,40,74,0.10);
  --line2: rgba(28,40,74,0.16);
  --text: #1b2438;
  --muted: #6a7488;
  --accent: #3a5bd9;
  --accent2: #2433a0;
  --grad: linear-gradient(135deg, #4f6ef2, #2a3da4);
  --green: #15a34a;
  --red: #e23a5e;
  --amber: #d98012;
  --radius: 16px;
  --shadow: 0 18px 44px -22px rgba(28,40,90,0.28);
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); line-height: 1.5; letter-spacing: -0.01em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
code { background: var(--card2); padding: 1px 7px; border-radius: 6px; font-size: 12.5px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 28px;
  background: rgba(255,255,255,0.78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo-img { height: 34px; width: auto; display: block; }
.brand-sub { padding-left: 14px; border-left: 1px solid var(--line2); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 720; letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.status { font-size: 13px; padding: 7px 13px; border-radius: 20px; font-weight: 650; }
.status--unknown { background: var(--card2); color: var(--muted); }
.status--ok { background: rgba(52,211,153,.15); color: var(--green); }
.status--err { background: rgba(251,113,133,.15); color: var(--red); }

main { max-width: 980px; margin: 0 auto; padding: 26px 20px 90px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 24px 26px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: -0.01em; }
.step { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 13px; font-weight: 700; }
.note { color: var(--amber); font-size: 12.5px; background: rgba(251,191,36,.08); border-left: 3px solid var(--amber); padding: 9px 13px; border-radius: 8px; margin: 12px 0 0; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line2);
  padding: 11px 17px; border-radius: 12px; font-size: 14px; cursor: pointer; font-weight: 650;
  transition: transform .08s ease, filter .2s ease, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 10px 24px -12px rgba(42,61,164,0.55); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--primary:disabled { background: #e4e8f1; box-shadow: none; color: #a3abbd; cursor: not-allowed; transform: none; filter: none; }
.btn--ghost { background: transparent; }
.btn--small { padding: 7px 13px; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 8px; }
.grid label { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 6px; }
select, input[type=text], input[type=number], input[type=password], input[type=email] {
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 11px; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58,91,217,0.15); }

.summary { margin-top: 16px; display: flex; gap: 28px; flex-wrap: wrap; background: var(--card2); padding: 16px 20px; border-radius: 14px; }
.summary .metric { display: flex; flex-direction: column; }
.summary .metric .v { font-size: 21px; font-weight: 740; letter-spacing: -0.02em; }
.summary .metric .k { font-size: 12px; color: var(--muted); }

.warnings { margin-top: 12px; }
.warnings div { color: var(--amber); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 15.5px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Juba arvel olevad on tagasihoidlikumad, aga peavad jääma loetavaks (mitte .5) */
tr.done { opacity: .68; }
.badge { font-size: 12px; padding: 4px 11px; border-radius: 20px; font-weight: 650; }

/* Laekumiste grupipäis: arve number + arve kuupäev */
tr.grp td { background: var(--card2); border-bottom: 1px solid var(--line2); padding-top: 14px; padding-bottom: 10px; }
.grp-inv { font-weight: 750; font-size: 15px; color: var(--text); letter-spacing: -0.01em; }
.grp-new { font-weight: 750; font-size: 15px; color: var(--accent); letter-spacing: -0.01em; }
.grp-date { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.grp-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
tr.grp--new td { background: rgba(58, 91, 217, 0.06); }
.badge--done, .badge--ok { background: rgba(52,211,153,.15); color: var(--green); }
.badge--err { background: rgba(251,113,133,.15); color: var(--red); }
.badge--skip { background: var(--card2); color: var(--muted); }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.checkline input { accent-color: var(--accent); width: 17px; height: 17px; }

.overlay { position: fixed; inset: 0; background: rgba(20,30,60,.42); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border: 1px solid var(--line2); border-radius: 18px; padding: 26px; max-width: 460px; width: 90%; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 10px; font-weight: 720; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 44px 38px; width: 90%; max-width: 380px; text-align: center; box-shadow: var(--shadow); }
.login-logo { margin: 0 auto 4px; display: inline-flex; align-items: center; justify-content: center; }
.login-logo img { height: 64px; width: auto; display: block; }
.login-card h1 { margin: 14px 0 2px; font-size: 23px; font-weight: 760; letter-spacing: -0.02em; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-error { color: var(--red); font-size: 13px; margin: 0; }
.login-foot { margin-top: 20px; font-size: 12px; }
.login-card #bio-btn { width: 100%; margin-top: 22px; }
.login-or { color: var(--muted); font-size: 12px; margin: 14px 0 0; text-transform: uppercase; letter-spacing: .1em; }

/* Config line + mode */
.config-line { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.mode-label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.mode-label select { padding: 8px 11px; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin-top: 6px; }
.config-item { background: var(--card2); border-radius: 10px; padding: 11px 13px; display: flex; flex-direction: column; gap: 3px; }
.config-item .ck { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.config-item .cv { font-size: 14px; font-weight: 650; }
