/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #0e2820;
  --sidebar-hover: #163d2e;
  --sidebar-active: #1d5c44;
  --sidebar-text: #9abfb0;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 240px;

  --main-bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-hover: #b8d4c8;

  --text-primary: #0e2820;
  --text-secondary: #5a6a8a;
  --text-muted: #8a9ab8;

  --accent: #27b07a;
  --accent-hover: #1d9467;
  --accent-light: #e6f7f1;

  --green: #16a34a;
  --green-light: #dcfce7;
  --yellow: #ca8a04;
  --yellow-light: #fef9c3;
  --red: #dc2626;
  --red-light: #fee2e2;
  --gray: #6b7280;
  --gray-light: #f3f4f6;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--main-bg);
  line-height: 1.5;
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-mark {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo .logo-mark .dot {
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: 12px 20px 4px;
  opacity: .6;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.nav-link .icon {
  font-size: 16px;
  opacity: .8;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--sidebar-active);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  color: var(--sidebar-text-active);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-rolle {
  font-size: 11px;
  color: var(--sidebar-text);
}

.btn-logout {
  width: 100%;
  padding: 7px 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}

.btn-logout:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* ─── Toolbar / Filters ──────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.input-search {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.input-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,106,223,.10);
}

.filter-tabs {
  display: flex;
  gap: 2px;
  background: var(--gray-light);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all .15s;
  white-space: nowrap;
}

.filter-tab:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,.6);
}

.filter-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow);
}

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--gray-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover td { background: #dbeafe !important; }

tbody td {
  padding: 11px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-name {
  font-weight: 600;
  color: var(--text-primary);
}

.td-company {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.td-email a {
  color: var(--accent);
  text-decoration: none;
}

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

/* ─── Badges / Status ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-gray   { background: var(--gray-light);   color: var(--gray); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }

.badge::before {
  content: '';
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--gray-light);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.btn-page {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}

.btn-page:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-page:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ─── Detail View ────────────────────────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-avatar {
  width: 60px; height: 60px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.detail-title { flex: 1; }
.detail-title h1 { font-size: 22px; font-weight: 700; }
.detail-title .subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.detail-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-section-header {
  padding: 12px 16px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

.detail-fields {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}

.field-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}

.field-value a {
  color: var(--accent);
  text-decoration: none;
}

.field-value a:hover { text-decoration: underline; }

.field-value.empty { color: var(--text-muted); font-style: italic; }

/* ─── Activity Timeline ──────────────────────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-body { flex: 1; }
.activity-subject { font-weight: 500; font-size: 13.5px; }
.activity-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

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

.empty-state .icon { font-size: 32px; margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--border-hover); background: var(--gray-light); }

.btn-back {
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.btn-back:hover { color: var(--accent); }

/* ─── Login Page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e2820 0%, #163d2e 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--sidebar-bg);
}

.login-logo .mark .dot {
  width: 10px; height: 10px;
  background: #4ade80;
  border-radius: 50%;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,106,223,.12);
}

.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: 8px;
}

.btn-login:hover { background: var(--accent-hover); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

.login-error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible { display: block; }

/* ─── Loading ────────────────────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-240px);
    transition: transform .2s;
    width: 240px;
  }

  .sidebar.open { transform: translateX(0); --sidebar-width: 240px; }

  .main-content { margin-left: 0; }

  .topbar { padding: 12px 16px; }
  .page-body { padding: 16px; }

  .detail-grid { grid-template-columns: 1fr; }
  .filter-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
}

tbody tr:hover td{background:#dbeafe!important}
