:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #132238;
  --muted: #607086;
  --border: #d9e4ef;
  --primary: #2368d5;
  --primary-dark: #174ea6;
  --primary-soft: #e8f1ff;
  --danger: #cf2e2e;
  --danger-soft: #fff0f0;
  --shadow: 0 24px 70px rgba(22, 42, 78, 0.14);
  --shadow-soft: 0 10px 30px rgba(22, 42, 78, 0.08);
  --radius: 12px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
}

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

a:hover { color: var(--primary-dark); }

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(35, 104, 213, 0.22);
  outline-offset: 2px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 12%, rgba(35, 104, 213, 0.12), transparent 32%),
    linear-gradient(135deg, #f7fbff 0%, #edf4fb 100%);
}

.login-shell {
  width: min(800px, 100%);
  min-height: 480px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(390px, 1.05fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(217, 228, 239, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  min-height: 100%;
  padding: 40px;
  color: #ffffff;
  background: linear-gradient(145deg, #12345d 0%, #174ea6 100%);
}

.login-brand-logo {
  display: block;
  width: min(200px, 70%);
  height: auto;
  max-height: 70px;
  object-fit: contain;
  object-position: left center;
}

.brand-copy h1,
.login-header h2,
.content h1,
.columns h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-copy h1 {
  max-width: 360px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 750;
}

.brand-copy p {
  max-width: 360px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.6;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
  background: var(--surface);
}

.login-header {
  margin-bottom: 20px;
}

.login-header h2 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 750;
}

.login-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
  width: 100%;
}

.field-group {
  display: grid;
  gap: 6px;
}

label {
  color: #22334d;
  font-weight: 650;
  font-size: 14px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  padding: 0 14px;
}

input:hover,
select:hover {
  border-color: #b7c8dc;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(35, 104, 213, 0.1);
  outline: none;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  align-items: stretch;
  gap: 10px;
}

.password-row input,
.password-row button {
  height: 46px;
}

.primary-button,
.secondary-button,
.danger-button,
.topbar button,
.inline-form button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(35, 104, 213, 0.22);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: #24405f;
  box-shadow: none;
}

.secondary-button:hover {
  border-color: #b9cce0;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.login-button {
  width: 100%;
  height: 40px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.form-row,
.page-title,
.topbar,
.topbar div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.remember-row {
  justify-content: flex-start;
  min-height: 24px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--primary);
}

.error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #ffd0d0;
  border-radius: 10px;
  background: var(--danger-soft);
  color: #9f1d1d;
  font-weight: 650;
}

