/* =============================================================
   Dashboard styles
   ============================================================= */

:root {
  --d-navy:    #1f5778;
  --d-deep:    #1a4865;
  --d-orange:  #f5a361;
  --d-red:     #ef5b53;
  --d-teal:    #2db1c9;
  --d-purple:  #9c5ba3;

  --d-text:    #11202c;
  --d-muted:   #5b6776;
  --d-line:    #e4e7eb;
  --d-bg:      #f5f6f8;
  --d-card:    #ffffff;

  --d-radius:  14px;
  --d-radius-sm: 10px;
  --d-shadow:  0 8px 24px rgba(31, 87, 120, 0.06), 0 2px 6px rgba(31,87,120,0.05);
  --d-shadow-lg: 0 18px 48px rgba(31, 87, 120, 0.18);

  --d-font: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body.db-body {
  font-family: var(--d-font);
  background: var(--d-bg);
  color: var(--d-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; }
a { color: inherit; }

/* =============================================================
   LOGIN
   ============================================================= */
.db-login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(800px 600px at 90% 0%, rgba(31,87,120,0.07) 0%, transparent 70%),
    radial-gradient(600px 400px at 0% 100%, rgba(245,163,97,0.10) 0%, transparent 70%),
    linear-gradient(180deg, #f7f8fa 0%, #edf0f4 100%);
}
.db-login-stripe { display: flex; flex-direction: column; }
.db-login-stripe .s { width: 100%; }
.db-login-stripe .s-navy   { background: var(--d-navy);   height: 14px; }
.db-login-stripe .s-orange { background: var(--d-orange); height: 5px; }
.db-login-stripe .s-red    { background: var(--d-red);    height: 5px; }
.db-login-stripe .s-teal   { background: var(--d-teal);   height: 5px; }
.db-login-stripe .s-purple { background: var(--d-purple); height: 5px; }

.db-login-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 480px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 56px 48px;
  gap: 64px;
  align-items: center;
}
.db-login-aside { padding-right: 24px; }
.db-login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.db-login-wordmark {
  display: flex; flex-direction: column;
  font-weight: 800; font-size: 12px; line-height: 1.05;
  letter-spacing: 0.04em; color: var(--d-navy);
}
.db-login-wordmark sup { font-size: 0.6em; vertical-align: super; }

.db-login-hero {
  font-size: 48px; font-weight: 900; letter-spacing: -0.015em;
  color: #0f1d29; margin: 0 0 16px 0; line-height: 1.08;
  text-wrap: balance;
}
.db-login-blurb { font-size: 18px; color: var(--d-muted); margin: 0 0 40px 0; max-width: 460px; }

.db-login-feats { display: flex; flex-direction: column; gap: 14px; }
.db-login-feat {
  display: flex; align-items: center; gap: 14px;
  font-size: 15px; color: #2a2a2a;
}
.db-login-feat-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.db-login-feat-purple { background: var(--d-purple); }
.db-login-feat-teal   { background: var(--d-teal); }
.db-login-feat-orange { background: var(--d-orange); }

.db-login-form {
  background: var(--d-card);
  padding: 40px 44px;
  border-radius: 20px;
  box-shadow: var(--d-shadow-lg);
  display: flex; flex-direction: column;
  animation: db-in 0.4s ease both;
}
.db-login-form-title {
  font-size: 26px; font-weight: 800; color: var(--d-navy);
  margin: 0 0 6px 0; letter-spacing: -0.01em;
}
.db-login-form-sub { font-size: 14px; color: var(--d-muted); margin: 0 0 24px 0; }
.db-login-form .db-btn { width: 100%; justify-content: center; margin-top: 8px; }
.db-login-error {
  background: #fde6e4; color: #b13a32;
  padding: 10px 14px; border-radius: 10px;
  font-size: 14px; margin: 0 0 12px 0;
}
.db-login-help { font-size: 13px; color: var(--d-muted); text-align: center; margin: 22px 0 0 0; }

@keyframes db-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   SHELL — sidebar + topbar
   ============================================================= */
.db-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.db-side {
  background: linear-gradient(180deg, var(--d-navy) 0%, var(--d-deep) 100%);
  color: #fff;
  padding: 20px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.db-side-brand {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 16px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 18px;
}
.db-side-logo {
  max-width: 100%;
  width: 180px;
  height: auto;
  display: block;
  background: #ffffff;
  border-radius: 8px;
  padding: 8px 10px;
}
.db-side-wordmark {
  display: flex; flex-direction: column;
  font-weight: 800; font-size: 10px; letter-spacing: 0.04em;
  line-height: 1.15;
}

.db-side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.db-side-link {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; cursor: pointer;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.85);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.db-side-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.db-side-link.is-active {
  background: rgba(255,255,255,0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--d-orange);
}
.db-side-link-icon { font-size: 17px; width: 22px; display: inline-flex; justify-content: center; }
.db-side-link-text { flex: 1; }
.db-side-link-badge {
  background: var(--d-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.db-side-foot {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 8px;
}

/* Topbar */
.db-main { display: flex; flex-direction: column; min-height: 100vh; }
.db-top {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--d-line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 5;
}
.db-top-section {
  font-size: 17px; font-weight: 800;
  color: var(--d-navy);
}
.db-top-user { display: flex; align-items: center; gap: 12px; }
.db-top-user-meta { text-align: right; line-height: 1.1; min-width: 0; }
.db-top-user-name { font-size: 13px; font-weight: 700; color: var(--d-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.db-top-user-role { font-size: 11px; margin-top: 4px; }
.db-top-user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--d-navy), var(--d-deep));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  letter-spacing: 0.02em;
}

.db-content {
  padding: 28px 32px 64px;
  flex: 1;
}

/* =============================================================
   PAGE HEADER
   ============================================================= */
.db-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px;
  margin: 4px 0 22px;
  flex-wrap: wrap;
}
.db-page-title {
  font-size: 28px; font-weight: 900;
  color: var(--d-navy);
  margin: 0; letter-spacing: -0.01em;
}
.db-page-sub { color: var(--d-muted); margin: 4px 0 0 0; font-size: 14px; }
.db-page-actions { display: flex; gap: 10px; align-items: center; }

/* =============================================================
   BUTTONS
   ============================================================= */
.db-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; cursor: pointer;
  font-weight: 700; letter-spacing: 0.01em;
  border-radius: 10px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}
.db-btn:focus-visible { outline: 3px solid rgba(31,87,120,0.35); outline-offset: 2px; }
.db-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.db-btn-sm { padding: 8px 14px;  font-size: 13px; }
.db-btn-md { padding: 11px 18px; font-size: 14px; }
.db-btn-primary {
  background: var(--d-navy); color: #fff;
  box-shadow: 0 6px 14px rgba(31,87,120,0.22);
}
.db-btn-primary:hover:not(:disabled) { background: var(--d-deep); transform: translateY(-1px); }
.db-btn-secondary {
  background: #fff; color: var(--d-navy);
  border: 1.5px solid var(--d-line);
}
.db-btn-secondary:hover:not(:disabled) { border-color: var(--d-navy); }
.db-btn-ghost {
  background: transparent; color: var(--d-navy);
}
.db-btn-ghost:hover:not(:disabled) { background: rgba(31,87,120,0.06); }
.db-btn-danger {
  background: var(--d-red); color: #fff;
  box-shadow: 0 6px 14px rgba(239,91,83,0.25);
}
.db-btn-danger:hover:not(:disabled) { background: #cf483f; }

.db-btn-icon { display: inline-flex; }
.db-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  animation: db-spin 0.7s linear infinite;
}
.db-btn-secondary .db-spinner,
.db-btn-ghost .db-spinner { border-color: rgba(31,87,120,0.25); border-top-color: var(--d-navy); }
.db-spinner-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes db-spin { to { transform: rotate(360deg); } }

.db-icon-btn {
  border: 0; background: transparent; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--d-navy);
  transition: background 0.15s ease, color 0.15s ease;
}
.db-icon-btn:hover { background: rgba(31,87,120,0.08); }
.db-icon-btn-danger { color: var(--d-red); }
.db-icon-btn-danger:hover { background: rgba(239,91,83,0.10); }

