/* =========================================================
   Knowledge Forge
   File: css/style.css
   Purpose:
   - Main application styling
   - Dashboard, KB, Assistant, Password Generator
   - Modern premium UI with purple / orange gradient theme
========================================================= */

/* =========================================================
   RESET / BASE
========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

:root {
    --bg: #F6F3EC;
    --bg-soft: #FBF9F3;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --surface-border: rgba(176, 150, 80, 0.20);
    --text: #2B2620;
    --text-soft: #6B6357;
    --text-muted: #9A9284;
    --primary: #B4933A;
    --primary-2: #D4B961;
    --accent: #D4B961;
    --accent-2: #E4D08A;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --shadow-lg: 0 24px 64px rgba(176, 147, 58, 0.16);
    --shadow-md: 0 14px 36px rgba(176, 147, 58, 0.12);
    --shadow-sm: 0 8px 18px rgba(176, 147, 58, 0.10);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --gradient-main: linear-gradient(135deg, #8A6D1F 0%, #BE9B37 45%, #6E7378 100%);
    --gradient-soft: linear-gradient(135deg, rgba(176, 147, 58, 0.10), rgba(212, 185, 97, 0.10));
    --sidebar-width: 300px;
}

body {
    font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(212, 185, 97, 0.08), transparent 26%),
        radial-gradient(circle at top left, rgba(176, 147, 58, 0.10), transparent 28%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
}

body.modal-open,
body.is-loading {
    overflow: hidden;
}

img,
video {
    max-width: 100%;
    display: block;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* =========================================================
   LAYOUT
========================================================= */

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

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    padding: 28px 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 26px 28px 34px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.topbar-left h2 {
    margin: 0 0 6px;
    font-size: 30px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.topbar-left p {
    margin: 0;
    color: var(--text-soft);
    font-size: 15px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =========================================================
   SIDEBAR
========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 8px 14px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: var(--gradient-main);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 10px;
    letter-spacing: -0.2px;
    text-align: center;
    padding: 0 4px;
    box-shadow: var(--shadow-md);
}

.brand-text h1 {
    margin: 0 0 2px;
    font-size: 22px;
    line-height: 1.1;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-text p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    appearance: none;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    color: var(--text-soft);
    padding: 14px 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.22s ease;
    font-weight: 600;
}

.nav-link:hover {
    background: rgba(176, 147, 58, 0.08);
    color: var(--text);
}

.nav-link.active {
    color: #fff;
    background: var(--gradient-main);
    box-shadow: var(--shadow-md);
}

.nav-icon {
    width: 24px;
    display: inline-grid;
    place-items: center;
    font-size: 16px;
}

.sidebar-footer {
    margin-top: auto;
}

.mini-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
    background: linear-gradient(145deg, rgba(176, 147, 58, 0.09), rgba(251, 146, 60, 0.10));
    border: 1px solid rgba(176, 147, 58, 0.08);
}

.mini-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--surface-strong);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
}

.mini-card strong {
    display: block;
    font-size: 14px;
}

.mini-card small {
    display: block;
    color: var(--text-muted);
}

/* =========================================================
   GENERIC COMPONENTS
========================================================= */

.glass-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.54);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px);
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.22s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    color: #fff;
    background: var(--gradient-main);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: saturate(1.04);
}

.btn-secondary {
    color: var(--text);
    background: rgba(176, 147, 58, 0.10);
}

.btn-secondary:hover {
    background: rgba(176, 147, 58, 0.16);
}

.btn-ghost {
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--surface-border);
}

.btn-ghost:hover {
    background: rgba(176, 147, 58, 0.06);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #f97316);
}

.pill,
.viewer-pill,
.assistant-confidence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 8px 12px;
    border-radius: 999px;
}

.pill {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(176, 147, 58, 0.08);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(176, 147, 58, 0.08);
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section-head h3 {
    margin: 0 0 5px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.section-head p {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
}

.section-head.with-action {
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-soft);
}

.empty-state.large {
    padding: 72px 20px;
}

.empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 22px;
    background: var(--gradient-soft);
    display: grid;
    place-items: center;
    font-size: 28px;
}

.empty-state h4 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
    max-width: 520px;
    margin-inline: auto;
}

.empty-inline-state {
    padding: 18px;
    border-radius: 18px;
    background: rgba(176, 147, 58, 0.05);
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-soft);
    border: 1px dashed rgba(176, 147, 58, 0.12);
}

.empty-inline-state.error {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.14);
}

.empty-inline-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: #fff;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
    font-size: 22px;
}