.loader {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading .loader { display: inline-block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(22, 42, 78, 0.06);
  backdrop-filter: blur(10px);
}

.topbar strong {
  font-size: 16px;
}

.topbar a {
  font-weight: 650;
}

.topbar form { margin: 0; }

.topbar button {
  background: #eef4fb;
  color: #24405f;
}

.topbar button:hover {
  background: #dfeaf6;
}

.content {
  width: min(1180px, calc(100vw - 40px));
  margin: 30px auto;
}

.page-title {
  margin-bottom: 18px;
}

.page-title h1 {
  font-size: 28px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 16px;
}

.metric-grid article,
.columns > div,
table,
.create-form,
.inline-form {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.metric-grid article,
.columns > div {
  padding: 18px;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-weight: 650;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.columns {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}

th {
  color: #52647a;
  background: #f7faff;
  font-size: 13px;
  font-weight: 750;
}

tr:last-child td {
  border-bottom: 0;
}

.create-form {
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  padding: 14px;
  margin: 16px 0;
}

.inline-form {
  grid-template-columns: minmax(180px, 1fr) 156px auto;
  align-items: center;
  padding: 10px;
  box-shadow: none;
}

.actions-cell {
  width: 108px;
}

.danger-button {
  min-height: 36px;
  border: 1px solid #f2b7b7;
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-button:hover {
  border-color: #e58989;
  background: #ffe4e4;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #e2e8f0;
  color: #475569;
}

.status.active { background: #d8f3dc; color: #116530; }
.status.disabled,
.status.deleted { background: #fee2e2; color: #991b1b; }
.status.pending { background: #fef3c7; color: #92400e; }
.download-url { max-width: 360px; overflow-wrap: anywhere; color: #31506f; }

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

@media (max-width: 920px) {
  .auth-page { padding: 22px; }
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .brand-panel {
    min-height: 260px;
    padding: 36px;
  }
  .brand-copy h1 { font-size: 28px; }
  .login-panel { padding: 36px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .columns { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .auth-page { padding: 14px; align-items: start; }
  .login-shell { border-radius: 10px; }
  .brand-panel,
  .login-panel { padding: 26px; }
  .brand-logo { width: min(230px, 100%); }
  .login-header h2 { font-size: 24px; }
  .password-row { grid-template-columns: minmax(0, 1fr) 76px; gap: 8px; }
  .secondary-button { padding: 0 10px; }
  .topbar,
  .topbar div,
  .page-title { align-items: flex-start; flex-direction: column; }
  .content { width: min(100% - 24px, 1180px); margin: 20px auto; }
  .metric-grid,
  .create-form,
  .inline-form { grid-template-columns: 1fr; }
}

/* =========================================
   ADDITIONAL UI STYLES (USERS, SETTINGS)
   ========================================= */

.settings-nav .nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.settings-nav .nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--primary-color);
}

.settings-nav .nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-weight: 600;
}

.dropdown-toggle-hide-arrow::after {
  display: none !important;
}

.custom-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =========================================
   ROLES & PERMISSIONS MODULE
   ========================================= */

.permission-matrix th {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
}

.permission-matrix td {
  vertical-align: middle;
}

.permission-matrix .sticky-col.first-col {
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 2px solid var(--border-color);
  box-shadow: 2px 0 5px rgba(0,0,0,0.02);
}

.matrix-check {
  width: 1.25em;
  height: 1.25em;
  cursor: pointer;
  transition: transform 0.1s ease-in-out;
}

.matrix-check:hover {
  transform: scale(1.1);
}

.matrix-check:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}


/* =========================================
   NEW DASHBOARD REDESIGN STYLES
   ========================================= */

/* Layout */
body {
  background-color: #f4f6f9;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #102a5c 0%, #1a438a 100%);
  color: #fff;
  flex-shrink: 0;
  transition: all 0.3s;
}

.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Important for flex child to not overflow */
}

/* Sidebar Brand & Header */
.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #0dcfc4; /* accent color from mockup */
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.sidebar-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
}

/* Sidebar Navigation */
.sidebar-nav .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 12px 24px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
  font-size: 18px;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.sidebar-nav .nav-link.active {
  border-left-color: #0dcfc4;
}

/* Topbar */
.topbar {
  height: 70px;
  padding: 0 32px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.search-bar {
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-input {
  padding-left: 36px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: none;
}

.search-input:focus {
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: none;
}

.notification-btn {
  cursor: pointer;
}

.notification-dot {
  width: 8px;
  height: 8px;
  padding: 0 !important;
}

.user-avatar {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

/* Page Content */
.page-content {
  padding: 32px;
  flex-grow: 1;
}

/* Redesigned Cards */
.dash-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  padding: 24px;
}

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

.dash-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

/* Metric Cards */
.metric-box {
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.bg-blue-soft { background: #eff6ff; color: #3b82f6; }
.bg-red-soft { background: #fef2f2; color: #ef4444; }
.bg-purple-soft { background: #faf5ff; color: #a855f7; }
.bg-orange-soft { background: #fff7ed; color: #f97316; }
.bg-gray-soft { background: #f1f5f9; color: #64748b; }

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.metric-number {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1;
  margin: 0;
}

/* Activity Feed */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  position: relative;
  padding-left: 24px;
  padding-bottom: 20px;
}

.activity-item:last-child {
  padding-bottom: 0;
}

.activity-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.activity-item:last-child::before {
  display: none;
}

.activity-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
}

.activity-text {
  font-size: 14px;
  color: #334155;
  margin: 0 0 4px 0;
}

.activity-time {
  font-size: 12px;
  color: #94a3b8;
  margin: 0;
}
