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

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --dark: #111827;
  --ok: #d1fae5;
  --ok-text: #065f46;
  --bad: #fee2e2;
  --bad-text: #991b1b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 94%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px 0;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.topnav { display: flex; gap: 8px; align-items: center; }

/* Buttons */
.btn, button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font: 500 13px/1 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover, button:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.btn.secondary, button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.btn.secondary:hover, button.secondary:hover { background: var(--line-soft); }

/* Nav */
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.main-nav a {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: color .15s, background .15s;
}
.main-nav a:hover { color: var(--text); background: var(--line-soft); }
.main-nav a.nav-active { color: var(--accent); background: var(--surface); border-color: var(--line); }
.main-nav a.nav-logout { margin-left: auto; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
.filters input { flex: 2; min-width: 180px; }
.filters select { flex: 1; min-width: 140px; }
.filters button { flex: 0 0 auto; }

/* Inputs */
input, select, textarea {
  font: 14px/1.5 'Inter', sans-serif;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input::placeholder { color: var(--muted-light); }

/* Table */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; min-width: 2200px; }
thead { position: sticky; top: 0; z-index: 1; }
th {
  background: var(--line-soft);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 10px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--line-soft); }
td strong { font-weight: 600; }

/* Bulk bar */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.bulk-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}
.bulk-group input, .bulk-group select { width: 150px; padding: 7px 10px; font-size: 12px; }
.th-check { width: 32px; text-align: center; }
.th-check input, td input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* Inline selects */
.inline-sel {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  background: transparent;
  cursor: pointer;
  width: 100%;
  transition: border-color .15s, background .15s;
}
.inline-sel:hover, .inline-sel:focus { border-color: var(--line); background: var(--surface); outline: none; }
.inline-sel option { font-size: 12px; }
.inline-sel.saving { opacity: .5; }
.inline-input {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  background: transparent;
  width: 100%;
  min-width: 100px;
  transition: border-color .15s, background .15s;
}
.inline-input:hover, .inline-input:focus { border-color: var(--line); background: var(--surface); outline: none; }
.inline-input.saving { opacity: .5; }
.inline-date { width: 69%; min-width: 0; }
.sel-ok { color: #065f46; font-weight: 600; }
.sel-open { color: var(--muted); }

/* Status pills */
.status-pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600; }
.pill-ok { background: #d1fae5; color: #065f46; }
.pill-open { background: #f3f4f6; color: #6b7280; }

/* Badges */
.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px;
}

/* Add form */
.add-form label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13px; font-weight: 500; }
.add-form label span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.add-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 24px; }
.add-form .add-row { grid-column: 1 / -1; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.add-form label.full { grid-column: 1 / -1; }
.add-form div[style] { grid-column: 1 / -1; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card {
  width: min(420px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { margin-bottom: 6px; }
label { display: block; margin: 14px 0; font-size: 13px; font-weight: 500; }
label input, label select, label textarea { margin-top: 5px; }
label.checkbox-label { display: flex; align-items: center; gap: 6px; }
label.checkbox-label input { margin-top: 0; width: 15px; height: 15px; accent-color: var(--accent); }

/* Alerts */
.alert { border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 13px; font-weight: 500; }
.alert.ok { background: var(--ok); color: var(--ok-text); border: 1px solid #6ee7b7; }
.alert.bad { background: var(--bad); color: var(--bad-text); border: 1px solid #fca5a5; }

/* Column resize */
th { position: relative; }
.col-resizer {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 5px;
  cursor: col-resize;
  user-select: none;
  z-index: 1;
}
.col-resizer:hover, .col-resizer.active { background: var(--accent); opacity: .5; }

/* Sort links */
.sort-link { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.sort-link:hover { color: var(--accent); }
.sort-icon { color: var(--muted-light); font-size: 10px; }
.sort-icon.active { color: var(--accent); }

/* Search clear */
.date-range { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.date-range input { width: 128px; min-width: 0; flex: none; }
.search-wrap { position: relative; flex: 2; min-width: 180px; }
.search-wrap input { width: 100%; padding-right: 28px; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; box-shadow: none; color: var(--muted); font-size: 12px; padding: 2px 4px; cursor: pointer; width: auto; min-width: 0; }
.search-clear:hover { color: var(--text); background: none; box-shadow: none; }

/* Danger button */
button.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
button.danger:hover { background: #fca5a5; }

/* Icon button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-icon:hover { background: var(--line-soft); border-color: var(--accent); color: var(--accent); }

/* Misc */
.note { white-space: pre-wrap; min-width: 280px; max-width: 650px; color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini { font-size: 12px; color: var(--muted); margin-top: 6px; }
td .mini { margin-top: 1px; }

/* Quick-add */
.quick-add-wrap { cursor: default; }
.quick-add-wrap summary { font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.quick-add-wrap summary::-webkit-details-marker { display: none; }
.quick-add-wrap summary::before { content: "▸"; font-size: 10px; transition: transform .2s; }
.quick-add-wrap[open] summary::before { transform: rotate(90deg); }
.quick-add-wrap[open] summary { color: var(--text); margin-bottom: 20px; }
.quick-add-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.qa-field { display: flex; flex-direction: column; gap: 5px; min-width: 120px; flex: 1; }
.qa-field.qa-wide { flex: 2; min-width: 180px; }
.qa-field span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.qa-field input, .qa-field select { font-size: 12px; padding: 7px 9px; }
.qa-submit { flex: 0 0 auto; padding-top: 20px; }

/* Responsive */
@media (max-width: 768px) {
  .wrap { width: 96%; padding: 16px 0; }
  header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .main-nav a { padding: 8px 12px; font-size: 12px; }
  .main-nav a.nav-logout { margin-left: 0; }
  .filters { flex-direction: column; }
  .filters input:not(.date-range input), .filters select { width: 100%; }
  .bulk-bar { flex-direction: column; align-items: flex-start; }
  .bulk-group { flex-wrap: wrap; }
  .bulk-group input, .bulk-group select { width: 100%; min-width: 0; flex: 1; }
  .add-row { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 14px 16px; }
}

@media (max-width: 480px) {
  .wrap { width: 98%; }
  h1 { font-size: 18px; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 7px 10px; font-size: 12px; }
}