.empty-inline-state strong {
    display: block;
    color: var(--text);
    margin-bottom: 4px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.form-group small {
    color: var(--text-muted);
    font-size: 12px;
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="file"],
textarea,
select {
    width: 100%;
    border: 1px solid rgba(123, 107, 168, 0.16);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
    border-radius: 16px;
    padding: 14px 16px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    resize: vertical;
    min-height: 110px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(176, 147, 58, 0.46);
    box-shadow: 0 0 0 5px rgba(176, 147, 58, 0.08);
    background: #fff;
}

/* =========================================================
   TABS
========================================================= */

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* =========================================================
   DASHBOARD
========================================================= */

.dashboard-grid {
    display: grid;
    gap: 24px;
}

.hero-card {
    border-radius: 30px;
    padding: 28px;
    background: var(--gradient-main);
    color: #fff;
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1.2fr 0.9fr;
    gap: 28px;
    box-shadow: var(--shadow-lg);
}

.hero-left h3 {
    margin: 14px 0 10px;
    font-size: 34px;
    line-height: 1.12;
    font-weight: 900;
    letter-spacing: -0.03em;
    max-width: 720px;
}

.hero-left p {
    margin: 0;
    max-width: 700px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 15px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.hero-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.hero-right {
    position: relative;
    min-height: 240px;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(1px);
}

.orb-one {
    width: 160px;
    height: 160px;
    right: 10px;
    top: 0;
    background: rgba(255, 255, 255, 0.12);
}

.orb-two {
    width: 220px;
    height: 220px;
    right: 90px;
    bottom: -30px;
    background: rgba(255, 255, 255, 0.08);
}

.stats-stack {
    position: relative;
    z-index: 2;
    margin-left: auto;
    max-width: 290px;
    display: grid;
    gap: 14px;
}

.stat-card {
    border-radius: 20px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
}

.stat-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.82;
    margin-bottom: 5px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.summary-card {
    padding: 22px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.summary-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: var(--gradient-soft);
    display: grid;
    place-items: center;
    font-size: 24px;
}

.summary-card h4 {
    margin: 0;
    font-size: 30px;
    line-height: 1;
}

.summary-card p {
    margin: 6px 0 0;
    color: var(--text-soft);
    font-size: 14px;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: 1.5fr 0.9fr;
    gap: 24px;
}

.quick-search-card,
.tips-card {
    border-radius: 26px;
    padding: 24px;
}

.quick-search-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-bottom: 18px;
}

.quick-results {
    display: grid;
    gap: 14px;
}

.quick-result-card {
    appearance: none;
    border: 1px solid rgba(176, 147, 58, 0.08);
    background: #fff;
    color: var(--text);
    border-radius: 20px;
    padding: 18px;
    text-align: left;
    cursor: pointer;
    transition: all 0.22s ease;
    box-shadow: var(--shadow-sm);
}

.quick-result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(176, 147, 58, 0.16);
}

.quick-result-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.quick-result-head h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
}

