:root {
  --bg: #0f1220;
  --bg-2: #171b2e;
  --card: #1c2136;
  --card-2: #232a45;
  --line: #2c3454;
  --text: #e8ebf5;
  --muted: #9aa3c4;
  --accent: #6c8cff;
  --accent-2: #4f6fe0;
  --green: #35d19a;
  --amber: #ffb454;
  --red: #ff6b7a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2140 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 700; font-size: 20px; color: #fff;
  box-shadow: var(--shadow);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: 0.2px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.rate-pill {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  color: var(--accent);
}

/* Summary cards */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
}
.card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-value.paid { color: var(--green); }
.card-value.due { color: var(--amber); }

/* Tabs */
.tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  background: var(--card); padding: 6px; border-radius: 999px;
  border: 1px solid var(--line); width: fit-content;
}
.tab {
  border: none; background: transparent; color: var(--muted);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

/* Panels */
.panel { display: none; animation: fade 0.2s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.block h2 { margin: 0 0 14px; font-size: 16px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.block-head h2 { margin: 0; }

/* Timer */
.timer-block { text-align: center; }
.timer-display {
  font-size: 52px; font-weight: 800; letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}
.timer-controls { display: flex; gap: 10px; max-width: 520px; margin: 0 auto; }
.timer-controls input { flex: 1; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Forms */
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px; margin-bottom: 16px;
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.wide { grid-column: 1 / -1; }
input, select {
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 12px;
  font-size: 14px; outline: none; transition: 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
.mini-select { padding: 8px 10px; font-size: 13px; }

/* Buttons */
.btn {
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); padding: 11px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: rgba(255,107,122,0.12); }
.btn.tiny { padding: 6px 10px; font-size: 12px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(108,140,255,0.06); }
.del-btn { background: transparent; border: none; color: var(--red); cursor: pointer; font-size: 16px; }

/* Periods */
.period {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; background: var(--bg-2);
}
.period.paid { border-color: rgba(53,209,154,0.4); }
.period-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.period-range { font-weight: 700; font-size: 15px; }
.period-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.period-amount { font-size: 20px; font-weight: 800; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; margin-left: 8px;
}
.badge.paid { background: rgba(53,209,154,0.15); color: var(--green); }
.badge.due { background: rgba(255,180,84,0.15); color: var(--amber); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; }
.save-note { color: var(--green); font-size: 13px; margin-left: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }

/* Responsive */
@media (max-width: 640px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .timer-display { font-size: 42px; }
  .timer-controls { flex-direction: column; }
}


/* ============================================================
   Cloudflare edition additions: login, roles, loading
   ============================================================ */

/* Loading splash */
.loading {
  min-height: 60vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
}

/* Topbar right cluster */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.role-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.6px;
  padding: 4px 10px; border-radius: 999px;
}
.role-badge.admin { background: rgba(108,140,255,0.16); color: var(--accent); }
.role-badge.viewer { background: rgba(255,180,84,0.16); color: var(--amber); }

/* Read-only banner */
.readonly-note {
  background: rgba(255,180,84,0.1);
  border: 1px solid rgba(255,180,84,0.35);
  color: var(--amber);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 30px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 14px 0 2px; font-size: 22px; }
.login-card .subtitle { margin: 0 0 22px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.avatar.big {
  width: 64px; height: 64px; font-size: 28px; margin: 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700;
}
.btn.full { width: 100%; margin-top: 4px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 0; text-align: center; }


/* Change-password / account form feedback */
.save-note.error { color: var(--red); }


/* ============================================================
   Agreement workflow + invoicing
   ============================================================ */

/* Status badges on entries */
.badge.pending  { background: rgba(255,180,84,0.15);  color: var(--amber); }
.badge.agreed   { background: rgba(53,209,154,0.15);  color: var(--green); }
.badge.disputed { background: rgba(255,107,122,0.15); color: var(--red); }

/* Pending summary card */
.card-value.pending { color: var(--amber); }

/* Dispute reason under a note */
.dispute-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--red);
  background: rgba(255,107,122,0.08);
  border-left: 3px solid var(--red);
  padding: 6px 8px;
  border-radius: 6px;
}

/* Action buttons in the entries table */
.actions-cell { white-space: nowrap; }
.actions-cell .btn.tiny, .actions-cell .del-btn { margin-left: 4px; }

/* Period pending line + controls */
.period-pending { color: var(--amber); font-size: 13px; margin-top: 4px; }
.period-controls { margin-top: 8px; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn.tiny[disabled] { opacity: 0.45; cursor: not-allowed; }


/* ============================================================
   Efficio branding
   ============================================================ */
.brand-icon { display: block; border-radius: 12px; }
.brand-icon.sm { width: 40px; height: 40px; }
.login-card .brand-icon { margin: 0 auto 12px; width: 64px; height: 64px; }
