/* Neosafe dashboard — hand-written stylesheet */
:root {
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --border: #e2e6ed;
  --text: #1a1a2e;
  --text-secondary: #5a6480;
  --accent: #3a5ba0;
  --accent-hover: #2d4a8a;
  --success: #22543d;
  --success-bg: #c6f6d5;
  --warning: #744210;
  --warning-bg: #fefcbf;
  --danger: #742a2a;
  --danger-bg: #fed7d7;
  --gray: #718096;
  --gray-bg: #edf2f7;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
pre, code { font-family: var(--mono); font-size: 0.82rem; }
pre { white-space: pre-wrap; word-break: break-all; }

/* Layout */
.site-header {
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.5rem; display: flex; align-items: center; gap: 1.25rem;
  position: sticky; top: 0; z-index: 100;
}
.site-logo { font-size: 1.05rem; font-weight: 700; color: var(--accent); letter-spacing: -.02em; flex-shrink: 0; }
.site-nav { display: flex; gap: 1rem; }
.site-nav a { color: var(--text-secondary); font-size: 0.88rem; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.header-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.workspace-name { color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; }
.user-email { color: var(--text-secondary); font-size: 0.82rem; }
.site-main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.site-footer { text-align: center; padding: 1.25rem; color: var(--text-secondary); font-size: 0.78rem; border-top: 1px solid var(--border); margin-top: 2.5rem; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
.card-title { font-size: 0.95rem; font-weight: 600; }
.section { margin-bottom: 1.75rem; }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Summary cards */
.summary-card { text-align: center; padding: 1.25rem; }
.summary-num { font-size: 2.2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.summary-label { color: var(--text-secondary); font-size: 0.82rem; margin-top: 0.3rem; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 0.18rem 0.55rem;
  border-radius: 999px; font-size: 0.73rem; font-weight: 500; line-height: 1.4; white-space: nowrap;
}
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1.1rem; border-radius: var(--radius); font-size: 0.88rem;
  font-weight: 500; cursor: pointer; border: none; min-height: 40px;
  line-height: 1.3; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--gray-bg); text-decoration: none; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #f8b4b4; }
.btn-danger:hover { background: #fbb; text-decoration: none; }
.btn-sm { padding: 0.25rem 0.65rem; font-size: 0.78rem; min-height: 32px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.83rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--text-secondary); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 0.48rem 0.75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.88rem; background: var(--bg-card); color: var(--text); min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border); padding: 0.5rem 0.75rem; font-size: 0.77rem; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Mono / address */
.mono { font-family: var(--mono); font-size: 0.82rem; }
.addr { font-family: var(--mono); font-size: 0.8rem; color: var(--text-secondary); }
.copy-btn {
  font-size: 0.68rem; padding: 0.1rem 0.3rem; margin-left: 0.25rem;
  cursor: pointer; border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg); color: var(--text-secondary); font-family: var(--font);
}
.copy-btn:hover { background: var(--gray-bg); }

/* Tab bar / filters */
.tab-bar { display: flex; gap: 0.35rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab { padding: 0.45rem 0.75rem; font-size: 0.87rem; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab:hover { color: var(--accent); text-decoration: none; }

/* Alerts */
.alert { padding: 0.7rem 1rem; border-radius: var(--radius); font-size: 0.88rem; margin-bottom: 1rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f8b4b4; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #9ae6b4; }

/* Progress bar */
.progress-bar { height: 5px; background: var(--border); border-radius: 999px; overflow: hidden; width: 100%; margin-top: 0.4rem; }
.progress-fill { height: 100%; background: var(--accent); }

/* Page */
h1 { font-size: 1.45rem; font-weight: 700; margin-bottom: 1.25rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.4rem; }
p { margin-bottom: 0.5rem; line-height: 1.6; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.page-header h1 { margin-bottom: 0; }
.text-secondary { color: var(--text-secondary); font-size: 0.88rem; }
.text-sm { font-size: 0.83rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.gap-sm { gap: 0.5rem; }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.flow-token-box { font-family: var(--mono); font-size: 0.78rem; background: var(--gray-bg); padding: 0.4rem 0.6rem; border-radius: 4px; word-break: break-all; }

/* Login page */
.login-wrap { max-width: 380px; margin: 4rem auto; }
.login-logo { font-size: 1.7rem; font-weight: 700; color: var(--accent); text-align: center; margin-bottom: 2rem; letter-spacing: -.03em; }

/* Signature list */
.sig-list { list-style: none; }
.sig-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; }
.sig-list li:last-child { border-bottom: none; }
.sig-check { color: var(--success); }
.sig-pending { color: var(--gray); }

/* Details expand */
details > summary { cursor: pointer; font-size: 0.88rem; color: var(--text-secondary); padding: 0.4rem 0; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▶  '; font-size: 0.7rem; }
details[open] > summary::before { content: '▼  '; }
details .detail-body { margin-top: 0.75rem; }

/* Feed */
.feed-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; display: flex; gap: 0.75rem; align-items: flex-start; }
.feed-item:last-child { border-bottom: none; }
.feed-time { color: var(--text-secondary); font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; min-width: 80px; }
.feed-type { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); background: var(--gray-bg); padding: 0.1rem 0.35rem; border-radius: 4px; flex-shrink: 0; }

/* Pagination */
.pagination { display: flex; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; align-items: center; }
.pagination a, .pagination span { padding: 0.35rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; }
.pagination a:hover { background: var(--gray-bg); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Signing card */
.signing-card { border: 2px solid var(--accent); border-radius: var(--radius); padding: 1.25rem; margin-top: 0.5rem; }

/* Empty state */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-secondary); font-size: 0.9rem; }

/* HTMX loading indicator */
.htmx-indicator { display: none; color: var(--text-secondary); font-size: 0.8rem; }
.htmx-request .htmx-indicator { display: inline; }

/* Responsive */
@media (max-width: 640px) {
  .site-header { padding: 0.65rem 1rem; flex-wrap: wrap; gap: 0.75rem; }
  .site-nav { order: 3; width: 100%; gap: 0.75rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .btn { min-height: 44px; }
  input, select, textarea { min-height: 44px; }
  .header-user .workspace-name, .header-user .user-email { display: none; }
  .login-wrap { margin: 2rem auto; padding: 0 1rem; }
}