.quick-result-badge {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(176, 147, 58, 0.08);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.quick-result-summary {
    margin: 0 0 10px;
    color: var(--text-soft);
    font-size: 14px;
}

.quick-result-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.quick-result-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.tips-list li {
    display: flex;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(176, 147, 58, 0.05);
    color: var(--text-soft);
}

.tips-list li span {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* =========================================================
   KNOWLEDGE BASE
========================================================= */

.kb-layout {
    display: grid;
    grid-template-columns: 430px 1fr;
    gap: 24px;
    align-items: start;
}

.kb-left,
.kb-right {
    border-radius: 28px;
    padding: 22px;
    min-height: 600px;
}

.kb-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    margin-bottom: 18px;
}

.search-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.article-list {
    display: grid;
    gap: 14px;
    max-height: calc(100vh - 250px);
    overflow: auto;
    padding-right: 4px;
}

.article-card {
    appearance: none;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(176, 147, 58, 0.08);
    background: #fff;
    color: var(--text);
    border-radius: 22px;
    padding: 18px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.22s ease;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.article-card.selected {
    border-color: rgba(176, 147, 58, 0.30);
    box-shadow: 0 0 0 4px rgba(176, 147, 58, 0.06), var(--shadow-md);
}

.article-card-head {
    display: flex;
    gap: 14px;
    margin-bottom: 12px;
}

.article-card-badge {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 900;
    color: #fff;
    background: var(--gradient-main);
    flex-shrink: 0;
}

.article-card-head-content h4 {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 800;
}

.article-card-head-content p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.article-card-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.article-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
}

.article-viewer {
    min-height: 560px;
}

.viewer-shell {
    display: grid;
    gap: 22px;
}

.viewer-hero {
    border-radius: 30px;
    padding: 28px;
    background: var(--gradient-main);
    color: #fff;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}

.viewer-hero-top {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.viewer-pill {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.viewer-pill-video {
    background: rgba(255, 255, 255, 0.22);
}

.viewer-hero h2 {
    margin: 0 0 10px;
    font-size: 34px;
    line-height: 1.12;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.viewer-summary {
    margin: 0 0 12px;
    color: rgba(255, 255, 255, 0.88);
    max-width: 760px;
}

.viewer-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.viewer-tags .tag-chip {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.viewer-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
}

.viewer-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.viewer-hero-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.viewer-hero-actions .btn-ghost {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.18);
}

.viewer-steps-wrap {
    display: grid;
    gap: 20px;
}

.viewer-step-card {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 18px;
    padding: 20px;
    border-radius: 26px;
    background: #fff;
    border: 1px solid rgba(176, 147, 58, 0.08);
    box-shadow: var(--shadow-sm);
}

.viewer-step-marker {
    border-radius: 20px;
    background: var(--gradient-main);
    color: #fff;
    display: grid;
    place-items: center;
    min-height: 160px;
    font-size: 28px;
    font-weight: 900;
    box-shadow: var(--shadow-md);
}

.viewer-step-content {
    min-width: 0;
}

.viewer-step-head {
    margin-bottom: 12px;
}

.viewer-step-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 0.08em;
    margin-bottom: 5px;
}

.viewer-step-head h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.2;
}

.viewer-step-body {
    color: var(--text-soft);
    font-size: 15px;
    margin-bottom: 16px;
}

/* Links in step bodies: blue, no underline (editor + reader) */
.viewer-step-body a,
.step-body-editor a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}
.viewer-step-body a:hover,
.step-body-editor a:hover {
    text-decoration: underline;
}

/* WYSIWYG step body editor */
.step-rt-toolbar {
    display: flex;
    gap: 8px;
    margin: 2px 0 8px;
    flex-wrap: wrap;
}
.step-rt-toolbar button {
    border: 1px solid rgba(176, 147, 58, 0.30);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 5px 13px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    transition: background 0.15s ease;
}
.step-rt-toolbar button:hover {
    background: rgba(176, 147, 58, 0.08);
}
.step-rt-toolbar .rt-bold {
    font-weight: 900;
    min-width: 34px;
}
.step-body-editor {
    min-height: 88px;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow-wrap: anywhere;
}
.step-body-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(176, 147, 58, 0.12);
}
.step-body-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted, #9b8fc0);
    pointer-events: none;
}

.viewer-step-media {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.viewer-media-card {
    border: 1px dashed rgba(176, 147, 58, 0.14);
    background: rgba(176, 147, 58, 0.03);
    border-radius: 20px;
    padding: 14px;
}

.viewer-media-card-icon {
    max-width: 320px;
}

.viewer-media-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.viewer-media-image {
    width: 100%;
    border-radius: 16px;
    object-fit: contain;
    background: #fff;
}

.viewer-media-icon {
    width: 110px;
    height: 110px;
    object-fit: contain;
    border-radius: 18px;
    background: #fff;
    padding: 10px;
}

.viewer-video-card {
    border-radius: 26px;
    padding: 22px;
    background: #fff;
    border: 1px solid rgba(176, 147, 58, 0.08);
    box-shadow: var(--shadow-sm);
}

.viewer-section-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 14px;
}

.viewer-video {
    width: 100%;
    border-radius: 20px;
    background: #000;
    max-height: 520px;
}

.viewer-video-meta {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 13px;
}

/* =========================================================
   MODAL / STEPS BUILDER
========================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 20, 44, 0.42);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    width: min(1180px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: var(--bg-soft);
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.46);
}

.modal-xl {
    width: min(1240px, 100%);
}

.modal-header,
.modal-footer {
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.modal-header {
    border-bottom: 1px solid rgba(176, 147, 58, 0.08);
}

.modal-body {
    padding: 24px;
    display: grid;
    gap: 24px;
}

/* Elegant themed scrollbar for modals */
.modal {
    scrollbar-width: thin;
    scrollbar-color: #8A6D1F transparent;
}
.modal::-webkit-scrollbar {
    width: 12px;
}
.modal::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}
.modal::-webkit-scrollbar-thumb {
    background: var(--gradient-main);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
    min-height: 44px;
}
.modal::-webkit-scrollbar-thumb:hover {
    border-width: 2px;
}

/* Floating "jump to top / bottom" buttons for the article editor */
.kb-step-jump {
    position: fixed;
    right: 34px;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1100;
}
.kb-step-jump button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--gradient-main);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kb-step-jump button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}
.kb-step-jump button:active {
    transform: translateY(0);
}

