/* ============================================================
   CUSTOMIZABLE HOME DASHBOARD — styles
   Grid is 12 columns, RTL: x counts from the RIGHT edge.
   ============================================================ */

#home_dashboard_tab { padding-bottom: 3rem; }

/* ---- header / toolbar ---- */
.dgdash-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.dgdash-toolbar .dgdash-title {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 1.25rem; font-weight: bold; color: var(--text-primary);
}
.dgdash-title i { color: var(--accent-primary); }
.dgdash-greeting { font-size: 0.85rem; color: var(--text-secondary); font-weight: normal; }
.dgdash-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.dgdash-btn {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.5rem 0.95rem; border-radius: 9px; cursor: pointer;
    border: var(--glass-border); background: rgba(255,255,255,0.06);
    color: var(--text-primary); font-family: inherit; font-size: 0.85rem;
    font-weight: bold; transition: all .2s;
}
.dgdash-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.dgdash-btn.primary { background: var(--accent-primary); border-color: transparent; color: #fff; }
.dgdash-btn.success { background: var(--accent-success); border-color: transparent; color: #fff; }
.dgdash-btn.danger  { background: rgba(239,68,68,0.15); color: var(--accent-danger); }
.dgdash-btn.ghost   { background: transparent; }
.dgdash-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---- tabs bar ---- */
.dgdash-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap; align-items: center; }
.dgdash-tab {
    padding: 0.4rem 1rem; border-radius: 20px; cursor: pointer; font-size: 0.82rem;
    border: var(--glass-border); color: var(--text-secondary);
    background: rgba(255,255,255,0.04); transition: all .2s; font-weight: bold;
}
.dgdash-tab.active { background: var(--accent-primary); color: #fff; border-color: transparent; }
.dgdash-tab .fa-xmark { margin-right: 6px; opacity: 0.7; }
.dgdash-tab .fa-xmark:hover { opacity: 1; color: var(--accent-danger); }

/* ---- pinned strip ---- */
.dgdash-pinned-strip {
    border: 1px dashed rgba(245,158,11,0.45); border-radius: 14px;
    padding: 0.75rem; margin-bottom: 1rem;
    background: linear-gradient(180deg, rgba(245,158,11,0.05), transparent);
}
.dgdash-pinned-label {
    font-size: 0.72rem; color: var(--accent-warning); font-weight: bold;
    display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem;
}
.dgdash-pinned-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; }
.dgdash-pinned-grid .dgdash-widget { position: relative; }

/* ---- the free canvas ---- */
.dgdash-canvas {
    position: relative; min-height: 240px; border-radius: 14px;
    transition: background .2s;
}
.dgdash-canvas.editing {
    background-image:
        repeating-linear-gradient(to bottom, rgba(255,255,255,0.035) 0 1px, transparent 1px 100px);
    outline: 2px dashed rgba(59,130,246,0.35); outline-offset: 6px;
}
.dgdash-canvas .dgdash-widget { position: absolute; transition: top .18s ease, right .18s ease, width .18s ease, height .18s ease; }
.dgdash-canvas .dgdash-widget.dragging,
.dgdash-canvas .dgdash-widget.resizing { transition: none; z-index: 50; opacity: 0.92; box-shadow: 0 18px 45px rgba(0,0,0,0.55); }

.dgdash-ghost {
    position: absolute; border-radius: 14px; z-index: 5;
    background: rgba(59,130,246,0.16); border: 2px dashed var(--accent-primary);
    transition: top .12s ease, right .12s ease, width .12s ease, height .12s ease;
    pointer-events: none;
}

/* ---- a widget card ---- */
.dgdash-widget {
    border-radius: 14px; border: var(--glass-border);
    background: rgba(30, 41, 59, 0.55); backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.dgdash-widget.alerting { border-color: rgba(239,68,68,0.55); box-shadow: 0 0 0 1px rgba(239,68,68,0.35), 0 8px 24px rgba(0,0,0,0.3); }
.dgdash-widget.threshold-warn { border-color: rgba(245,158,11,0.6); }
.dgdash-widget.threshold-bad { border-color: rgba(239,68,68,0.7); }
.dgdash-widget.threshold-good { border-color: rgba(34,197,94,0.5); }

.dgdash-w-head {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.85rem 0.45rem; flex-shrink: 0; user-select: none;
}
.dgdash-w-head i.dgdash-w-icon { color: var(--accent-secondary); font-size: 0.9rem; }
.dgdash-w-title {
    font-size: 0.82rem; font-weight: bold; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.dgdash-w-tools { display: flex; gap: 0.25rem; align-items: center; }
.dgdash-w-tools button {
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    font-size: 0.75rem; padding: 3px 5px; border-radius: 6px;
}
.dgdash-w-tools button:hover { color: var(--text-primary); background: rgba(255,255,255,0.1); }
.dgdash-pin-badge { color: var(--accent-warning); font-size: 0.72rem; }

.dgdash-w-body { flex: 1; overflow: auto; padding: 0.25rem 0.85rem 0.6rem; scrollbar-width: thin; }
.dgdash-w-foot {
    flex-shrink: 0; padding: 0.35rem 0.85rem; font-size: 0.7rem;
    color: var(--text-secondary); border-top: 1px solid rgba(255,255,255,0.06);
}
.dgdash-w-foot.alert { color: var(--accent-warning); font-weight: bold; }

/* clickable drill-down */
.dgdash-widget[data-drill] .dgdash-w-head { cursor: pointer; }
.dgdash-widget[data-drill] .dgdash-w-head:hover .dgdash-w-title { color: var(--accent-primary); }

/* edit-mode chrome */
.dgdash-canvas.editing .dgdash-widget:not(.pinned) .dgdash-w-head { cursor: grab; }
.dgdash-canvas.editing .dgdash-widget:not(.pinned) .dgdash-w-head:active { cursor: grabbing; }
.dgdash-widget .dgdash-resize-handle {
    display: none; position: absolute; left: 2px; bottom: 2px; width: 18px; height: 18px;
    cursor: nesw-resize; color: var(--text-secondary); z-index: 6;
    align-items: center; justify-content: center; font-size: 0.7rem;
}
.dgdash-canvas.editing .dgdash-widget:not(.pinned) .dgdash-resize-handle { display: flex; }
.dgdash-canvas.editing .dgdash-widget:not(.pinned) { animation: dgdash-wiggle 3s ease-in-out infinite; }
@keyframes dgdash-wiggle { 0%,100% { box-shadow: 0 8px 24px rgba(0,0,0,0.25);} 50% { box-shadow: 0 8px 28px rgba(59,130,246,0.25);} }

/* ---- KPI rendering ---- */
.dgdash-kpi { display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 0.25rem; }
.dgdash-kpi-value { font-size: 1.7rem; font-weight: 800; color: var(--text-primary); line-height: 1.1; direction: ltr; text-align: right; }
.dgdash-kpi-value .unit { font-size: 0.8rem; color: var(--text-secondary); font-weight: normal; }
.dgdash-kpi-delta { font-size: 0.75rem; font-weight: bold; display: flex; align-items: center; gap: 0.3rem; }
.dgdash-kpi-delta.up { color: var(--accent-success); }
.dgdash-kpi-delta.down { color: var(--accent-danger); }
.dgdash-kpi-delta .lbl { color: var(--text-secondary); font-weight: normal; }

.dgdash-kpi-group { display: flex; height: 100%; align-items: center; gap: 0.4rem; }
.dgdash-kpi-cell { flex: 1; text-align: center; padding: 0.3rem 0.2rem; border-radius: 10px; background: rgba(255,255,255,0.04); }
.dgdash-kpi-cell .v { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); }
.dgdash-kpi-cell .v.warn { color: var(--accent-danger); }
.dgdash-kpi-cell .l { font-size: 0.68rem; color: var(--text-secondary); margin-top: 2px; }

/* ---- list rendering ---- */
.dgdash-list { display: flex; flex-direction: column; gap: 0.35rem; }
.dgdash-list-summary {
    display: flex; align-items: baseline; gap: 0.45rem; margin-bottom: 0.3rem;
    font-size: 0.78rem; color: var(--text-secondary);
}
.dgdash-list-summary .n { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); }
.dgdash-list-summary.alert .n { color: var(--accent-danger); }
.dgdash-li {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem;
    border-radius: 9px; background: rgba(255,255,255,0.035); font-size: 0.78rem;
}
.dgdash-li.warn { background: rgba(239,68,68,0.09); }
.dgdash-li.unread { border-right: 3px solid var(--accent-primary); }
.dgdash-li .t { flex: 1; min-width: 0; }
.dgdash-li .t .main { color: var(--text-primary); font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dgdash-li .t .sub { color: var(--text-secondary); font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dgdash-li .meta { color: var(--text-secondary); font-size: 0.68rem; white-space: nowrap; }
.dgdash-li .val { font-weight: 800; color: var(--text-primary); font-size: 0.8rem; white-space: nowrap; direction: ltr; }
.dgdash-li.warn .val, .dgdash-li.warn .meta { color: var(--accent-danger); }
.dgdash-empty { text-align: center; color: var(--text-secondary); font-size: 0.8rem; padding: 1.2rem 0.5rem; }
.dgdash-empty i { font-size: 1.4rem; display: block; margin-bottom: 0.4rem; opacity: 0.5; }

/* ---- actions widget ---- */
.dgdash-actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 0.4rem; height: 100%; align-content: center; }
.dgdash-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
    padding: 0.5rem 0.25rem; border-radius: 10px; cursor: pointer;
    background: rgba(255,255,255,0.05); border: var(--glass-border);
    color: var(--text-primary); font-size: 0.68rem; font-family: inherit; font-weight: bold;
    transition: all .15s;
}
.dgdash-action-btn:hover { background: rgba(59,130,246,0.18); transform: translateY(-2px); }
.dgdash-action-btn i { font-size: 1rem; color: var(--accent-secondary); }

/* ---- clock widget ---- */
.dgdash-clock { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 0.2rem; }
.dgdash-clock .time { font-size: 1.9rem; font-weight: 800; color: var(--text-primary); direction: ltr; font-variant-numeric: tabular-nums; }
.dgdash-clock .date { font-size: 0.78rem; color: var(--text-secondary); }

/* ---- notes widget ---- */
.dgdash-notes {
    width: 100%; height: 100%; resize: none; border: none; outline: none;
    background: transparent; color: var(--text-primary); font-family: inherit;
    font-size: 0.85rem; line-height: 1.7;
}
.dgdash-notes::placeholder { color: var(--text-secondary); opacity: 0.6; }

/* ---- chart canvas ---- */
.dgdash-chart-wrap { position: relative; height: 100%; min-height: 80px; }

/* ---- skeleton / loading ---- */
.dgdash-skel { background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.05) 75%); background-size: 200% 100%; animation: dgdash-shimmer 1.2s infinite; border-radius: 8px; }
@keyframes dgdash-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.dgdash-w-error { color: var(--accent-danger); font-size: 0.75rem; padding: 0.6rem; text-align: center; }
.dgdash-stale { opacity: 0.55; }

