/* Tip Jar — Light institutional styling (realms-inspired) */

:root {
  --bg: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f5f5f5;
  --surface: #ffffff;
  --border: #e5e5e5;
  --border-hover: #d4d4d4;
  --text: #171717;
  --text-secondary: #525252;
  --text-muted: #737373;
  --accent: #404040;
  --accent-hover: #262626;
  --accent-light: #525252;
  --success: #059669;
  --badge-bg: #f5f5f5;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.08);
  --font-sans: 'Helvetica Neue', Helvetica, Arial, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

html {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 740px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header { text-align: center; margin-bottom: 2rem; }
header .logo { width: 120px; height: 120px; margin-bottom: .75rem; }
header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: .25rem;
}
header .subtitle { color: var(--text-muted); font-size: .9rem; }
header .subtitle a { color: var(--accent); text-decoration: none; font-weight: 500; }
header .subtitle a:hover { text-decoration: underline; }
header .canister-id {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .5rem;
}

/* Auth bar (top-right) */
.auth-bar {
  position: fixed;
  top: .75rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.auth-bar button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .35rem .9rem;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}
.auth-bar button:hover { background: var(--accent-hover); }
.auth-principal {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: .65rem;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: .6rem 1.2rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -2px;
  border-radius: 0;
  box-shadow: none;
  letter-spacing: 0;
  transition: color .15s, border-color .15s;
}
.tab:hover {
  color: var(--text);
  background: none;
  transform: none;
  box-shadow: none;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}
.stat { text-align: center; }
.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}
.stat-sub {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* Form */
.form-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
input, select, textarea {
  flex: 1;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; margin-bottom: .75rem; width: 100%; }

button {
  padding: .6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
button:hover {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  color: var(--accent-hover);
}

.form-note {
  margin-top: .5rem;
  font-size: .82rem;
  color: var(--text-muted);
  min-height: 1.3em;
}

/* Instructions box */
.instructions {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.instructions strong { color: var(--text); }
.instructions code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .78rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text);
}
.instructions ol { margin: .5rem 0; padding-left: 1.5rem; }
.instructions li { margin-bottom: .3rem; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  text-align: left;
  padding: .5rem .4rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tbody td {
  padding: .5rem .4rem;
  border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: var(--bg-tertiary); }
.empty { color: var(--text-muted); text-align: center; padding: 1rem; }

/* Expandable donor rows */
.donor-row { cursor: pointer; }
.donor-row:hover { background: var(--bg-tertiary); }
.donor-messages-row td { padding: 0 !important; border-bottom: 1px solid var(--border); }
.donor-messages-container {
  padding: .5rem .75rem;
  background: var(--bg-secondary);
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: .75rem;
}
.pager button {
  padding: .3rem .8rem;
  font-size: .78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.pager button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-tertiary);
  transform: none;
  box-shadow: none;
}
.pager-info { font-size: .78rem; color: var(--text-muted); }

/* Step labels */
.step-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  margin-bottom: .5rem;
}
.step-optional { font-weight: 400; color: var(--text-muted); text-transform: none; }

/* Encrypted badge */
.badge-secret {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}
.encrypted-text {
  font-size: .75rem;
  color: var(--text-muted);
  word-break: break-all;
  display: block;
  margin: .25rem 0;
}

/* Messages list */
.messages-list { display: flex; flex-direction: column; gap: .75rem; }
.message {
  padding: .75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.message:hover { box-shadow: var(--shadow-sm); }
.message strong { color: var(--accent); }
.message p { margin: .25rem 0; color: var(--text-secondary); }
.message time { font-size: .72rem; color: var(--text-muted); }
.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--success);
  padding: .1rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  margin-left: .4rem;
  font-weight: 600;
  border: 1px solid #e5e5e5;
}

/* Secret notes */
.secret-note {
  padding: .75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: .5rem;
}
.secret-note .note-from { font-weight: 600; color: var(--accent); font-size: .85rem; }
.secret-note .note-text { color: var(--text-secondary); margin: .25rem 0; font-size: .9rem; }
.secret-note time { font-size: .72rem; color: var(--text-muted); }

/* Info section */
.info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}
.info-grid button {
  flex: 1;
  min-width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.info-grid button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-tertiary);
}
.info-output {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: .82rem;
  color: var(--text-secondary);
  min-height: 2rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Success box */
.success-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  color: #166534;
}
.block-code {
  display: block;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .82rem;
  word-break: break-all;
  margin-top: .5rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }
.footer-gh { display: flex; align-items: center; }
.footer-meta { font-family: ui-monospace, SFMono-Regular, monospace; font-size: .7rem; }
.mono { font-family: ui-monospace, SFMono-Regular, monospace; }

/* Responsive */
@media (max-width: 480px) {
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  header .logo { width: 44px; height: 44px; }
  header h1 { font-size: 1.6rem; }
}