.modal-header h3 {
    margin: 0 0 5px;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.modal-header p {
    margin: 0;
    color: var(--text-soft);
}

.modal-footer {
    border-top: 1px solid rgba(176, 147, 58, 0.08);
}

.icon-btn {
    appearance: none;
    border: 1px solid rgba(176, 147, 58, 0.10);
    background: #fff;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--text-soft);
    transition: all 0.22s ease;
}

.icon-btn:hover {
    background: rgba(176, 147, 58, 0.06);
    color: var(--text);
}

.steps-builder {
    display: grid;
    gap: 18px;
}

.steps-container {
    display: grid;
    gap: 18px;
}

.step-builder-card {
    border-radius: 26px;
    padding: 20px;
    background: #fff;
    border: 1px solid rgba(176, 147, 58, 0.08);
    box-shadow: var(--shadow-sm);
}

.step-builder-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
}

.step-builder-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.step-number-badge {
    min-width: 112px;
    text-align: center;
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--gradient-main);
    color: #fff;
    font-weight: 900;
    box-shadow: var(--shadow-md);
}

.step-title-input {
    flex: 1;
}

.step-builder-actions {
    display: flex;
    gap: 8px;
}

.step-media-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.file-preview {
    min-height: 30px;
}

.media-preview-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    border: 1px dashed rgba(176, 147, 58, 0.16);
    background: rgba(176, 147, 58, 0.04);
    border-radius: 18px;
    padding: 14px;
    margin-top: 10px;
}

.media-preview-body {
    min-width: 0;
    flex: 1;
}

.media-preview-image {
    width: 100%;
    max-width: 220px;
    border-radius: 16px;
    background: #fff;
    object-fit: contain;
    margin-bottom: 10px;
}