/* ---- catalog & modals ---- */
.dgdash-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 6000;
    display: flex; align-items: flex-start; justify-content: center;
    overflow-y: auto; padding: 4vh 1rem;
}
.dgdash-modal {
    width: 100%; max-width: 860px; border-radius: 16px; padding: 1.4rem;
    background: rgba(15, 23, 42, 0.98); border: var(--glass-border); margin: auto;
}
.dgdash-modal h3 { margin: 0 0 1rem; color: var(--text-primary); font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; }
.dgdash-modal h3 i { color: var(--accent-primary); }

.dgdash-cat-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.dgdash-cat-tab {
    padding: 0.35rem 0.8rem; border-radius: 16px; font-size: 0.75rem; cursor: pointer;
    border: var(--glass-border); color: var(--text-secondary); background: transparent; font-family: inherit;
}
.dgdash-cat-tab.active { background: var(--accent-secondary); color: #06202c; font-weight: bold; border-color: transparent; }

.dgdash-catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; max-height: 55vh; overflow-y: auto; padding: 2px; }
.dgdash-cat-card {
    border: var(--glass-border); border-radius: 12px; padding: 0.7rem;
    background: rgba(255,255,255,0.04); cursor: pointer; transition: all .15s;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.dgdash-cat-card:hover { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.5); transform: translateY(-2px); }
