:root {
  --color-bg: #f3f5f8;
  --color-surface: #ffffff;
  --color-border: #e3e7ec;
  --color-text: #1c2530;
  --color-muted: #667085;
  --color-primary: #16273f;
  --color-primary-hover: #0e1b2e;
  --color-accent: #3b6ea5;
  --color-accent-soft: #eaf1f8;
  --color-success-bg: #e6f4ea;
  --color-success-text: #1e7a34;
  --color-error-bg: #fbe9e9;
  --color-error-text: #a3282f;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.05);

  --sidebar-width: 258px;
  --sidebar-bg: #0e1a2b;
  --sidebar-text: #a7b4c6;
  --sidebar-text-muted: #6d7c91;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(59, 110, 165, 0.22);
  --sidebar-active-text: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

h1 {
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
  color: var(--color-primary);
}

h2 {
  font-size: 1.1rem;
  font-weight: 650;
  margin: 2rem 0 0.75rem;
  color: var(--color-primary);
}

/* ---------- App shell (sidebar layout, authenticated pages) ---------- */

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.4rem 1.5rem;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.brand-name {
  color: #fff;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 0.9rem;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.sidebar-footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.user-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--sidebar-hover-bg);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 650;
}

.user-name {
  color: #d6dde6;
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-link {
  color: var(--sidebar-text-muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.logout-link:hover {
  color: #fff;
}

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  flex: 1;
}

.app-footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.8rem;
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* ---------- Guest shell (login / register) ---------- */

.guest-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1c2c44 0%, var(--color-primary) 55%, #0e1a2b 100%);
  padding: 2rem;
}

.guest-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2.25rem 2.5rem;
}

.guest-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.guest-brand .brand-name {
  color: var(--color-primary);
}

/* ---------- Dashboard: overview strip & sector tiles ---------- */

.overview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-pill {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.5rem;
  min-width: 150px;
}

.stat-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 2.25rem;
}

.sector-tile {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.sector-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.sector-tile-empty {
  border-style: dashed;
}

.sector-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sector-icon svg {
  width: 19px;
  height: 19px;
}

.sector-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
}

.sector-count {
  font-size: 0.78rem;
  color: var(--color-muted);
}

.sector-tile-empty .sector-count {
  color: var(--color-accent);
  font-weight: 650;
}

.dashboard-secondary {
  margin-top: 0.5rem;
}

/* ---------- Cards & dashboard grid ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
}

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

.card h2 {
  margin-top: 0;
  font-size: 0.98rem;
}

.stat-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.stat-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.stat-list li:last-child {
  border-bottom: none;
}

.badge {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 650;
}

.big-number {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0.25rem 0;
  letter-spacing: -0.02em;
}

/* ---------- Toolbar, buttons, forms ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.button, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.15rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
}

.button:hover, button[type="submit"]:hover {
  background: var(--color-primary-hover);
}

.link-button {
  background: none;
  border: none;
  color: var(--color-error-text);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: underline;
}

.inline-form {
  display: inline;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}

.form input, .form select, .form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

.data-table .actions {
  display: flex;
  gap: 0.9rem;
}

/* ---------- Alerts & misc ---------- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.hint {
  color: var(--color-muted);
  font-size: 0.84rem;
}

.document-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1.5rem;
}

.document-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.document-list li:last-child {
  border-bottom: none;
}

@media (max-width: 780px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.6rem 0.9rem;
  }

  .sidebar-footer {
    margin-left: auto;
    border-top: none;
    padding: 0.6rem 1.25rem;
  }

  .sidebar-user {
    margin-bottom: 0;
  }

  .container {
    padding: 1.5rem 1.25rem;
  }
}