.media-preview-name {
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

.media-preview-subtext {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.media-remove-btn {
    flex-shrink: 0;
}

.article-video-preview-player {
    width: 100%;
    max-width: 460px;
    margin-top: 10px;
    border-radius: 16px;
    background: #000;
}

/* =========================================================
   ASSISTANT
========================================================= */

.assistant-layout {
    display: grid;
}

.assistant-card {
    border-radius: 28px;
    padding: 22px;
    min-height: 720px;
}

.assistant-chat-wrap {
    display: grid;
    gap: 18px;
}

.assistant-messages {
    min-height: 560px;
    max-height: calc(100vh - 320px);
    overflow: auto;
    padding: 4px;
    display: grid;
    gap: 18px;
}

.assistant-message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.assistant-message.user {
    justify-content: flex-end;
}

.assistant-message.user .assistant-avatar {
    order: 2;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.assistant-message.user .assistant-bubble {
    order: 1;
    background: linear-gradient(135deg, rgba(176, 147, 58, 0.10), rgba(212, 185, 97, 0.10));
    border: 1px solid rgba(176, 147, 58, 0.10);
}

.assistant-avatar {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    background: var(--gradient-main);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 22px;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.assistant-bubble {
    max-width: min(980px, calc(100% - 80px));
    background: #fff;
    border: 1px solid rgba(176, 147, 58, 0.08);
    box-shadow: var(--shadow-sm);
    border-radius: 24px;
    padding: 18px;
}

.assistant-bubble ul {
    margin: 10px 0 0 18px;
    color: var(--text-soft);
}

.assistant-inline-intro {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.assistant-answer-text {
    white-space: normal;
    color: var(--text-soft);
    margin-bottom: 14px;
}

.assistant-confidence {
    background: rgba(176, 147, 58, 0.08);
    color: var(--primary);
    margin-bottom: 12px;
}

.assistant-confidence-high {
    background: rgba(34, 197, 94, 0.10);
    color: #15803d;
}

.assistant-confidence-medium {
    background: rgba(59, 130, 246, 0.10);
    color: #1d4ed8;
}

.assistant-confidence-low,
.assistant-confidence-very_low {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.assistant-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.assistant-thinking {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 10px;
}

.assistant-thinking span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--primary);
    animation: assistantPulse 1.2s infinite ease-in-out;
}

.assistant-thinking span:nth-child(2) {
    animation-delay: 0.15s;
}

.assistant-thinking span:nth-child(3) {
    animation-delay: 0.3s;
}

.assistant-thinking-label {
    color: var(--text-soft);
}

@keyframes assistantPulse {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

.assistant-article-card {
    border-radius: 22px;
    padding: 18px;
    background: rgba(176, 147, 58, 0.03);
    border: 1px solid rgba(176, 147, 58, 0.08);
    display: grid;
    gap: 18px;
}

.assistant-article-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.assistant-article-head h3 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 900;
}

.assistant-article-summary {
    margin: 0 0 12px;
    color: var(--text-soft);
}

.assistant-article-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.assistant-article-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.assistant-steps-wrap {
    display: grid;
    gap: 16px;
}

.assistant-step-card {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 14px;
    border-radius: 18px;
    background: #fff;
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.assistant-step-marker {
    width: 54px;
    min-height: 54px;
    border-radius: 16px;
    background: var(--gradient-main);
    color: #fff;
    font-weight: 900;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-sm);
}

.assistant-step-title {
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 8px;
}

.assistant-step-body {
    color: var(--text-soft);
    margin-bottom: 12px;
}

.assistant-step-media-wrap {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.assistant-step-media-card {
    border-radius: 16px;
    border: 1px dashed rgba(176, 147, 58, 0.14);
    background: rgba(176, 147, 58, 0.03);
    padding: 12px;
}

.assistant-step-media-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.assistant-step-image {
    width: 100%;
    border-radius: 14px;
    object-fit: contain;
    background: #fff;
}

.assistant-step-icon {
    width: 84px;
    height: 84px;
    border-radius: 16px;
    object-fit: contain;
    padding: 8px;
    background: #fff;
}

.assistant-video-card {
    border-radius: 20px;
    background: #fff;
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.assistant-section-title {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
}

.assistant-video-player {
    width: 100%;
    border-radius: 16px;
    background: #000;
    max-height: 480px;
}

.assistant-video-meta {
    margin-top: 10px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
}

.assistant-related-wrap {
    display: grid;
    gap: 12px;
}

.assistant-related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.assistant-related-card {
    appearance: none;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(176, 147, 58, 0.08);
    background: #fff;
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.22s ease;
    box-shadow: var(--shadow-sm);
}

.assistant-related-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.assistant-related-title {
    font-weight: 800;
    margin-bottom: 6px;
}

.assistant-related-summary {
    color: var(--text-soft);
    font-size: 13px;
    margin-bottom: 10px;
}

.assistant-related-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.assistant-related-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.assistant-system-bubble {
    margin: 0 auto;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(176, 147, 58, 0.08);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

/* =========================================================
   PASSWORD GENERATOR
========================================================= */

.password-layout {
    display: grid;
}

.password-card {
    border-radius: 28px;
    padding: 22px;
    min-height: 560px;
}

.password-config {
    display: grid;
    gap: 20px;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.option-box {
    border: 1px solid rgba(176, 147, 58, 0.10);
    background: #fff;
    border-radius: 22px;
    min-height: 92px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.22s ease;
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    font-weight: 800;
}

.option-box input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-box.active {
    color: #fff;
    background: var(--gradient-main);
    box-shadow: var(--shadow-md);
}

.password-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.password-output-wrap input {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: #fff;
}

.password-enhanced-ui {
    display: grid;
    gap: 20px;
    margin-top: 8px;
}

.password-status-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.password-meta-label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
}

.password-strength-value.weak {
    color: #dc2626;
}

.password-strength-value.fair {
    color: #d97706;
}

.password-strength-value.good {
    color: #2563eb;
}

.password-strength-value.strong {
    color: #15803d;
}

.password-visual-output {
    border: 1px dashed rgba(176, 147, 58, 0.16);
    background: rgba(255, 255, 255, 0.86);
    border-radius: 24px;
    min-height: 112px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.password-char-placeholder {
    color: var(--text-muted);
}

.password-char-tile {
    min-width: 52px;
    height: 58px;
    border-radius: 18px;
    display: inline-grid;
    place-items: center;
    font-size: 22px;
    font-weight: 900;
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.password-char-tile.is-upper {
    color: #B4933A;
    background: rgba(176, 147, 58, 0.10);
}

.password-char-tile.is-lower {
    color: #0f766e;
    background: rgba(20, 184, 166, 0.12);
}

.password-char-tile.is-digit {
    color: #16a34a;
    background: rgba(34, 197, 94, 0.12);
}

.password-char-tile.is-symbol {
    color: #ea580c;
    background: rgba(249, 115, 22, 0.12);
}

.password-strength-meter-wrap {
    display: grid;
    gap: 8px;
}

.password-strength-meter {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: rgba(176, 147, 58, 0.08);
    overflow: hidden;
}

.password-strength-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    transition: width 0.25s ease;
    background: linear-gradient(90deg, #ef4444, #f97316);
}

.password-strength-fill.fair {
    background: linear-gradient(90deg, #f97316, #f59e0b);
}

.password-strength-fill.good {
    background: linear-gradient(90deg, #7c3aed, #3b82f6);
}

.password-strength-fill.strong {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.password-strength-scale {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.password-note-card,
.password-history-card {
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(176, 147, 58, 0.08);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.password-note-title,
.password-history-title {
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 10px;
}

.password-note-body p {
    margin: 0 0 8px;
    color: var(--text-soft);
}

.password-note-body code {
    background: rgba(176, 147, 58, 0.08);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 10px;
    word-break: break-all;
}

.password-history-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.password-history-list {
    display: grid;
    gap: 10px;
}

.password-history-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(176, 147, 58, 0.04);
}

.password-history-left {
    min-width: 0;
}

.password-history-password {
    font-family: "Consolas", "Courier New", monospace;
    font-weight: 800;
    word-break: break-all;
}

.password-history-meta {
    margin-top: 4px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 12px;
}

.password-history-copy-btn {
    appearance: none;
    border: 1px solid rgba(176, 147, 58, 0.10);
    background: #fff;
    color: var(--text);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
}

.password-history-empty {
    padding: 18px;
    border-radius: 16px;
    color: var(--text-muted);
    background: rgba(176, 147, 58, 0.04);
    text-align: center;
}

/* =========================================================
   LOADING + TOAST
========================================================= */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(24, 19, 39, 0.36);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.loader-card {
    width: 220px;
    border-radius: 24px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    padding: 26px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid rgba(176, 147, 58, 0.10);
    border-top-color: var(--primary);
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}

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

.toast-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    display: grid;
    gap: 12px;
    width: min(420px, calc(100vw - 32px));
}

.toast {
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.25s ease;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(176, 147, 58, 0.08);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(176, 147, 58, 0.08);
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background: rgba(34, 197, 94, 0.10);
}

.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.10);
}

.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.12);
}

.toast-body {
    min-width: 0;
    flex: 1;
}

.toast-title {
    font-size: 14px;
    font-weight: 900;
    margin-bottom: 4px;
}

.toast-message {
    color: var(--text-soft);
    font-size: 13px;
}

.toast-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* =========================================================
   UTILITY
========================================================= */

.hidden {
    display: none !important;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1440px) {
    .kb-layout {
        grid-template-columns: 390px 1fr;
    }

    .summary-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1180px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        flex: 0 0 auto;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--surface-border);
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .kb-layout {
        grid-template-columns: 1fr;
    }

    .viewer-step-media,
    .assistant-step-media-wrap,
    .step-media-grid {
        grid-template-columns: 1fr;
    }

    .hero-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .main-content {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-cards,
    .option-grid,
    .assistant-related-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .quick-search-box,
    .search-group,
    .assistant-input-row {
        grid-template-columns: 1fr;
    }

    .viewer-hero {
        grid-template-columns: 1fr;
    }

    .viewer-step-card,
    .assistant-step-card {
        grid-template-columns: 1fr;
    }

    .viewer-step-marker,
    .assistant-step-marker {
        min-height: 70px;
        width: 100%;
    }

    .viewer-hero-actions {
        align-items: stretch;
    }

    .assistant-article-head,
    .password-status-row,
    .password-history-item {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal-body,
    .modal-header,
    .modal-footer {
        padding: 18px;
    }
}

@media (max-width: 560px) {
    .brand {
        padding-inline: 2px;
    }

    .topbar-left h2 {
        font-size: 24px;
    }

    .hero-left h3,
    .viewer-hero h2 {
        font-size: 26px;
    }

    .article-card,
    .quick-result-card,
    .assistant-bubble,
    .assistant-article-card,
    .password-note-card,
    .password-history-card {
        border-radius: 18px;
    }

    .password-char-tile {
        min-width: 44px;
        height: 50px;
        font-size: 20px;
    }
}

/* =========================================================
   STEP COMMANDS - VIEWER
========================================================= */
.viewer-commands-block {
    background: var(--surface-2, #1e1e2e);
    border: 1px solid var(--border, #2a2a3d);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.viewer-commands-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #888);
    margin-bottom: 0.5rem;
}

.viewer-command-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.viewer-command-row:last-child {
    margin-bottom: 0;
}

.viewer-command-code {
    flex: 1;
    background: var(--surface-3, #13131f);
    border: 1px solid var(--border, #2a2a3d);
    border-radius: 5px;
    padding: 0.35rem 0.65rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    color: var(--accent, #7c6fcd);
    word-break: break-all;
}

.viewer-copy-cmd-btn {
    flex-shrink: 0;
    font-size: 0.78rem;
    padding: 0.25rem 0.6rem;
}

/* =========================================================
   EXTRA SCREENSHOTS - FORM BUILDER
========================================================= */
.extra-screenshots-section {
    margin-top: 0.75rem;
}

.extra-screenshots-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.extra-screenshot-slot {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    background: var(--surface-2, #1e1e2e);
    border: 1px solid var(--border, #2a2a3d);
    border-radius: 8px;
    padding: 0.5rem;
    max-width: 200px;
}

.extra-screenshot-slot .media-preview-image {
    max-width: 180px;
    max-height: 120px;
    border-radius: 5px;
    object-fit: contain;
}

.add-screenshot-btn {
    font-size: 0.82rem;
}

/* =========================================================
   IMAGE LIGHTBOX / ZOOM
========================================================= */
.kf-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.kf-lightbox.open {
    opacity: 1;
    pointer-events: all;
}

.kf-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.kf-lightbox-box {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9);
    transition: transform 0.22s ease;
}

.kf-lightbox.open .kf-lightbox-box {
    transform: scale(1);
}

.kf-lightbox-img {
    max-width: 90vw;
    max-height: 86vh;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: block;
}

.kf-lightbox-close {
    position: absolute;
    top: -18px;
    right: -18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #111;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    line-height: 1;
    z-index: 2;
    transition: background 0.15s;
}

.kf-lightbox-close:hover {
    background: #f44;
    color: #fff;
}

/* Make all viewer images show zoom cursor */
.viewer-media-image.zoomable-image,
.viewer-media-icon.zoomable-image {
    cursor: zoom-in;
    transition: opacity 0.15s;
}

.viewer-media-image.zoomable-image:hover,
.viewer-media-icon.zoomable-image:hover {
    opacity: 0.88;
}

.btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none !important;
}

/* =========================================================
   INFRASTRUCTURE — FLIP CARD
========================================================= */

/* Outer wrapper — 3-D viewport */
.infra-flip-wrapper {
    perspective: 1200px;
    height: 200px;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

/* The hovered card expands to 420px as an absolute overlay growing downward.
   For cards on the LAST row that overlay would extend past the grid and make
   the page grow/jump. Reserve ~240px of empty space below the grid so the
   expansion always lands in reserved room and nothing shifts. */
#infraGrid,
#locationGrid {
    padding-bottom: 240px;
}

/* Raise the hovered wrapper above its neighbours. Height stays fixed so the
   grid never reflows — the expanded card overlays as an absolute layer below. */
.infra-flip-wrapper:hover {
    z-index: 50;
}

/* The rotating card. On hover it becomes an absolute overlay that grows
   downward over whatever is beneath it IN ITS OWN COLUMN, instead of
   expanding the grid cell (which used to push the next row's cards down). */
.infra-flip-card {
    width: 100%;
    height: 200px;
    position: absolute;
    top: 0;
    left: 0;
    transform-style: preserve-3d;
    transition: transform 0.75s cubic-bezier(0.42, 0.00, 0.18, 1.00),
                height 0.75s cubic-bezier(0.42, 0.00, 0.18, 1.00);
    border-radius: 20px;
}

.infra-flip-wrapper:hover .infra-flip-card {
    height: 420px;
    transform: rotateY(180deg);
}

/* Shared face base */
.infra-flip-front,
.infra-flip-back {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ════════════════════════════════
   FRONT — dark slate
════════════════════════════════ */
.infra-flip-front {
    background: rgba(15, 19, 27, 0.96);
    border: 1px solid rgba(220, 38, 38, 0.08);
    border-left: 4px solid var(--infra-status-color, #10b981);
    padding: 22px;
    justify-content: space-between;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
}

/* Crimson top-bar */
.infra-flip-front::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #b91c1c, #dc2626, #ef4444);
    border-radius: 20px 20px 0 0;
}

.infra-flip-front-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.infra-flip-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), rgba(185, 28, 28, 0.06));
    border: 1px solid rgba(220, 38, 38, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.infra-flip-status-badge {
    font-size: 11px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 999px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.infra-flip-name {
    margin: 0 0 5px;
    font-size: 16px;
    font-weight: 800;
    color: #e2e8f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.infra-flip-location {
    font-size: 12px;
    color: #7a8899;
    margin: 0 0 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.infra-flip-ip {
    font-size: 12px;
    background: rgba(220, 38, 38, 0.08);
    color: #ef4444;
    padding: 5px 11px;
    border-radius: 9px;
    border: 1px solid rgba(220, 38, 38, 0.14);
    font-family: 'Consolas', 'Courier New', monospace;
    display: inline-block;
}

.infra-flip-hint {
    font-size: 10px;
    color: #3d4a58;
    text-align: right;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* ════════════════════════════════
   BACK — bright white premium
════════════════════════════════ */
.infra-flip-back {
    background: #ffffff;
    border: 1px solid rgba(176, 147, 58, 0.10);
    transform: rotateY(180deg);
    padding: 0;
    box-shadow:
        0 0 0 1px rgba(176, 147, 58, 0.06),
        0 20px 50px rgba(176, 147, 58, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.08);
    justify-content: stretch;
}

/* Gradient colour-bar header strip */
.infra-back-header {
    background: linear-gradient(135deg, #8A6D1F 0%, #B4933A 50%, #D4B961 100%);
    padding: 20px 20px 18px;
    display: flex;
    align-items: center;
    gap: 13px;
    flex-shrink: 0;
}

.infra-back-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.20);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
}

.infra-back-header-text {
    min-width: 0;
    flex: 1;
}

.infra-back-header-name {
    font-size: 16px;
    font-weight: 900;
    color: #ffffff;
    margin: 0 0 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

.infra-back-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.90);
    background: rgba(255, 255, 255, 0.20);
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 999px;
    padding: 3px 10px;
    letter-spacing: 0.04em;
}

/* 4-row spec list */
.infra-back-specs {
    flex: 1;
    padding: 14px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.infra-back-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: #f8f6ff;
    border: 1px solid rgba(176, 147, 58, 0.07);
    border-radius: 13px;
    transition: background 0.18s, border-color 0.18s;
}

.infra-flip-wrapper:hover .infra-back-row {
    background: #f2eeff;
    border-color: rgba(176, 147, 58, 0.14);
}

.infra-back-row-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.infra-back-row-icon.ip-icon   { background: rgba(239, 68,  68,  0.10); }
.infra-back-row-icon.sn-icon   { background: rgba(176, 147, 58, 0.10); }
.infra-back-row-icon.loc-icon  { background: rgba(16,  185, 129, 0.10); }
.infra-back-row-icon.cat-icon  { background: rgba(245, 158, 11,  0.10); }

.infra-back-row-info {
    min-width: 0;
    flex: 1;
}

.infra-back-row-label {
    font-size: 9px;
    font-weight: 800;
    color: #a89bc2;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 2px;
}

.infra-back-row-value {
    font-size: 13px;
    font-weight: 700;
    color: #1e1635;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.infra-back-row-value.mono {
    font-family: 'Consolas', 'Courier New', monospace;
    color: #dc2626;
    font-weight: 800;
    font-size: 13px;
}

/* Click-to-open footer strip */
.infra-back-footer {
    padding: 10px 18px 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    border-top: 1px solid rgba(176, 147, 58, 0.07);
}

.infra-back-footer-text {
    font-size: 10px;
    font-weight: 800;
    color: #b3a8cc;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.infra-back-footer-arrow {
    font-size: 14px;
    color: #B4933A;
    animation: infra-bounce-x 1.4s ease-in-out infinite;
}

@keyframes infra-bounce-x {
    0%, 100% { transform: translateX(0);   }
    50%       { transform: translateX(4px); }
}

/* Ensure parent containers don't clip the expanding flip card */
#tab-infra .dashboard-grid,
#tab-infra #infraGrid,
#tab-infra .glass-card {
    overflow: visible;
}

/* =========================================================
   LOCATION POPUP — Hardware list with beautiful scrollbar
========================================================= */

.kf-hw-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
    /* Custom scrollbar track */
    scrollbar-width: thin;
    scrollbar-color: rgba(176, 147, 58, 0.35) rgba(176, 147, 58, 0.06);
}

/* WebKit scrollbar */
.kf-hw-list::-webkit-scrollbar {
    width: 6px;
}
.kf-hw-list::-webkit-scrollbar-track {
    background: rgba(176, 147, 58, 0.06);
    border-radius: 99px;
    margin: 4px 0;
}
.kf-hw-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #B4933A, #D4B961);
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.20);
}
.kf-hw-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6d28d9, #a21caf);
}

/* Hardware item */
.kf-hw-item {
    padding: 12px 14px;
    background: #fff;
    border: 1.5px solid rgba(176, 147, 58, 0.08);
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 2px 8px rgba(176, 147, 58, 0.05);
}
.kf-hw-item:hover,
.kf-hw-item.kf-hw-item-hover {
    border-color: rgba(176, 147, 58, 0.30);
    transform: translateX(3px);
    box-shadow: 0 4px 14px rgba(176, 147, 58, 0.12);
}
.kf-hw-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
    background: rgba(176, 147, 58, 0.08);
    border: 1px solid rgba(176, 147, 58, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Hide scrollbar visually but keep scrollable */
.kf-no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* =========================================================
   KB FULLSCREEN MODAL — scrollbar polish
========================================================= */
#kbFullscreenBody::-webkit-scrollbar        { width: 6px; }
#kbFullscreenBody::-webkit-scrollbar-track  { background: transparent; }
#kbFullscreenBody::-webkit-scrollbar-thumb  { background: rgba(176,147,58,0.22); border-radius: 99px; }
#kbFullscreenBody::-webkit-scrollbar-thumb:hover { background: rgba(176,147,58,0.40); }

#kbFullscreenCloseBtn:hover {
    background: rgba(176,147,58,0.14) !important;
    border-color: rgba(176,147,58,0.40) !important;
}