.dgdash-cat-card.added { opacity: 0.45; pointer-events: none; }
.dgdash-cat-card .nm { font-weight: bold; color: var(--text-primary); font-size: 0.82rem; display: flex; align-items: center; gap: 0.45rem; }
.dgdash-cat-card .nm i { color: var(--accent-secondary); width: 16px; text-align: center; }
.dgdash-cat-card .ds { font-size: 0.7rem; color: var(--text-secondary); line-height: 1.5; }
.dgdash-cat-card .tag { align-self: flex-start; margin-top: auto; font-size: 0.62rem; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,0.07); color: var(--text-secondary); }

/* ---- generic form bits inside dgdash modals ---- */
.dgdash-form-row { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.75rem; }
.dgdash-form-row label { font-size: 0.75rem; color: var(--text-secondary); font-weight: bold; }
.dgdash-form-row select, .dgdash-form-row input[type="text"], .dgdash-form-row input[type="number"], .dgdash-form-row textarea {
    padding: 0.55rem 0.7rem; border-radius: 9px; border: var(--glass-border);
    background: rgba(0,0,0,0.35); color: var(--text-primary); font-family: inherit; font-size: 0.85rem; outline: none;
}
.dgdash-modal-foot { display: flex; justify-content: flex-start; gap: 0.5rem; margin-top: 1rem; }

