@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700;800&family=Mulish:wght@400;500;600;700;800&display=swap");

* { box-sizing: border-box; }

:root {
  --ink: #16273F;
  --body: #33404F;
  --muted: #8791A0;
  --muted2: #5B6675;
  --muted3: #98A2B0;
  --card-border: #EAEDF3;
  --red: #E8402A;
}

html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: "Mulish", system-ui, sans-serif;
  color: var(--body);
  background: linear-gradient(180deg, #F5F3FB 0%, #F1F6F6 100%);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
body.auth-pending .app-shell { display: none; }
.app-shell .rm-header-inner, .app-shell .rm-footer-inner { max-width: 90%; }

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

/* ------------------------------- Buttons ------------------------------- */
.db-btn { display: inline-flex; align-items: center; gap: 8px; font-family: "Lexend", sans-serif; font-weight: 600; font-size: 14px; border-radius: 12px; padding: 11px 18px; border: 1px solid transparent; text-decoration: none; white-space: nowrap; transition: all .15s ease; }
.db-btn-outline { background: #fff; color: var(--ink); border-color: #E4E8EF; box-shadow: 0 1px 2px rgba(18,38,63,0.05); }
.db-btn-outline:hover { border-color: #3C7CE0; color: #3C7CE0; }
.db-btn-red { background: var(--red); color: #fff; box-shadow: 0 6px 16px rgba(232,64,42,0.25); }
.db-btn-red:hover { background: #cf3925; }
.db-btn-blue { background: #2F6FE0; color: #fff; }
.db-btn-blue:hover { background: #1E56C0; }
.db-btn-dark { background: #16273F; color: #fff; }
.db-btn-dark:hover { background: #0f1b2d; }
.db-btn-ghost { background: #fff; color: var(--ink); border-color: #E4E8EF; box-shadow: 0 1px 2px rgba(18,38,63,0.05); }
.db-btn-ghost:hover { border-color: #16273F; }

/* ------------------------------- Hero ------------------------------- */
.db-hero-inner { max-width: 90%; margin: 0 auto; padding: 30px 32px 4px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.db-greeting { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 38px; line-height: 1.05; letter-spacing: -0.5px; color: var(--ink); margin: 0 0 6px; }
.db-subtitle { font-size: 15.5px; color: var(--muted2); }
.db-hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.db-edit-toolbar { max-width: 90%; margin: 14px auto 0; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.db-toolbar-hint { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted2); font-weight: 600; }

/* ------------------------------- Widget grid ------------------------------- */
.db-main { flex: 1; max-width: 90%; width: 100%; margin: 0 auto; padding: 22px 32px 56px; }
.db-gridwrap { position: relative; }
.db-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; align-items: stretch; position: relative; z-index: 1; }
/* Boxed guide layer (4 columns × fixed rows), revealed while dragging/resizing —
   matches the grid columns + the 128px row unit used for height snapping. */
.db-grid-guides { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 128px; gap: 24px; align-content: start; overflow: hidden; opacity: 0; transition: opacity .15s ease; pointer-events: none; z-index: 0; }
.db-grid-guides span { border-radius: 14px; background: rgba(60,124,224,0.05); border: 1px dashed rgba(60,124,224,0.28); }
.db-gridwrap.show-grid .db-grid-guides { opacity: 1; }
.db-w { grid-column: span 4; min-width: 0; animation: dbFadeUp 0.3s ease both; display: flex; flex-direction: column; }
/* A widget with an explicit (resized) height scrolls its body instead of overflowing. */
.db-w--sized { overflow: hidden; }
.db-w--sized .db-w-body { overflow: auto; min-height: 0; }
.db-w-body { flex: 1; min-width: 0; }
.db-grid.editing .db-w { position: relative; outline: 1.5px dashed #C9D2DE; outline-offset: 4px; border-radius: 22px; cursor: grab; }
.db-grid.editing .db-w:hover { outline-color: #3C7CE0; }
.db-w.dragging { opacity: 0.45; }
.db-w.drop-target { outline: 2px solid #3C7CE0 !important; outline-offset: 4px; }
.db-w.resizing { outline: 2px solid #3C7CE0 !important; }
/* Bottom-right corner resize grip (diagonal lines). */
.db-w-resize { position: absolute; right: 5px; bottom: 5px; width: 18px; height: 18px; z-index: 3; cursor: nwse-resize; touch-action: none; border-radius: 5px;
  background-image: repeating-linear-gradient(135deg, #9AA5B4 0 1.5px, transparent 1.5px 4px); opacity: .75; }
.db-w-resize:hover { opacity: 1; }
.db-resize-badge { position: absolute; z-index: 6; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 12px; color: #fff; background: #16273F; border-radius: 8px; padding: 5px 10px; pointer-events: none; box-shadow: 0 4px 12px rgba(18,38,63,0.28); }
.db-w-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.db-w-handle { display: inline-flex; align-items: center; gap: 8px; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.db-w-remove { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: #fff; border: 1px solid #E4E8EF; }
.db-w-remove:hover { border-color: var(--red); background: #FCECEA; }

/* ------------------------------- Score widget ------------------------------- */
.db-scorecard { background: #16273F; border-radius: 22px; padding: 30px; height: 100%; display: flex; align-items: center; gap: 24px; box-shadow: 0 4px 20px rgba(18,38,63,0.10); }
.db-ring { position: relative; width: 124px; height: 124px; flex: 0 0 auto; border-radius: 50%; }
.db-ring-hole { position: absolute; inset: 13px; background: #16273F; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.db-ring-value { font-family: "Lexend", sans-serif; font-weight: 800; font-size: 28px; color: #fff; line-height: 1; }
.db-ring-level { font-size: 10px; color: #8CA0B8; font-weight: 700; letter-spacing: 0.5px; margin-top: 3px; }
.db-score-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 26px; color: #fff; line-height: 1.1; }
.db-score-sub { font-size: 13.5px; color: #A9B7C9; margin-top: 8px; line-height: 1.5; }
.db-score-badge { display: inline-flex; align-items: center; margin-top: 14px; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 12.5px; color: #7BE0AE; background: rgba(63,208,138,0.14); border: 1px solid rgba(63,208,138,0.3); border-radius: 8px; padding: 5px 12px; }

/* ------------------------------- Key stats widget ------------------------------- */
.db-keystats { background: #fff; border: 1px solid var(--card-border); border-radius: 22px; box-shadow: 0 4px 20px rgba(18,38,63,0.05); padding: 30px 34px; height: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 26px 40px; }
.db-keystat-top { display: flex; align-items: center; gap: 10px; }
.db-keystat-value { font-family: "Lexend", sans-serif; font-weight: 800; font-size: 30px; color: var(--ink); line-height: 1; }
.db-keystat-delta { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 11.5px; color: #1FA97A; background: #E7F7F1; border-radius: 999px; padding: 3px 9px; }
.db-keystat-desc { font-size: 13.5px; color: var(--muted2); margin-top: 8px; line-height: 1.5; }

/* ------------------------------- Section head (domains/products) ------------------------------- */
.db-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.db-section-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 22px; color: var(--ink); margin: 0; }
.db-section-sub { font-size: 14px; color: var(--muted2); margin-top: 3px; }
.db-section-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ------------------------------- Domains ------------------------------- */
.db-domains { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.db-domain { background: #fff; border: 1px solid var(--card-border); border-radius: 18px; box-shadow: 0 4px 16px rgba(18,38,63,0.05); padding: 16px; }
.db-domain-shot { height: 210px; border-radius: 12px; display: flex; align-items: flex-end; padding: 14px; color: rgba(255,255,255,0.92); font-family: "Lexend", sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.db-domain-head { display: flex; align-items: center; gap: 12px; margin: 16px 4px 0; }
.db-domain-fav { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; background: #F2F4F8; display: flex; align-items: center; justify-content: center; }
.db-domain-name { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.db-domain-host { font-size: 12.5px; color: var(--muted); }
.db-domain-score { margin-left: auto; flex: 0 0 auto; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 13px; color: #C79020; background: #FCF3DC; border-radius: 8px; padding: 6px 12px; }
.db-domain-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.db-domain-stat { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.db-domain-stat-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.db-domain-stat-value { font-family: "Lexend", sans-serif; font-weight: 800; font-size: 17px; color: var(--ink); }
.db-domain-stat-label { font-size: 12px; color: var(--muted); }
.db-domain-foot { display: flex; align-items: center; gap: 12px; }
.db-domain-del { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; background: #fff; border: 1px solid #E4E8EF; display: flex; align-items: center; justify-content: center; }
.db-domain-del:hover { border-color: var(--red); }
.db-domain-view { flex: 1; justify-content: center; padding: 13px; }

/* ------------------------------- Products ------------------------------- */
.db-products { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.db-product { display: block; background: #fff; border: 1px solid var(--card-border); border-left: 4px solid #ccc; border-radius: 14px; box-shadow: 0 4px 16px rgba(18,38,63,0.05); padding: 20px; transition: all .16s ease; }
.db-product:hover { box-shadow: 0 10px 26px rgba(18,38,63,0.10); transform: translateY(-1px); }
.db-product-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.db-product-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.db-product-trend { display: inline-flex; align-items: center; gap: 6px; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 12.5px; color: #1FA97A; }
.db-product-go { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 7px; border: 1px solid #EAEDF3; margin-left: 4px; }
.db-product-name { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 15.5px; color: var(--ink); }
.db-product-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; margin-bottom: 18px; line-height: 1.5; min-height: 36px; }
.db-product-metric-row { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.db-product-metric { font-family: "Lexend", sans-serif; font-weight: 800; font-size: 27px; color: var(--ink); line-height: 1; }
.db-product-unit { font-size: 13.5px; color: var(--muted2); font-weight: 600; }
.db-product-sub { font-size: 12.5px; color: var(--muted); margin-left: auto; }

/* ------------------------------- Attention / Activity ------------------------------- */
/* These two widgets live inside a white card body (unlike the section widgets). */
.db-w:has(.db-card-head) .db-w-body { background: #fff; border: 1px solid var(--card-border); border-radius: 18px; box-shadow: 0 4px 16px rgba(18,38,63,0.05); padding: 24px; }
.db-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.db-card-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); margin: 0; }
.db-card-when { font-size: 13px; color: var(--muted3); font-weight: 600; }
.db-badge-red { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 12px; color: var(--red); background: #FCECEA; border-radius: 999px; padding: 5px 12px; }

.db-attn { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid #F1F4F8; }
.db-attn:last-child { border-bottom: none; }
.db-attn:hover .db-attn-text { color: var(--red); }
.db-attn-icon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.db-attn-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.db-attn-text { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 14.5px; color: var(--ink); }
.db-attn-product { font-size: 12.5px; color: var(--muted3); margin-top: 2px; }
.db-attn-count { flex: 0 0 auto; font-family: "Lexend", sans-serif; font-weight: 700; font-size: 13px; color: #C0392B; background: #FCECEC; border-radius: 999px; padding: 4px 13px; }

.db-act { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; }
.db-act-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; }
.db-act-main { flex: 1; min-width: 0; }
.db-act-text { font-size: 14px; color: var(--body); line-height: 1.5; }
.db-act-text strong { color: var(--ink); font-weight: 700; }
.db-act-time { font-size: 12.5px; color: var(--muted3); }
.db-act-empty { padding: 18px 2px; font-size: 13.5px; color: var(--muted3); }

/* ------------------------------- Widget library cards ------------------------------- */
.db-lib { background: #fff; border: 1px solid #EAEDF3; border-radius: 20px; box-shadow: 0 4px 18px rgba(18,38,63,0.05); padding: 26px 28px; height: 100%; }
.db-lib-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 18px; color: #16273F; letter-spacing: -0.2px; }
.db-lib-sub { font-size: 13.5px; color: #8791A0; margin-top: 3px; }

/* ------------------------------- Fake widget ------------------------------- */
.db-fake { background: #fff; border: 1px dashed #D3DBE6; border-radius: 18px; padding: 28px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; min-height: 150px; }
.db-fake-icon { width: 46px; height: 46px; border-radius: 12px; background: #F2F4F8; display: flex; align-items: center; justify-content: center; }
.db-fake-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); margin-top: 4px; }
.db-fake-desc { font-size: 13px; color: var(--muted); max-width: 320px; line-height: 1.5; }
.db-fake-tag { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #8791A0; background: #F2F4F8; border-radius: 999px; padding: 4px 10px; margin-top: 6px; }

/* ------------------------------- Add-widget panel ------------------------------- */
.db-add-overlay { position: fixed; inset: 0; background: rgba(16,26,40,0.45); z-index: 80; opacity: 0; transition: opacity .26s ease; }
.db-add-overlay.show { opacity: 1; }
.db-add-panel { position: fixed; top: 0; right: 0; height: 100%; width: 420px; max-width: 94vw; background: #F6F7FA; z-index: 85; overflow-y: auto; box-shadow: -18px 0 50px rgba(16,26,40,0.22); transform: translateX(104%); transition: transform .28s cubic-bezier(.22,.61,.36,1); }
.db-add-panel.show { transform: translateX(0); }
.db-add-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 16px; position: sticky; top: 0; background: rgba(246,247,250,0.94); backdrop-filter: blur(6px); border-bottom: 1px solid #ECEEF3; }
.db-add-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 19px; color: var(--ink); }
.db-add-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.db-add-close { width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid #E4E8EF; display: flex; align-items: center; justify-content: center; }
.db-add-list { padding: 16px 22px 34px; display: flex; flex-direction: column; gap: 12px; }
.db-add-item { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: #fff; border: 1px solid #E9ECF2; border-radius: 14px; padding: 14px 16px; transition: all .15s ease; }
.db-add-item:hover { border-color: #3C7CE0; box-shadow: 0 6px 16px rgba(18,38,63,0.08); }
.db-add-item-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px; background: #EAF1FC; display: flex; align-items: center; justify-content: center; }
.db-add-item-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.db-add-item-title { font-family: "Lexend", sans-serif; font-weight: 700; font-size: 15px; color: var(--ink); }
.db-add-item-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.db-add-item-plus { flex: 0 0 auto; }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 1180px) {
  .db-products { grid-template-columns: repeat(2, 1fr); }
  .db-domains { grid-template-columns: 1fr; }
  .db-w { grid-column: span 4 !important; }
  .db-keystats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .db-hero-inner, .db-main, .db-edit-toolbar { padding-left: 20px; padding-right: 20px; }
  .db-products { grid-template-columns: 1fr; }
  .db-keystats { grid-template-columns: 1fr; }
  .db-greeting { font-size: 30px; }
}

/* Add-widget popout: category groups (General, then per product). */
.db-add-group { display: flex; flex-direction: column; gap: 10px; }
.db-add-group + .db-add-group { margin-top: 18px; }
.db-add-group-title {
  font-family: 'Lexend', sans-serif; font-weight: 700; font-size: 11.5px; letter-spacing: 0.6px;
  text-transform: uppercase; color: #8791A0; padding: 2px 2px 2px; margin-bottom: 2px;
}

/* Honest empty state, used wherever a widget has no live data to show rather than
   falling back to invented figures. */
.db-empty {
  grid-column: 1 / -1;
  padding: 28px 20px;
  border: 1px dashed #D8DEE7;
  border-radius: 12px;
  background: #FBFCFD;
  color: var(--muted2);
  font-size: 14px;
  text-align: center;
}
