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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
}

/* Nav */
nav {
  background: #1d1d1f;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .brand { font-weight: 700; color: #fff; font-size: 1rem; text-decoration: none; letter-spacing: -0.01em; }
nav a { color: rgba(255,255,255,0.65); text-decoration: none; font-size: 0.875rem; transition: color 0.15s; }
nav a:hover { color: #fff; }
nav .spacer { flex: 1; }
nav .logout { font-size: 0.8rem; color: rgba(255,255,255,0.4); }
nav .logout:hover { color: rgba(255,255,255,0.8); }

/* Main */
main { max-width: 1100px; margin: 2rem auto; padding: 0 2rem; }

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; letter-spacing: -0.02em; }
.page-sub { color: #6b7280; font-size: 0.875rem; margin-bottom: 2rem; }

/* Tiles */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}
.tile {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  text-decoration: none;
  color: inherit;
  display: block;
  border-top: 3px solid #2563eb;
  transition: transform 0.12s, box-shadow 0.12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.1); }
.tile.green  { border-top-color: #16a34a; }
.tile.amber  { border-top-color: #d97706; }
.tile.purple { border-top-color: #7c3aed; }
.tile.red    { border-top-color: #dc2626; }

.tile-icon  { font-size: 2rem; margin-bottom: 0.75rem; }
.tile-title { font-weight: 700; font-size: 1rem; margin-bottom: 0.3rem; }
.tile-desc  { font-size: 0.82rem; color: #6b7280; line-height: 1.45; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.82rem; }
th {
  background: #f9fafb;
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
td {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #f3f4f6;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 0.4rem; margin-top: 1.25rem; flex-wrap: wrap; }
.page-link {
  padding: 0.3rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  text-decoration: none;
  color: #374151;
  font-size: 0.82rem;
  background: #fff;
}
.page-link.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.page-link:hover:not(.active) { background: #f3f4f6; }
.page-info { font-size: 0.82rem; color: #6b7280; margin-left: 0.5rem; }

/* Script cards */
.script-list { display: flex; flex-direction: column; gap: 0.75rem; }
.script-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.script-label { font-weight: 600; font-size: 0.95rem; }
.script-cmd   { font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace; font-size: 0.78rem; color: #6b7280; margin-top: 0.2rem; }
.warn-badge   { font-size: 0.72rem; background: #fef3c7; color: #92400e; padding: 0.15rem 0.5rem; border-radius: 4px; font-weight: 500; margin-left: 0.5rem; }

/* Terminal / log viewer */
.terminal {
  background: #0f1117;
  color: #c9d1d9;
  font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  padding: 1.25rem;
  border-radius: 10px;
  height: 520px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal .line-ok   { color: #56d364; }
.terminal .line-warn { color: #e3b341; }
.terminal .line-err  { color: #f85149; }

/* Log list */
.log-list { display: flex; flex-direction: column; gap: 0.5rem; }
.log-row {
  background: #fff;
  border-radius: 9px;
  padding: 0.9rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.log-row a { text-decoration: none; color: #2563eb; font-weight: 600; }
.log-row a:hover { text-decoration: underline; }
.log-meta { font-size: 0.8rem; color: #6b7280; margin-top: 0.15rem; }
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 5px; font-size: 0.75rem; font-weight: 600; }
.badge-ok   { background: #dcfce7; color: #15803d; }
.badge-fail { background: #fef2f2; color: #dc2626; }

/* Storage */
.storage-card { background: #fff; border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.prefix-row { display: flex; justify-content: space-between; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid #f3f4f6; }
.prefix-row:last-child { border-bottom: none; }
.prefix-name { font-family: monospace; font-size: 0.875rem; color: #374151; }
.prefix-count { font-weight: 600; font-size: 0.875rem; color: #2563eb; }
.storage-total { font-size: 1.5rem; font-weight: 700; color: #1d1d1f; }
.storage-label { font-size: 0.875rem; color: #6b7280; }

/* Login */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 18px;
  width: 380px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.1);
}
.login-card h1 { text-align: center; margin-bottom: 0.25rem; }
.login-sub { text-align: center; color: #6b7280; font-size: 0.875rem; margin-bottom: 2rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.form-group input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.error-msg { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; padding: 0.75rem; border-radius: 7px; font-size: 0.875rem; margin-bottom: 1.25rem; }

/* Misc */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.empty-state { text-align: center; padding: 3rem; color: #9ca3af; font-size: 0.875rem; }
