@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #0F2436;
  --bg: #EAF3F8;
  --surface: #FFFFFF;
  --primary: #1B5FA8;
  --primary-dark: #123F70;
  --accent: #2FBFAE;
  --accent-dark: #1E9C8D;
  --border: #D3E4EE;
  --muted: #5C7A8A;
  --danger: #C24B4B;
  --danger-bg: #FBEBEA;
  --success-bg: #E4F6F3;
  --info-bg: #E9F1FA;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Manrope', 'Inter', sans-serif;
}

a { color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.top-bar {
  background: linear-gradient(100deg, var(--primary-dark), var(--primary) 55%, var(--accent-dark));
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.top-bar .who {
  font-size: 14px;
  opacity: 0.92;
}
.top-bar a { color: #fff; }

.admin-nav {
  display: flex;
  gap: 4px;
  background: var(--primary-dark);
  padding: 0 24px;
  border-bottom: 3px solid var(--accent);
}
.admin-nav a {
  display: inline-block;
  padding: 11px 16px;
  color: #cfe2ee;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -3px;
}
.admin-nav a:hover {
  color: #fff;
}
.admin-nav a.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.secondary:hover { background: var(--info-bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a53d3d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 15%, #dcedf6 0%, var(--bg) 55%);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(15, 36, 54, 0.04);
}

.card h2 {
  margin-top: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
}

.login-card {
  width: 100%;
  max-width: 380px;
  border-left: 3px solid var(--accent);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--primary-dark);
  letter-spacing: -0.01em;
}
.login-card p.sub {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="text"], input[type="password"], input[type="date"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  font-family: inherit;
  background: #FBFDFE;
  color: var(--ink);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(27, 95, 168, 0.12);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #F0CBC9;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.success-msg {
  background: var(--success-bg);
  color: var(--accent-dark);
  border: 1px solid #BCE7DF;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
tbody tr:hover {
  background: #F5FAFD;
}

.report-text {
  white-space: pre-wrap;
  max-width: 420px;
  line-height: 1.5;
}

.report-text-clamped {
  max-width: 320px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.5;
}
.report-text-clamped:hover {
  color: var(--primary);
}

.view-more-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.view-more-link:hover { color: var(--primary-dark); text-decoration: underline; }

.pill {
  display: inline-block;
  background: var(--info-bg);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 700;
}
.pill-locked {
  background: var(--danger-bg);
  color: var(--danger);
}
.pill-editable {
  background: var(--success-bg);
  color: var(--accent-dark);
}
.pill-count {
  background: var(--info-bg);
  color: var(--primary-dark);
}
.pill-none {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 3px 0;
}

.verify-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.verify-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent-dark);
  cursor: pointer;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.row > div { flex: 1; min-width: 160px; }

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

.empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 28px 0;
  text-align: center;
}

/* ---- modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 36, 54, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border-top: 3px solid var(--accent);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
  position: relative;
}
.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
}
.modal-close-btn:hover { color: var(--ink); background: var(--bg); }

.actions-cell {
  white-space: nowrap;
}

.attachment-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.attachment-slot-row .slot-label {
  flex: 0 0 48px;
}
.attachment-slot-row input[type="file"] {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  font-size: 13px;
}

/* ---- responsive ---- */
@media (max-width: 640px) {
  .top-bar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .top-bar h1 { font-size: 16px; }
  .admin-nav { padding: 0 16px; }
  .admin-nav a { padding: 12px 14px; flex: 1; text-align: center; }
  .wrap { padding: 18px 12px 44px; }
  .card { padding: 16px; border-radius: 12px; }
  .card h2 { font-size: 16px; }
  .row { flex-direction: column; align-items: stretch; }
  .row > div { min-width: 0; }

  .btn { width: 100%; padding: 12px 18px; }
  .row .btn, .card > .btn, form > .btn {
    width: 100%;
  }

  input[type="text"], input[type="password"], input[type="date"], textarea, select {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  /* stacked "card" tables instead of a cramped horizontal-scroll grid */
  .table-scroll table,
  .table-scroll thead,
  .table-scroll tbody,
  .table-scroll th,
  .table-scroll td,
  .table-scroll tr {
    display: block;
  }
  .table-scroll thead { display: none; }
  .table-scroll tr {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--surface);
  }
  .table-scroll td {
    border-bottom: none;
    padding: 7px 0;
    max-width: none;
  }
  .table-scroll td:not(:last-child) {
    border-bottom: 1px dashed var(--border);
  }
  .table-scroll td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .table-scroll .report-text-clamped { max-width: none; }
  .actions-cell {
    white-space: normal;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .actions-cell .btn { width: auto; flex: 1; min-width: 90px; }

  #reportsPagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
  #reportsPagination .btn { width: auto; }

  .modal-box { padding: 20px; max-height: 90vh; }
}

@media (max-width: 400px) {
  .admin-nav a { font-size: 13px; padding: 11px 8px; }
}