/* ---- admin (manager) panel ---- */
.dgdash-admin-cols { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; min-height: 380px; }
.dgdash-admin-side { border-left: 1px solid rgba(255,255,255,0.08); padding-left: 0.75rem; max-height: 60vh; overflow-y: auto; }
.dgdash-admin-side .hd { font-size: 0.7rem; color: var(--text-secondary); font-weight: bold; margin: 0.6rem 0 0.3rem; }
.dgdash-scope-item {
    display: block; width: 100%; text-align: right; padding: 0.4rem 0.6rem; border-radius: 8px;
    background: none; border: none; color: var(--text-primary); font-family: inherit;
    font-size: 0.78rem; cursor: pointer;
}
.dgdash-scope-item:hover { background: rgba(255,255,255,0.07); }
.dgdash-scope-item.active { background: var(--accent-primary); color: #fff; font-weight: bold; }
.dgdash-scope-item .badge { font-size: 0.6rem; color: var(--accent-warning); margin-right: 4px; }

.dgdash-policy-zone { border: var(--glass-border); border-radius: 12px; padding: 0.8rem; margin-bottom: 0.8rem; }
.dgdash-policy-zone h4 { margin: 0 0 0.5rem; font-size: 0.82rem; color: var(--text-primary); display: flex; align-items: center; gap: 0.4rem; justify-content: space-between; }
.dgdash-policy-zone h4 .hint { font-size: 0.65rem; color: var(--text-secondary); font-weight: normal; }
.dgdash-chip-list { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 28px; }
.dgdash-chip {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.6rem;
    border-radius: 14px; font-size: 0.72rem; background: rgba(255,255,255,0.07);
    color: var(--text-primary); border: var(--glass-border);
}
.dgdash-chip i.rm { cursor: pointer; color: var(--text-secondary); }
.dgdash-chip i.rm:hover { color: var(--accent-danger); }
.dgdash-chip.pinned { border-color: rgba(245,158,11,0.5); }
.dgdash-chip.blocked { border-color: rgba(239,68,68,0.5); text-decoration: line-through; }

/* ---- first-run hint bar ---- */
.dgdash-hint-bar {
    display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem;
    padding: 0.7rem 1rem; border-radius: 12px;
    background: linear-gradient(90deg, rgba(59,130,246,0.14), rgba(34,211,238,0.07));
    border: 1px solid rgba(59,130,246,0.35); font-size: 0.82rem; color: var(--text-primary);
}
.dgdash-hint-bar i.spark { color: var(--accent-primary); font-size: 1rem; }
.dgdash-hint-bar .close { margin-right: auto; cursor: pointer; color: var(--text-secondary); }
.dgdash-hint-bar .close:hover { color: var(--text-primary); }

/* ---- TV / kiosk mode ---- */
body.dgdash-tv .sidebar,
body.dgdash-tv header,
body.dgdash-tv #sidebarBackdrop,
body.dgdash-tv .dgdash-hint-bar { display: none !important; }
body.dgdash-tv .main-content { margin: 0 !important; padding: 1rem 1.5rem !important; width: 100% !important; }
body.dgdash-tv .app-container { display: block !important; }
body.dgdash-tv { overflow: hidden; }
body.dgdash-tv #home_dashboard_tab { padding-bottom: 0; }
body.dgdash-tv .dgdash-widget { box-shadow: 0 4px 18px rgba(0,0,0,0.45); }
.dgdash-tv-exit {
    position: fixed; top: 14px; left: 14px; z-index: 7000;
    background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px; padding: 0.4rem 1rem; cursor: pointer; font-family: inherit;
    font-size: 0.78rem; opacity: 0.35; transition: opacity .2s;
}
.dgdash-tv-exit:hover { opacity: 1; }
.dgdash-tv-clockbar {
    position: fixed; top: 14px; right: 18px; z-index: 7000; direction: ltr;
    font-size: 1.1rem; font-weight: 800; color: var(--text-primary);
    font-variant-numeric: tabular-nums; opacity: 0.8;
}

/* ---- focus (maximize) mode ---- */
.dgdash-focus-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 6500;
    display: flex; align-items: center; justify-content: center; padding: 4vh 4vw;
}
.dgdash-focus-overlay .dgdash-widget {
    position: relative !important; width: 100% !important; height: 100% !important;
    max-width: 1100px; max-height: 82vh; animation: dgdash-pop .18s ease;
}
@keyframes dgdash-pop { from { transform: scale(0.96); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }

/* ---- last-updated dot ---- */
.dgdash-updated-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent-success);
    display: inline-block; flex-shrink: 0; transition: background .3s;
}
.dgdash-updated-dot.stale { background: var(--accent-warning); }

