/* Piloo History — palette shared with the openSIS chat frontends */
:root {
  --ink: #26252a;
  --ink-soft: #3c3b42;
  --red: #e8262d;
  --red-dark: #c81e24;
  --paper: #ffffff;
  --mist: #f6f7fb;
  --line: #e6e9f1;
  --muted: #6f7480;
  --ok: #1f8a4c;
  --ok-bg: #e8f6ee;
  --err-bg: #fdf1f1;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(38, 37, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(38, 37, 42, 0.12);
  --font-display: "Bricolage Grotesque", "Inter", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid rgba(232, 38, 45, 0.35); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 500;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost:hover:not(:disabled) { background: var(--mist); }

input, select {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}

.error { color: var(--red-dark); }
.error.banner {
  background: var(--err-bg);
  border: 1px solid #f5c9cb;
  padding: 10px 14px;
  border-radius: 10px;
}

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(600px 320px at 50% 12%, rgba(163, 190, 245, 0.35), transparent 70%), var(--mist);
}
.login-card {
  width: min(400px, 100%);
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 36px 28px;
  text-align: center;
}
.login-logo { height: 36px; margin: 0 auto 18px; }
.login-card h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 6px; }
.google-btn { display: flex; justify-content: center; margin: 24px 0 12px; min-height: 44px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.login .error { margin: 14px 0 0; font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.brand img { height: 28px; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user img { width: 30px; height: 30px; border-radius: 50%; }
#user-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  text-align: left;
  color: var(--ink-soft);
}
.tab small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.tab.active { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); color: var(--ink); }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px 14px;
  padding: 16px;
  align-items: end;
}
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 2px 16px; }

/* ---------- summary ---------- */
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- table ---------- */
.table-card { position: relative; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfd; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
td.nowrap { white-space: nowrap; }
td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.err { background: var(--err-bg); color: var(--red-dark); }
.empty, .loading { text-align: center; color: var(--muted); padding: 32px; margin: 0; }
.loading { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.7); display: grid; place-items: center; }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.page-size { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.page-size select { width: auto; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
#page-info { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- detail dialog ---------- */
dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: none;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 20px 24px 24px;
  color: var(--ink);
}
dialog::backdrop { background: rgba(38, 37, 42, 0.45); }
.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head h2 { font-family: var(--font-display); margin: 0; font-size: 20px; }
dialog h3 { font-size: 13px; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 14px 0 0; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }
.msg {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  background: var(--mist);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0;
}
.msg-error { background: var(--err-bg); color: var(--red-dark); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .brand span { display: none; }
  .container { padding: 16px 16px 32px; }
  #user-email { max-width: 140px; }
}
