/* ════════════════════════════════════════════════════════════════
   GIMS Compliance Relay — UI design system
   Dark navy + blue→purple accents, GREEN = verified/immutable.
   Modeled on the OpenClaw aesthetic, themed for pharma compliance.
═══════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #070b16;
  --bg2:       #0b1120;
  --surface:   #111a2c;
  --surface2:  #18233b;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.14);
  --text:      #dce4f0;
  --text-mid:  #9fb0cc;
  --text-soft: #647a9e;
  --text-mute: #3a4f6c;

  --accent:       #4f6ef7;
  --accent-2:     #7c3aed;
  --accent-light: rgba(79,110,247,0.15);
  --accent-glow:  rgba(79,110,247,0.30);

  --green:       #10b981;
  --green-light: rgba(16,185,129,0.13);
  --green-glow:  rgba(16,185,129,0.35);
  --green-text:  #34d399;

  --amber:       #fbbf24;
  --amber-light: rgba(251,191,36,0.13);

  --red:         #ef4444;
  --red-light:   rgba(239,68,68,0.10);
  --red-border:  rgba(239,68,68,0.30);
  --red-text:    #f87171;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.28), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 18px rgba(0,0,0,0.38), 0 2px 6px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55), 0 4px 14px rgba(0,0,0,0.35);

  --radius: 11px; --radius-sm: 7px; --radius-lg: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 50% at 15% 0%, rgba(79,110,247,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at 90% 10%, rgba(124,58,237,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 80% 100%, rgba(16,185,129,0.05) 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.icon { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.icon-lg { width: 22px; height: 22px; }
.hidden { display: none !important; }

/* ── Header ─────────────────────────────────────────────────────── */
.header {
  height: 60px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: linear-gradient(135deg, #0c1736 0%, #16264e 50%, #0c1736 100%);
  border-bottom: 1px solid rgba(79,110,247,0.25);
  position: sticky; top: 0; z-index: 40;
  overflow: hidden;
}
.header::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 18% 50%, rgba(79,110,247,0.16) 0%, transparent 60%),
              radial-gradient(ellipse at 82% 50%, rgba(16,185,129,0.08) 0%, transparent 60%);
}
.brand { display: flex; align-items: center; gap: 11px; position: relative; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 2px 14px var(--accent-glow);
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; color: #fff; }
.brand-sub { font-size: 10.5px; font-weight: 500; color: var(--text-soft); letter-spacing: 0.4px; text-transform: uppercase; }

.header-spacer { flex: 1; }

/* chain-status pill (live verified indicator) */
.chain-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border2); background: var(--surface2); color: var(--text-mid);
  position: relative; cursor: pointer; transition: all .15s;
}
.chain-pill:hover { border-color: var(--accent); }
.chain-pill.ok { background: var(--green-light); border-color: rgba(16,185,129,0.4); color: var(--green-text); }
.chain-pill.broken { background: var(--red-light); border-color: var(--red-border); color: var(--red-text); }
.chain-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chain-pill.ok .dot { animation: pulse-dot 1.9s ease infinite; }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 var(--green-glow); } 50% { box-shadow: 0 0 0 6px transparent; } }

.operator {
  display: flex; align-items: center; gap: 9px; position: relative;
  padding: 5px 12px 5px 9px; border-radius: 99px;
  background: var(--surface2); border: 1px solid var(--border);
}
.operator .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff;
}
.operator .who { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.operator .role { font-size: 10px; color: var(--text-soft); }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 18px;
  max-width: 1480px; margin: 0 auto; padding: 20px 24px;
}
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* ── Panels ─────────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  overflow: hidden; animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.panel-head {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--surface2);
}
.panel-head .icon { color: var(--accent); }
.panel-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; color: var(--text-soft); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 13px; }

