:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.nav-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  flex-wrap: wrap;
}

.nav-brand {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--accent); color: #fff; }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.logout-btn:hover { background: var(--bg); }

.page {
  width: 100%;
  margin: 0;
  padding: 24px;
}

.filter-field.search-field { flex: 1; min-width: 200px; }
.filter-field.search-field input { width: 100%; min-width: 0; }

.filter-bar {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-field label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.filter-field select,
.filter-field input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  min-width: 140px;
}

.filter-bar button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.filter-bar button:hover { background: var(--accent-dark); }

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

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.tile .tile-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.tile .tile-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

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

.panel h2 { margin: 0 0 14px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; position: sticky; top: 0; background: var(--panel); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: '\2195'; margin-left: 6px; opacity: 0.35; font-size: 11px; }
th.sorted-asc::after { content: '\2191'; opacity: 1; color: var(--accent); }
th.sorted-desc::after { content: '\2193'; opacity: 1; color: var(--accent); }
tbody tr:hover { background: var(--bg); }
.table-scroll { overflow-x: auto; }

.status { color: var(--muted); font-size: 13px; padding: 20px 0; }
.error { color: var(--bad); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
  text-align: center;
}
.login-card h1 { font-size: 18px; margin-bottom: 20px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--accent-dark); }

.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 160px); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-msg.assistant { align-self: flex-start; background: var(--bg); }
.chat-input-row { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; }
.chat-input-row button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
