:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-nested: #0f172a;
  --surface-nested-2: #0b1220;
  --sidebar: #0b0f1a;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-2: #e2e8f0;
  --text-dim: #94a3b8;
  --text-dim-2: #64748b;
  --text-muted: #475569;
  --accent: #c9a227;
  --accent-light: #f3e999;
  --accent-dark: #8b5e29;
  --accent-glow: rgba(201, 162, 39, 0.14);
  --accent-border: rgba(201, 162, 39, 0.3);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #d8b84a;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark img {
  width: 26px;
  height: 26px;
}

.brand-wordmark {
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-light) 50%, var(--accent-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.01em;
}

* { box-sizing: border-box; }

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

.view.hidden { display: none; }

#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#login-view.hidden,
#app-view.hidden {
  display: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

#login-form {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h1 { font-size: 1.4rem; margin: 0 0 8px; color: var(--text); }
h2 { font-size: 1.2rem; margin: 0; color: var(--text-2); }

input[type="text"], input[type="password"], input[type="file"], input[type="tel"], input[type="email"], textarea, select {
  background: var(--surface-nested);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

select option { background: var(--surface-nested); color: var(--text); }

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}

button.secondary {
  background: var(--border);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
}

button.danger { background: var(--danger); }

button:hover { opacity: 0.9; }

.error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.hint { color: var(--text-dim); }

/* --- App layout: sidebar + content --- */

#app-view {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-logo {
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0 20px 20px;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  background: none;
  border: none;
  border-right: 2px solid transparent;
  border-radius: 8px;
  color: var(--text-dim);
  text-align: left;
  padding: 9px 12px;
  margin: 0 8px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-item:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--info);
  font-weight: 600;
  border-right-color: var(--accent-border);
}

.nav-item.disabled {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.7;
}

.badge {
  font-size: 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--text-dim-2);
}

.sidebar-footer {
  padding: 0 20px;
}

.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 960px;
}

.content-section.hidden { display: none; }

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

form.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  max-width: 480px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-dim); font-weight: 500; }
td { color: var(--text-2); }

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.section-block { margin-bottom: 28px; }

.tag {
  display: inline-block;
  background: var(--surface-nested);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 2px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions button {
  padding: 4px 10px;
  font-size: 0.82rem;
}

#contacts-filter-info {
  cursor: pointer;
  text-decoration: underline;
}

td a {
  color: var(--info);
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}
