:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e7ed;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
  --purple: #7c3aed;
  --blue: #2563eb;
  --gray: #6b7280;
  --dark: #374151;
}

* { box-sizing: border-box; }

html {
  color-scheme: light only; /* stop mobile browsers auto-dark-moding an unstyled-looking page */
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.layout {
  position: relative;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  overflow-y: auto;
  background: #111827;
  color: #e5e7eb;
  padding: 24px 18px;
  z-index: 10;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 28px;
  color: #fff;
}
.brand span { color: #60a5fa; }

.nav-link,
.nav-link:link,
.nav-link:visited {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1 !important;
  text-decoration: none !important;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-link:hover, .nav-link.active {
  background: #1f2937;
  color: #fff !important;
}

.sidebar-note {
  margin-top: 32px;
  font-size: 12px;
  line-height: 1.5;
  color: #9ca3af;
  border-top: 1px solid #1f2937;
  padding-top: 16px;
}

.main {
  margin-left: 240px;
  width: auto;
  max-width: 1200px;
  padding: 28px 32px;
  box-sizing: border-box;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 24px;
}

h1 { margin-top: 0; font-size: 22px; }
h2 { margin-top: 0; font-size: 17px; }

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

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
}
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.progress-wrap { margin-top: 10px; }
.progress-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #059669);
  transition: width .3s ease;
}

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 6px;
}
.form-grid input, .form-grid textarea {
  width: 100%;
  max-width: 100%;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
.full-width { grid-column: 1 / -1; }

.inline-form input[type="file"] {
  max-width: 100%;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-danger-outline { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table a { color: var(--primary); text-decoration: none; word-break: break-all; }
.data-table a:hover { text-decoration: underline; }
.data-table td:nth-child(2) { max-width: 260px; }

.muted { color: #9ca3af; }
.empty-row { text-align: center; color: var(--muted); padding: 28px; }

.notes-input {
  width: 100%;
  min-width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.status-select {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.badge-gray { background: #f3f4f6; color: var(--gray); }
.badge-blue { background: #eff6ff; color: var(--blue); }
.badge-purple { background: #f5f3ff; color: var(--purple); }
.badge-green { background: #ecfdf5; color: var(--green); }
.badge-orange { background: #fffbeb; color: var(--orange); }
.badge-red { background: #fef2f2; color: var(--red); }
.badge-dark { background: #f3f4f6; color: var(--dark); }

@media (max-width: 800px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }
  .main {
    margin-left: 0;
    padding: 18px;
  }
  .form-grid { grid-template-columns: 1fr; }
}
