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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text2: #888;
  --accent: #e1306c;
  --accent2: #833ab4;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 10px;
}

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

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

.layout {
  display: flex;
  min-height: 100vh;
  padding-bottom: 52px;
}

.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 52px;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  padding: 0 20px 24px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: var(--text2);
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--accent);
  text-decoration: none;
}

.main {
  margin-left: 200px;
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; color: var(--text2); font-weight: 500; font-size: 12px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-green { background: #14532d; color: var(--green); }
.badge-yellow { background: #713f12; color: var(--yellow); }
.badge-red { background: #7f1d1d; color: var(--red); }
.badge-blue { background: #1e3a5f; color: var(--blue); }
.badge-gray { background: var(--surface2); color: var(--text2); }

btn, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text2); font-size: 12px; font-weight: 500; text-transform: uppercase; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; width: 440px; max-width: 95vw;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }

.status-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 52px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  z-index: 50;
  font-size: 12px;
  color: var(--text2);
}
.status-indicator {
  display: flex; align-items: center; gap: 6px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot-gray { background: var(--text2); }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
  color: var(--text2);
}
.upload-zone:hover { border-color: var(--accent); color: var(--text); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb button {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.7); border: none; color: #fff;
  border-radius: 50%; width: 20px; height: 20px; cursor: pointer;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
}

.empty { color: var(--text2); text-align: center; padding: 40px; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; }
.success-msg { color: var(--green); font-size: 13px; margin-top: 8px; }

.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--text2); font-size: 12px; margin-top: 4px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text2); }

/* ---- server-rendered additions ---- */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.banner-error { background: #2a1414; border-color: #7f1d1d; color: #fca5a5; }
.banner-success { background: #0f2417; border-color: #14532d; color: #86efac; }
.banner-warn { background: #2a2113; border-color: #713f12; color: #fde047; }

form.inline { display: inline; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar a.btn { text-decoration: none; }
a.btn:hover { text-decoration: none; }

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

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.status-bar a { color: var(--text2); }

.hint { color: var(--text2); font-size: 12px; margin-top: 6px; }

@media (max-width: 800px) {
  .sidebar { position: static; width: 100%; bottom: auto; flex-direction: row; align-items: center; padding: 12px; overflow-x: auto; }
  .sidebar-logo { padding: 0 16px 0 4px; }
  .sidebar nav { display: flex; }
  .sidebar nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar nav a.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .layout { flex-direction: column; }
  .main { margin-left: 0; padding: 20px 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .status-bar { height: auto; padding: 10px 16px; gap: 12px; flex-wrap: wrap; position: static; }
  .layout { padding-bottom: 0; }
}

table { display: block; overflow-x: auto; white-space: nowrap; }
@media (min-width: 801px) { table { display: table; white-space: normal; } }
