:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #1e4d6b;
  --primary-dark: #163a52;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 270px;
  flex-shrink: 0;
  background: var(--primary-dark);
  color: #e2e8f0;
  padding: 1.25rem 0 2rem;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 0.75rem;
}

.sidebar-brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(13,148,136,0.25);
}

.sidebar-brand h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
}

.sidebar-brand span {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 1px;
}

.sidebar nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.sidebar nav a.active {
  background: rgba(13,148,136,0.18);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sidebar nav a .badge {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.1);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 1px 8px;
  flex-shrink: 0;
}

.sidebar nav a.active .badge {
  background: var(--accent);
  color: #fff;
}

.sidebar-home {
  margin: 0 1.25rem 0.75rem;
  display: block;
  color: #fff !important;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  opacity: 0.9;
}
.sidebar-home:hover { opacity: 1; }

/* Main */
.main {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 3rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.topbar h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary-dark);
  font-weight: 650;
}

.topbar .sub {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Cards (dashboard) */
.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 160px;
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.table-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15,23,42,0.1);
  border-color: var(--accent);
}

.table-card .name {
  font-weight: 650;
  font-size: 0.98rem;
  color: var(--primary-dark);
}

.table-card .meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.9rem;
}

.table-card .meta b {
  color: var(--accent);
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}

.filter-bar input[type="text"],
.filter-bar select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  background: #fbfcfd;
  color: var(--text);
}

.filter-bar input[type="text"] {
  min-width: 220px;
  flex: 1 1 220px;
}

.filter-bar button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.48rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.filter-bar button:hover { background: var(--primary-dark); }

.filter-bar .reset {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.filter-bar .reset:hover { background: #f1f5f9; color: var(--text); }

.search-hint {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  margin-bottom: 1.1rem;
}

.search-hint a {
  color: #b45309;
  font-weight: 600;
}

.fuzzy-mark {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  margin-right: 4px;
  cursor: help;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
  max-width: 100%;
}

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
  white-space: nowrap;
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--primary);
  color: #fff;
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-weight: 600;
  font-size: 0.76rem;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  z-index: 1;
}

table.data thead th a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

table.data thead th a:hover { text-decoration: underline; }

table.data tbody tr:nth-child(even) { background: #f8fafc; }
table.data tbody tr:hover { background: var(--accent-soft); }

table.data td {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #eef1f5;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #334155;
}

table.data td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.empty { color: #cbd5e1; font-style: italic; }

table.data td.truncatable { cursor: zoom-in; }
table.data td.truncatable:hover {
  text-decoration: underline dotted;
  text-decoration-color: var(--text-muted);
}

table.data td.expanded {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: break-word;
  max-width: 480px;
  cursor: zoom-out;
  background: var(--accent-soft);
}

.pill {
  display: inline-block;
  background: var(--accent-soft);
  color: #0f766e;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pagination .pages { display: flex; gap: 0.3rem; }

.pagination a, .pagination span.current {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
}

.pagination a:hover { background: #eef2f7; }

.pagination span.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

footer.note {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: #94a3b8;
}