/* =============================================================
   FIELDS
   ============================================================= */
.db-field {
  display: flex; flex-direction: column; margin: 0 0 14px 0;
}
.db-field-label {
  font-size: 12px; font-weight: 700; color: var(--d-navy);
  letter-spacing: 0.04em; text-transform: uppercase;
  margin: 0 0 6px 4px;
}
.db-input, .db-select {
  font: inherit; font-size: 15px;
  color: var(--d-text);
  background: #fff;
  border: 1.5px solid var(--d-line);
  border-radius: 10px;
  padding: 11px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.db-input:focus, .db-select:focus {
  outline: none; border-color: var(--d-navy); background: #fff;
}
.db-input.is-error { border-color: var(--d-red); }
.db-field-hint  { color: var(--d-muted); font-size: 12px; margin: 6px 0 0 4px; }
.db-field-error { color: var(--d-red);  font-size: 12px; margin: 6px 0 0 4px; }

.db-search {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--d-line);
  min-width: 240px;
  transition: border-color 0.15s ease;
}
.db-search:focus-within { border-color: var(--d-navy); }
.db-search-icon { color: var(--d-muted); font-size: 16px; }
.db-search-input {
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: 14px;
  flex: 1; padding: 0;
}

.db-checkbox {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--d-text);
  cursor: pointer;
  margin: 6px 0;
}
.db-checkbox input { width: 16px; height: 16px; accent-color: var(--d-navy); }

