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

:root {
  --purple: #5B2B82;
  --purple-light: #7B4BA2;
  --green: #70EA45;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-2: #555;
  --ink-3: #888;
  --border: #e0e0e0;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Header ---- */

#app-header {
  background: var(--purple);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 32px;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.header-logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.7;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }

/* ---- Main ---- */

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ---- Toolbar ---- */

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input[type="text"] {
  flex: 1;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}

.toolbar input[type="text"]:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(91,43,130,0.15);
}

.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  outline: none;
  cursor: pointer;
}

/* ---- Table ---- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: #fafafa; }

.data-table .mono {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 12px;
}

.data-table .truncate {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Tier badges ---- */

.tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.tier-free { background: #eee; color: #666; }
.tier-trial { background: #e0f0ff; color: #1a73e8; }
.tier-pro { background: #e6f9e0; color: #1b8a1b; }
.tier-grace { background: #fff3e0; color: #e65100; }
.tier-expired { background: #fde8e8; color: #c62828; }
.tier-beta { background: #f3e8ff; color: #5B2B82; }

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body { padding: 18px; }

.card-body .field-row {
  display: flex;
  padding: 6px 0;
  gap: 12px;
}

.card-body .field-label {
  width: 160px;
  flex-shrink: 0;
  color: var(--ink-3);
  font-size: 13px;
  text-align: right;
}

.card-body .field-value {
  font-size: 13px;
  word-break: break-all;
}

.card-body .field-value input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 280px;
  outline: none;
}

.card-body .field-value input:focus {
  border-color: var(--purple);
}

/* ---- Buttons ---- */

.btn {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--purple-light); }

.btn-ghost {
  background: transparent;
  color: var(--purple);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #f0f0f0; }

.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d32f2f; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ---- Pagination ---- */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---- Back link ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--purple);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
}

.back-link:hover { text-decoration: underline; }

/* ---- Confirm dialog ---- */

#confirm-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  max-width: 420px;
  width: 90%;
}

#confirm-dialog::backdrop {
  background: rgba(0,0,0,0.4);
}

.dialog-body {
  padding: 24px;
}

.dialog-body p {
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* ---- Expandable JSON ---- */

.json-toggle {
  color: var(--purple);
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}

.json-toggle:hover { text-decoration: underline; }

.json-block {
  display: none;
  background: #f8f8f8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 4px;
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.json-block.open { display: block; }

/* ---- Extend trial inline form ---- */

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.inline-form input[type="number"] {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.inline-form input[type="number"]:focus {
  border-color: var(--purple);
}

/* ---- Empty state ---- */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---- Loading ---- */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--ink-3);
}
