:root {
  --primary: #2455e6;
  --primary-dark: #1a3fc4;
  --primary-light: #eaefff;
  --dark: #10182b;
  --sidebar-bg: #101a34;
  --sidebar-hover: #1b2a4d;
  --gray-50: #f7f8fb;
  --gray-100: #eef0f5;
  --gray-200: #e2e5ec;
  --gray-400: #9aa1b2;
  --gray-600: #5c6579;
  --gray-800: #232b3d;
  --green: #17a673;
  --yellow: #e0a415;
  --red: #e34850;
  --blue: #2455e6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 43, 0.08), 0 1px 2px rgba(16, 24, 43, 0.06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 43, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14.5px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 6px; color: var(--dark); }
p { margin: 0 0 10px; color: var(--gray-600); }

/* ---------- AUTH PAGES ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10182b 0%, #2455e6 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 10px;
}
.auth-logo h1 { font-size: 20px; }
.auth-logo p { font-size: 13px; margin: 0; }

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--gray-800); }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=file],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--gray-800);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.help-text { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: 0.15s ease;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-danger { background: var(--red); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

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

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: #cfd6e8;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-mark {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
}
.sidebar-brand strong { color: #fff; font-size: 15.5px; display:block; }
.sidebar-brand span { font-size: 11px; color: #8b93ab; }

.sidebar-section { padding: 16px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #6f7896; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #cfd6e8;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--sidebar-hover); border-left-color: var(--primary); color: #fff; font-weight: 600; }
.sidebar nav a .ico { width: 18px; text-align: center; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.avatar-lg { width: 96px; height: 96px; font-size: 30px; }
.user-chip .name { font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
.user-chip .role { font-size: 11.5px; color: var(--gray-400); }

.content { padding: 26px; flex: 1; }

/* ---------- CARDS / GRID / TABLE ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { margin: 0; font-size: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stat-card .stat-num { font-size: 28px; font-weight: 800; color: var(--dark); }
.stat-card .stat-label { font-size: 12.5px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card.blue { border-left: 4px solid var(--primary); }
.stat-card.green { border-left: 4px solid var(--green); }
.stat-card.yellow { border-left: 4px solid var(--yellow); }
.stat-card.red { border-left: 4px solid var(--red); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; font-size: 13.5px; border-bottom: 1px solid var(--gray-100); }
th { color: var(--gray-400); font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: .03em; }
tr:hover td { background: var(--gray-50); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-blue { background: #e5edff; color: #2455e6; }
.badge-green { background: #e2f6ee; color: #17a673; }
.badge-yellow { background: #fdf1dc; color: #b9791f; }
.badge-red { background: #fde5e6; color: #e34850; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #e2f6ee; color: #0e7a54; }
.alert-error { background: #fde5e6; color: #c22; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

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

.pill-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.pill-tabs a { padding: 7px 15px; border-radius: 20px; background: var(--gray-100); color: var(--gray-600); font-size: 13px; font-weight: 600; }
.pill-tabs a.active { background: var(--primary); color: #fff; }
.pill-tabs a:hover { text-decoration: none; }

.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .sidebar { display:none; } }

.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--gray-200); font-size: 13.5px; }
.detail-row span:first-child { color: var(--gray-400); }
.detail-row span:last-child { font-weight: 600; }

/* ---------- CHAT ---------- */
.chat-wrap { display: flex; height: 68vh; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-list { width: 260px; border-right: 1px solid var(--gray-100); overflow-y: auto; flex-shrink: 0; }
.chat-list a { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--gray-800); border-bottom: 1px solid var(--gray-50); }
.chat-list a.active, .chat-list a:hover { background: var(--primary-light); text-decoration: none; }
.chat-body { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 60%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; }
.bubble-me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble-them { align-self: flex-start; background: var(--gray-100); color: var(--gray-800); border-bottom-left-radius: 4px; }
.bubble small { display: block; opacity: 0.65; font-size: 10.5px; margin-top: 4px; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--gray-100); }
.chat-input input { flex: 1; }

/* ---------- MISC ---------- */
.text-muted { color: var(--gray-400); }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: 12.5px; }
.divider { border: none; border-top: 1px solid var(--gray-100); margin: 18px 0; }
.chip-role { padding: 2px 9px; background: var(--gray-100); border-radius: 12px; font-size: 11px; font-weight: 700; color: var(--gray-600); margin-left: 6px;}
.profile-cover { background: linear-gradient(135deg, #10182b 0%, #2455e6 100%); height: 110px; border-radius: 12px 12px 0 0; }
.profile-header { text-align: center; margin-top: -50px; }
.profile-header .avatar-lg { border: 4px solid #fff; margin: 0 auto 10px; }