/* =============================================================
   TABLES
   ============================================================= */
.db-table-wrap {
  background: var(--d-card);
  border-radius: var(--d-radius);
  box-shadow: var(--d-shadow);
  overflow: hidden;
}
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.db-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--d-muted);
  font-weight: 800;
  padding: 14px 18px;
  background: #fafbfc;
  border-bottom: 1px solid var(--d-line);
}
.db-table td {
  padding: 14px 18px;
  border-top: 1px solid var(--d-line);
  vertical-align: middle;
}
.db-table tr:first-child td { border-top: 0; }
.db-table tr { transition: background 0.12s ease; }
.db-table tbody tr:hover { background: rgba(31,87,120,0.025); }
.db-table-sub { color: var(--d-muted); font-size: 12px; margin-top: 2px; }
.db-row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }

.db-empty {
  padding: 36px;
  text-align: center;
  color: var(--d-muted);
  background: var(--d-card);
  border-radius: var(--d-radius);
  box-shadow: var(--d-shadow);
}
.db-empty-rich {
  background: var(--d-card);
  border-radius: var(--d-radius);
  box-shadow: var(--d-shadow);
  padding: 48px 32px;
  text-align: center;
}
.db-empty-icon { font-size: 36px; opacity: 0.8; margin-bottom: 12px; }
.db-empty-title { font-size: 18px; font-weight: 800; color: var(--d-navy); margin-bottom: 6px; }
.db-empty-body { color: var(--d-muted); font-size: 14px; max-width: 420px; margin: 0 auto 16px; }

.db-skel-wrap { display: flex; flex-direction: column; gap: 10px; }
.db-skel-row {
  height: 56px;
  background: linear-gradient(90deg, #eef0f3 0%, #f6f7f9 50%, #eef0f3 100%);
  background-size: 200% 100%;
  animation: db-skel 1.4s ease-in-out infinite;
  border-radius: var(--d-radius-sm);
}
@keyframes db-skel {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================
   BADGES
   ============================================================= */
.db-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.db-badge-navy   { background: rgba(31,87,120,0.10);  color: var(--d-navy); }
.db-badge-purple { background: rgba(156,91,163,0.14); color: var(--d-purple); }
.db-badge-teal   { background: rgba(45,177,201,0.14); color: var(--d-teal); }
.db-badge-orange { background: rgba(245,163,97,0.18); color: #b56518; }

/* =============================================================
   MODAL
   ============================================================= */
.db-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 30, 41, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: db-fade 0.18s ease both;
}
@keyframes db-fade { from { opacity: 0 } to { opacity: 1 } }
.db-modal {
  background: var(--d-card);
  border-radius: 16px;
  box-shadow: var(--d-shadow-lg);
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: db-pop 0.22s cubic-bezier(.2,.8,.2,1.05) both;
}
@keyframes db-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.db-modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--d-line);
  display: flex; justify-content: space-between; align-items: center;
}
.db-modal-head h3 { margin: 0; font-size: 17px; color: var(--d-navy); font-weight: 800; }
.db-modal-x {
  border: 0; background: transparent; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--d-muted);
  width: 32px; height: 32px; border-radius: 8px;
}
.db-modal-x:hover { background: var(--d-line); color: var(--d-text); }
.db-modal-body { padding: 22px; overflow-y: auto; }
.db-modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--d-line);
  display: flex; gap: 10px; justify-content: flex-end;
}
.db-modal-lede { color: var(--d-muted); font-size: 14px; margin: 0 0 16px 0; line-height: 1.5; }