/* ── Fields ─────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-soft); display: flex; align-items: center; gap: 5px;
}
.input, .select, textarea.input {
  width: 100%; padding: 9px 12px; font-size: 13px; font-family: inherit;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); outline: none; appearance: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent); background: rgba(79,110,247,0.06); box-shadow: 0 0 0 3px var(--accent-glow);
}
.input:hover:not(:focus), .select:hover:not(:focus) { border-color: var(--border2); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23647a9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer;
}
textarea.input { resize: vertical; min-height: 64px; line-height: 1.5; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1.5px solid var(--border2); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: #fff; transform: translateY(-1px); box-shadow: 0 3px 12px var(--accent-glow); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.green:hover:not(:disabled) { border-color: var(--green); box-shadow: 0 3px 12px var(--green-glow); }

.btn-primary {
  position: relative; overflow: hidden; color: #fff; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 4px 18px rgba(79,110,247,0.4); width: 100%; padding: 12px;
}
.btn-primary::before {
  content: ''; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.28) 50%, transparent 70%);
  background-size: 200% 100%; transition: opacity .2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(79,110,247,0.55); }
.btn-primary:hover:not(:disabled)::before { opacity: 1; animation: shimmer .9s ease forwards; }
@keyframes shimmer { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }

/* ── Stat tiles ─────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat {
  padding: 13px; border-radius: var(--radius); background: var(--surface2);
  border: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px;
}
.stat .v { font-size: 22px; font-weight: 700; color: #fff; line-height: 1; }
.stat .l { font-size: 10.5px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.stat.accent .v { color: var(--accent); }
.stat.green .v { color: var(--green-text); }

/* ── Toolbar (search/filter row above the table) ───────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.search-wrap .input { padding-left: 34px; }

/* ── Table ──────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; }
table.trail { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.trail th {
  text-align: left; padding: 10px 12px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-soft);
  border-bottom: 1px solid var(--border2); position: sticky; top: 0; background: var(--surface);
}
table.trail td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.trail tbody tr { transition: background .12s; }
table.trail tbody tr:hover { background: rgba(79,110,247,0.05); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11.5px; }
.chk { color: var(--text-soft); }
.chk b { color: var(--green-text); }

/* kind chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  border: 1px solid var(--border2); color: var(--text-mid); background: var(--surface2); white-space: nowrap;
}
.chip.file_capture { color: var(--accent); border-color: rgba(79,110,247,0.4); background: var(--accent-light); }
.chip.signature { color: var(--amber); border-color: rgba(251,191,36,0.4); background: var(--amber-light); }
.chip.access { color: var(--text-mid); }
.chip.export { color: var(--green-text); border-color: rgba(16,185,129,0.4); background: var(--green-light); }
.chip.watcher_control, .chip.system { color: var(--text-soft); }

.actor { display: inline-flex; align-items: center; gap: 5px; }
.actor.os_bound { color: var(--text-mid); }
.actor.authenticated { color: var(--green-text); }

/* row sign button (appears on hover) */
.row-sign { opacity: 0; transition: opacity .12s; }
table.trail tbody tr:hover .row-sign { opacity: 1; }

/* ── Pagination ─────────────────────────────────────────────────── */
.pager { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager .info { font-size: 12px; color: var(--text-soft); }

/* ── Watcher cards ──────────────────────────────────────────────── */
.watcher { padding: 11px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface2); display: flex; flex-direction: column; gap: 8px; }
.watcher-top { display: flex; align-items: center; gap: 8px; }
.watcher-path { font-size: 12px; font-weight: 600; word-break: break-all; flex: 1; }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--text-mute); flex-shrink: 0; }
.led.on { background: var(--green); box-shadow: 0 0 8px var(--green-glow); animation: pulse-dot 1.9s ease infinite; }
.led.warn { background: var(--amber); }
.watcher-meta { display: flex; gap: 14px; font-size: 11px; color: var(--text-soft); }
.watcher-meta b { color: var(--text); }

/* ── Modal ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(4,7,14,0.66); backdrop-filter: blur(3px); animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 460px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 20px 6px; }
.modal-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.modal-title .icon { color: var(--accent); }
.modal-sub { font-size: 12.5px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; }
.modal-body { padding: 14px 20px; display: flex; flex-direction: column; gap: 13px; }
.modal-foot { padding: 12px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── Login screen ───────────────────────────────────────────────── */
.login-screen { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 30px; }
.login-card { width: 400px; max-width: 92vw; }
.login-hero { text-align: center; margin-bottom: 22px; }
.login-hero .brand-mark { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; }
.login-hero .brand-mark .icon { width: 30px; height: 30px; }
.login-hero h1 { font-size: 21px; font-weight: 700; }
.login-hero p { font-size: 13px; color: var(--text-soft); margin-top: 6px; line-height: 1.55; }
.link { color: var(--accent); cursor: pointer; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ── Toasts + error ─────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border2); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; animation: slide-in .25s ease; max-width: 360px;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.ok { border-color: rgba(16,185,129,0.5); } .toast.ok .icon { color: var(--green-text); }
.toast.err { border-color: var(--red-border); } .toast.err .icon { color: var(--red-text); }
.form-err { font-size: 12.5px; color: var(--red-text); min-height: 16px; }

.empty { text-align: center; padding: 50px 20px; color: var(--text-soft); }
.empty .icon { width: 38px; height: 38px; color: var(--text-mute); margin-bottom: 12px; }
.empty h3 { font-size: 15px; color: var(--text-mid); font-weight: 600; }
.empty p { font-size: 12.5px; margin-top: 5px; }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); background-clip: padding-box; }

@media (max-width: 920px) { .layout { grid-template-columns: 1fr; } }
