:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e5e9;
  --color-text: #1f2933;
  --color-text-muted: #6b7684;
  --color-primary: #2455c9;
  --color-primary-dark: #1a3f9e;
  --color-danger: #c0392b;
  --color-risk-high-bg: #fdeceb;
  --color-risk-high-text: #c0392b;
  --color-risk-medium-bg: #fdf3e2;
  --color-risk-medium-text: #b06a00;
  --color-risk-low-bg: #eaf6ec;
  --color-risk-low-text: #237a3f;
  --radius: 6px;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
}

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

/* --- Login page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  width: 340px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  margin: 0 0 20px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  color: var(--color-text);
}

.field textarea { resize: vertical; }

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
}

button:hover, .btn:hover { background: var(--color-primary-dark); }
button.secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
button.secondary:hover { background: #f0f2f4; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.error-text {
  color: var(--color-danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 6px;
}

/* --- App shell --- */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 { font-size: 16px; margin: 0; }
.app-header .user-info { font-size: 13px; color: var(--color-text-muted); display: flex; gap: 12px; align-items: center; }

.container {
  padding: 20px 24px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- Summary tiles --- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

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

.tile .value { font-size: 24px; font-weight: 700; }
.tile .label { color: var(--color-text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.tile.risk-high .value { color: var(--color-risk-high-text); }
.tile.risk-medium .value { color: var(--color-risk-medium-text); }
.tile.risk-low .value { color: var(--color-risk-low-text); }
.tile.attention { border-color: var(--color-risk-high-text); }

/* --- Toolbar --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
  justify-content: space-between;
}

.toolbar .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar input, .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
}

/* --- Table --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: #fafbfc;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

tbody tr:hover { background: #f7f9fb; cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge.risk-high { background: var(--color-risk-high-bg); color: var(--color-risk-high-text); }
.badge.risk-medium { background: var(--color-risk-medium-bg); color: var(--color-risk-medium-text); }
.badge.risk-low { background: var(--color-risk-low-bg); color: var(--color-risk-low-text); }

.badge.status { background: #eef1f5; color: #445; }
.badge.mgmt { background: var(--color-risk-high-text); color: #fff; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--color-text-muted);
}

/* --- Modal / drawer --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 33, 0.4);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}

.drawer {
  width: 420px;
  max-width: 100%;
  background: var(--color-surface);
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
}

.drawer h2 { margin-top: 0; font-size: 17px; }
.drawer .meta-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.drawer .meta-row .label { color: var(--color-text-muted); }
.drawer .section-title { font-size: 12px; text-transform: uppercase; color: var(--color-text-muted); margin: 18px 0 8px; letter-spacing: 0.03em; }
.drawer .actions { display: flex; gap: 8px; margin-top: 20px; }
.drawer .close-btn { float: right; background: none; color: var(--color-text-muted); padding: 4px 8px; }

.history-item {
  border-left: 2px solid var(--color-border);
  padding: 4px 0 4px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.hidden { display: none !important; }
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--color-text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
}
