:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7585;
  --border: #e4e7ee;
  --primary: #1f6feb;
  --primary-hover: #1a5fcb;
  --pill-bg: #eef2f7;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --radius: 10px;
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark {
  background: var(--primary); color: #fff;
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.brand-tenant { color: var(--muted); font-weight: 500; }

.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent; border: 0; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; color: var(--muted); font: inherit;
}
.tab:hover { background: var(--pill-bg); color: var(--text); }
.tab.active { background: var(--pill-bg); color: var(--text); font-weight: 600; }

.me { display: flex; align-items: center; gap: 12px; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text);
}
.btn-ghost:hover { background: var(--pill-bg); }

/* ---------- Main ---------- */
.main { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.view { display: none; }
.view.active { display: block; }
.view h2 { margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ---------- Tables ---------- */
table.data {
  width: 100%; border-collapse: collapse; margin: 0;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
}
table.data tr:last-child td { border-bottom: 0; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--pill-bg); font-size: 12px; font-weight: 600;
}

/* ---------- Auth pages ---------- */
.auth-body {
  display: grid; place-items: center;
  min-height: 100vh; padding: 24px;
  background: linear-gradient(180deg, #f7f8fb 0%, #eef2f7 100%);
}
.auth-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px;
  width: 100%; max-width: 380px;
  border: 1px solid var(--border);
}
.auth-title { margin: 0 0 4px; font-size: 22px; }
.auth-sub   { margin: 0 0 20px; color: var(--muted); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label span { font-size: 13px; color: var(--muted); font-weight: 500; }
.auth-form input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text);
}
.auth-form input:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent;
}

.btn-primary {
  background: var(--primary); color: #fff;
  border: 0; padding: 10px 14px; border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn-primary:hover  { background: var(--primary-hover); }
.btn-primary:disabled { background: #99b9ea; cursor: not-allowed; }

.auth-error { color: #b3271d; margin: 0; font-size: 13px; }
.auth-info  { color: var(--muted); margin: 0; font-size: 13px; }
.auth-foot  { margin: 20px 0 0; text-align: center; font-size: 13px; }

/* ---------- Project cards ---------- */
.project {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 12px; background: #fbfcfe;
}
.project h3 { margin: 0 0 8px; }
.project details { margin-top: 8px; }
.project summary { cursor: pointer; color: var(--muted); }

/* ---------- Section actions (filter + add) ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 12px;
}
.section-head h2 { margin: 0; }
.section-head .muted { margin: 0; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions select, .actions input[type=date], .actions input[type=text] {
  font: inherit; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text);
}

.btn-add {
  background: var(--primary); color: #fff; border: 0;
  width: 32px; height: 32px; border-radius: 8px;
  font-size: 18px; font-weight: 600; cursor: pointer; line-height: 1;
}
.btn-add:hover { background: var(--primary-hover); }

/* ---------- Inline create forms ---------- */
.create-form {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; background: var(--surface);
  box-shadow: var(--shadow);
  display: grid; gap: 12px;
}
.create-form .row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.create-form .row.three { grid-template-columns: 1fr 1fr 1fr; }
.create-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.create-form input, .create-form select, .create-form textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; color: var(--text);
}
.create-form textarea { min-height: 60px; resize: vertical; }
.create-form input:focus, .create-form select:focus, .create-form textarea:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent;
}
.create-form .form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.create-form .form-msg { font-size: 13px; }
.create-form .form-msg.error { color: #b3271d; }
.create-form .form-msg.ok    { color: #167c3d; }

@media (max-width: 640px) {
  .create-form .row, .create-form .row.three { grid-template-columns: 1fr; }
}

/* small responsive nicety */
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .me span { display: none; }
  .main { padding: 0 12px; }
}