.db-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-bottom: 22px;
}
.db-detail-cell { background: #fafbfc; border-radius: 10px; padding: 12px 14px; }
.db-detail-k { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
               color: var(--d-muted); font-weight: 700; margin-bottom: 4px; }
.db-detail-v { font-size: 14px; font-weight: 600; color: var(--d-text); }
.db-detail-h { font-size: 14px; font-weight: 800; color: var(--d-navy);
               text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 12px 0; }
.db-meters { display: flex; flex-direction: column; gap: 10px; }
.db-meter-row {
  display: grid; grid-template-columns: 180px 1fr 170px;
  gap: 14px; align-items: center;
  font-size: 14px;
}
.db-meter-name { color: var(--d-navy); font-weight: 700; }
.db-meter-bar {
  background: var(--d-line);
  height: 10px; border-radius: 999px; overflow: hidden;
}
.db-meter-fill {
  height: 100%; border-radius: 999px;
  background: var(--d-navy);
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}
.db-meter-num { text-align: right; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* =============================================================
   TOASTS
   ============================================================= */
.db-toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.db-toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  background: #11202c; color: #fff;
  box-shadow: var(--d-shadow-lg);
  animation: db-toast-in 0.22s cubic-bezier(.2,.8,.2,1.05) both;
}
@keyframes db-toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.db-toast-ok  { background: linear-gradient(140deg, #1f5778, #1a4865); }
.db-toast-err { background: linear-gradient(140deg, #ef5b53, #cf483f); }
.db-toast-info{ background: linear-gradient(140deg, #2db1c9, #1f8aa3); }

/* =============================================================
   SETTINGS
   ============================================================= */
.db-settings-card {
  background: var(--d-card);
  padding: 28px;
  border-radius: var(--d-radius);
  box-shadow: var(--d-shadow);
  max-width: 520px;
}
.db-settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
}
.db-settings-k { color: var(--d-muted); font-size: 13px; }
.db-settings-v { color: var(--d-text);  font-size: 14px; font-weight: 600; }
.db-settings-divider { height: 1px; background: var(--d-line); margin: 16px 0 22px; }
.db-settings-actions { margin-top: 14px; display: flex; justify-content: flex-end; }

/* =============================================================
   FULL-PAGE LOADER / ERROR
   ============================================================= */
.db-fullpage-loader,
.db-error-screen {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  color: var(--d-muted);
}
.db-error-card {
  max-width: 460px;
  background: var(--d-card);
  border-radius: var(--d-radius);
  box-shadow: var(--d-shadow);
  padding: 32px;
  text-align: center;
}
.db-error-card h2 { margin: 0 0 8px 0; color: var(--d-navy); }
.db-error-card p { color: var(--d-muted); margin: 0 0 18px 0; }

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 860px) {
  .db-login-grid { grid-template-columns: 1fr; padding: 32px 22px; gap: 32px; }
  .db-login-hero { font-size: 38px; }
  .db-shell { grid-template-columns: 1fr; }
  .db-side {
    position: sticky;
    top: 0;
    height: auto;
    padding: 12px;
    flex-direction: row;
    overflow-x: auto;
    z-index: 6;
  }
  .db-side-brand { border: 0; padding: 8px; margin: 0 14px 0 0; }
  .db-side-wordmark { display: none; }
  .db-side-nav { flex-direction: row; flex: 1; gap: 4px; }
  .db-side-foot { border: 0; padding: 0; }
  .db-side-link-text { display: none; }
  .db-side-link.is-active { box-shadow: inset 0 -3px 0 var(--d-orange); }
  .db-content { padding: 18px; }
  .db-meter-row { grid-template-columns: 1fr; }
}
