@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300..700&display=swap');

:root {
  --primary: #111115;
  --primary-light: #2a2a2d;
  --primary-dark: #0a0a0d;
  --white: #ffffff;
  --background: #FFFFF5;
  --accent-pink: #F1C1F3;
  --accent-sage: #ACCDB5;
  --accent-lavender: #BBCAF0;
  --accent-amber: #F2B457;
  --border: #D7D7DA;
  --muted-fg: #6E6E73;
  --destructive: #D64545;
  --gray-50: #FAFAF7;
  --gray-100: #F5F4EE;
  --gray-200: #EEEEE5;
  --gray-300: #D7D7DA;
  --gray-400: #9ca3af;
  --gray-500: #6E6E73;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111115;
  --success: #ACCDB5;
  --warning: #F2B457;
  --error: #D64545;
  --info: #BBCAF0;
  --sidebar-bg: #1A1A1D;
  --sidebar-accent: #2A2A2D;
  --sidebar-border: #2A2A2D;
  --sidebar-fg: #F2F2F2;
  --radius: 0.375rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--background);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  font-size: 0.875rem;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.3; color: var(--gray-700); }
h4 { font-size: 0.875rem; font-weight: 600; color: var(--gray-600); }

a { color: inherit; text-decoration: none; }

.brand-gradient-strip {
  background: linear-gradient(to right, #F2B457, #F1C1F3, #BBCAF0, #ACCDB5);
  height: 4px;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.card-header { padding: 1.25rem 1.25rem 0; }
.card-content { padding: 1.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-ghost {
  background: transparent;
  color: var(--muted-fg);
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-destructive {
  background: var(--destructive);
  color: var(--white);
}
.btn-destructive:hover { opacity: 0.9; }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.input {
  display: flex;
  height: 2.75rem;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17,17,21,0.08);
}
.input::placeholder { color: var(--gray-400); }

.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-left: 2.5rem; }
.input-icon-wrap svg,
.input-icon-wrap .input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted-fg);
  pointer-events: none;
}

.label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  display: block;
  margin-bottom: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-success { background: #e8f0ea; color: #2d5a3a; border-color: #c0d8c6; }
.badge-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-error { background: #fecaca; color: #dc2626; border-color: #fca5a5; }
.badge-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.badge-muted { background: var(--gray-100); color: var(--muted-fg); border-color: var(--border); }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--white);
}
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: var(--gray-50); }
th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
td { padding: 0.75rem 1rem; color: var(--gray-600); border-top: 1px solid var(--gray-100); }
tr:hover { background: var(--gray-50); }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-logo { height: 3rem; width: auto; display: block; margin: 0 auto; }
.login-subtitle {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted-fg);
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
}
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--destructive);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  display: none;
}

/* Company selector */
.company-page { min-height: 100vh; }
.company-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.company-topbar-logo { height: 1.5rem; }
.company-topbar-right { display: flex; align-items: center; gap: 1rem; }
.company-topbar-user { font-size: 0.875rem; color: var(--gray-600); }

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}
.company-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  transition: all 0.2s;
  cursor: pointer;
}
.company-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.company-card-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.company-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.375rem;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.company-card-icon svg { width: 1.25rem; height: 1.25rem; color: var(--gray-600); }
.company-card-name { font-weight: 600; font-size: 0.9375rem; }
.company-card-sub { font-size: 0.75rem; color: var(--muted-fg); }
.company-card-meta { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8125rem; color: var(--muted-fg); margin-bottom: 0.75rem; }
.company-card-footer { display: flex; align-items: center; justify-content: flex-end; padding-top: 0.75rem; border-top: 1px solid var(--gray-100); }
.company-card-open { font-size: 0.8125rem; font-weight: 600; color: var(--gray-600); display: flex; align-items: center; gap: 0.25rem; }
.company-card-open:hover { color: var(--primary); }

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

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  transition: width 0.2s ease;
  z-index: 50;
}
.sidebar.collapsed { width: 72px; }

.sidebar-logo {
  height: 4rem;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo img { height: 20px; width: auto; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0; }

.sidebar-company {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  margin: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-company:hover { background: var(--sidebar-accent); }
.sidebar-company-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  background: var(--accent-sage);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-company-icon svg { width: 1rem; height: 1rem; color: var(--primary); }
.sidebar-company-info { flex: 1; min-width: 0; }
.sidebar-company-name { font-size: 0.8125rem; font-weight: 500; color: var(--sidebar-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-company-sub { font-size: 0.6875rem; color: rgba(242,242,242,0.6); }
.sidebar-company-switch { color: rgba(242,242,242,0.4); flex-shrink: 0; }
.sidebar-company-switch svg { width: 1rem; height: 1rem; }

.sidebar.collapsed .sidebar-company { justify-content: center; padding: 0.625rem; margin: 0.5rem 0.5rem; }
.sidebar.collapsed .sidebar-company-info,
.sidebar.collapsed .sidebar-company-switch { display: none; }

.sidebar-nav { flex: 1; padding: 0.5rem 0.75rem; display: flex; flex-direction: column; gap: 0.125rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
  color: rgba(242,242,242,0.7);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.sidebar-link:hover { background: var(--sidebar-accent); color: var(--sidebar-fg); }
.sidebar-link.active { background: rgba(42,42,45,0.8); color: var(--sidebar-fg); }
.sidebar-link.active svg { color: var(--accent-pink); }
.sidebar-link svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; transition: color 0.15s; }
.sidebar-link span { white-space: nowrap; }

.sidebar.collapsed .sidebar-link { justify-content: center; padding: 0.625rem; }
.sidebar.collapsed .sidebar-link span { display: none; }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
}
.sidebar-divider-line { flex: 1; height: 1px; background: var(--sidebar-border); }
.sidebar-divider-text { font-size: 0.625rem; font-weight: 500; color: rgba(242,242,242,0.4); text-transform: uppercase; letter-spacing: 0.1em; }
.sidebar.collapsed .sidebar-divider { display: none; }

.main-content { flex: 1; overflow-x: hidden; }
.page-content { padding: 1.5rem 2rem; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header-left h1 { margin-bottom: 0.25rem; }
.page-header-left p { color: var(--muted-fg); font-size: 0.875rem; }
.page-header-right { display: flex; align-items: center; gap: 0.5rem; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card-label { font-size: 0.75rem; color: var(--muted-fg); font-weight: 500; margin-bottom: 0.25rem; }
.stat-card-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.stat-card-sub { font-size: 0.6875rem; color: var(--gray-400); margin-top: 0.25rem; }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--white);
  border-radius: 0.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h2 { font-size: 1.125rem; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1.25rem;
  border-top: 1px solid var(--gray-100);
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 0.25rem;
}
.modal-close:hover { color: var(--gray-700); }

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

.text-muted { color: var(--muted-fg); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.hidden { display: none !important; }

/* Checkbox multiselect */
.checkbox-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 200px; overflow-y: auto; }
.checkbox-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.checkbox-item input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--muted-fg);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 200;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--primary); color: var(--white); }
.toast-error { background: var(--destructive); color: var(--white); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .company-grid { grid-template-columns: 1fr; }
}

/* Select */
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}