/* ---- welcome banner ---- */
.dgdash-banner {
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    height: 100%; padding: 0.5rem 0.25rem;
}
.dgdash-banner-greet {
    display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0;
}
.dgdash-banner-greet .wave { font-size: 1.8rem; }
.dgdash-banner-greet .name { font-size: 1.1rem; font-weight: bold; color: var(--text-primary); }
.dgdash-banner-greet .date { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.15rem; }
.dgdash-banner-stats {
    display: flex; gap: 1rem; flex-wrap: wrap; flex: 1;
}
.dgdash-banner-stat {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(255,255,255,0.06); border-radius: 10px;
    padding: 0.5rem 0.9rem; min-width: 80px; gap: 0.15rem;
    border: var(--glass-border);
}
.dgdash-banner-stat i { color: var(--accent-secondary); font-size: 0.8rem; }
.dgdash-banner-stat .v { font-size: 1.1rem; font-weight: bold; color: var(--text-primary); }
.dgdash-banner-stat .l { font-size: 0.65rem; color: var(--text-secondary); }
.dgdash-banner-stat.warn { border-color: var(--accent-danger); }
.dgdash-banner-stat.warn i, .dgdash-banner-stat.warn .v { color: var(--accent-danger); }

/* ---- density variants ---- */
.dgdash-canvas.density-compact { --row-h-override: 76px; }
.dgdash-canvas.density-spacious { --row-h-override: 108px; }

/* ---- form rows (settings modals) ---- */
.dgdash-form-row {
    display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem;
}
.dgdash-form-row label { font-size: 0.82rem; color: var(--text-secondary); }
.dgdash-form-row select, .dgdash-form-row input[type="number"], .dgdash-form-row input[type="text"] {
    padding: 0.45rem 0.7rem; border-radius: 8px; border: var(--glass-border);
    background: rgba(0,0,0,0.3); color: var(--text-primary);
    font-family: inherit; font-size: 0.85rem; outline: none; width: 100%;
}

/* ---- responsive: stack on small screens ---- */
@media (max-width: 768px) {
    .dgdash-canvas { position: static !important; height: auto !important; }
    .dgdash-canvas .dgdash-widget {
        position: static !important; width: 100% !important; height: auto !important;
        min-height: 140px; margin-bottom: 0.75rem;
    }
    .dgdash-pinned-grid { display: flex; flex-direction: column; }
    .dgdash-admin-cols { grid-template-columns: 1fr; }
    .dgdash-admin-side { border-left: none; max-height: 200px; }
}
