/* === reset & base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-tint: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -2px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

html { font-size: 14px; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === nav === */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  height: 56px;
}

nav .brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-right: 1rem;
  letter-spacing: -0.01em;
}
nav .brand:hover { text-decoration: none; }

nav a:not(.brand) {
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  transition: background 0.1s ease, color 0.1s ease;
}
nav a:not(.brand):hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
nav a.active {
  color: var(--primary);
  background: var(--primary-tint);
}

nav .badge {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.25rem;
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
  line-height: 1.3;
}

nav form.logout { margin-left: auto; }
nav form.logout button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.35rem 0.85rem;
}
nav form.logout button:hover {
  background: var(--bg);
  color: var(--text);
}

/* === layout === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
  color: var(--text);
}
h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.75rem 0 0.75rem;
  color: var(--text);
}
p { margin-bottom: 0.75rem; }

/* === sections / cards === */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
section h2:first-child { margin-top: 0; }

/* === dashboard stats === */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat .value {
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.stat.accent .value { color: var(--primary); }

/* === tables === */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}
thead { background: var(--bg); }
th {
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.05s ease; }
tbody tr:hover { background: var(--primary-tint); }
td a {
  color: var(--primary);
  word-break: break-all;
}

/* === forms === */
input[type="text"], input[type="password"], input[type="file"], input:not([type]), select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.875rem;
}
form.add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
form.add input, form.add select { width: auto; flex: 1; min-width: 160px; }

/* === buttons === */
button {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  background: var(--primary);
  color: white;
  transition: background 0.1s ease, transform 0.05s ease;
  white-space: nowrap;
}
button:hover { background: var(--primary-hover); }
button:active { transform: translateY(1px); }

td form button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}
td form button:hover { background: var(--bg); border-color: var(--text-muted); }
td form[action*="approve"] button { color: var(--success); border-color: rgba(22, 163, 74, 0.3); }
td form[action*="approve"] button:hover { background: rgba(22, 163, 74, 0.08); }
td form[action*="reject"] button { color: var(--danger); border-color: rgba(220, 38, 38, 0.3); }
td form[action*="reject"] button:hover { background: rgba(220, 38, 38, 0.08); }

form.run-now { margin-bottom: 1.5rem; }

/* === error / messages === */
.error {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-top: 1rem;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* === login === */
.login-container {
  max-width: 380px;
  margin: 5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 2.25rem;
  box-shadow: var(--shadow-md);
}
.login-container h1 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.login-container .subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.login-container button { width: 100%; padding: 0.6rem 1rem; }

/* === empty state === */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

/* === code / cron === */
code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 0.125rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--border);
}

/* === notification row states === */
tr.unread { background: var(--primary-tint); }
tr.unread:hover { background: rgba(37, 99, 235, 0.12); }
tr.read { opacity: 0.65; }

/* === utility === */
.muted { color: var(--text-muted); }
