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

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

:root {
    --sidebar-bg:   #2D2320;
    --sidebar-w:    240px;
    --accent:       #E8823A;
    --accent-dark:  #D06A26;
    --success:      #2DA44E;
    --danger:       #e5534b;
    --warning:      #D97706;
    --cream-50:     #FDFCFA;
    --cream-100:    #FAF8F5;
    --cream-200:    #EFE9E0;
    --gray-400:     #A89B8C;
    --gray-600:     #6B5E52;
    --gray-800:     #2C1F14;
    --topbar-h:     64px;
    --radius:       12px;
    --shadow:       0 2px 8px rgba(60,30,10,.07), 0 1px 3px rgba(60,30,10,.05);
    --shadow-md:    0 4px 16px rgba(60,30,10,.10), 0 2px 6px rgba(60,30,10,.07);
}

body { font-family: 'Nunito', system-ui, sans-serif; background: var(--cream-100); color: var(--gray-800); }

/* Layout */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo i { color: var(--accent); font-size: 20px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,.50);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.nav-item-danger { color: rgba(229,83,75,.7); }
.nav-item.nav-item-danger:hover { background: rgba(229,83,75,.15); color: #e5534b; }
.nav-item i { width: 16px; text-align: center; }

/* Main */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--cream-50);
    border-bottom: 1px solid var(--cream-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Topbar breadcrumb */
.topbar-breadcrumb { display: flex; align-items: center; gap: 8px; }
.topbar-bc-link { font-size: 15px; font-weight: 700; color: var(--accent); text-decoration: none; transition: color .15s; }
.topbar-bc-link:hover { color: var(--accent-dark); text-decoration: underline; }
.topbar-bc-sep { font-size: 10px; color: var(--gray-400); }
.topbar-bc-current { font-size: 17px; font-weight: 800; color: var(--gray-800); }

.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--gray-600); }

/* Content */
.content { padding: 32px; }

/* Cards */
.card {
    background: var(--cream-50);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--cream-200);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--gray-800); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
    background: var(--cream-50);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--cream-200);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon { width: 46px; height: 46px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-icon.blue  { background: #FDE8D4; color: var(--accent); }
.stat-icon.green { background: #D1FAE5; color: var(--success); }
.stat-icon.red   { background: #FFE4E4; color: var(--danger); }
.stat-icon.gray  { background: var(--cream-200); color: var(--gray-600); }

.stat-info .stat-value { font-size: 26px; font-weight: 800; color: var(--gray-800); }
.stat-info .stat-label { font-size: 12px; font-weight: 600; color: var(--gray-400); margin-top: 2px; }

/* Detail page */
.page-breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; }
.breadcrumb-back { color: var(--accent); font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.breadcrumb-back:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--gray-400); }
.breadcrumb-current { color: var(--gray-800); font-weight: 700; }

.detail-actions { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; align-items: center; }
.detail-actions-spacer { flex: 1; }
.detail-actions-divider { width: 2px; background: var(--gray-400); align-self: stretch; margin: 0 4px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.detail-grid > .card { margin-bottom: 0; }
.detail-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.detail-grid-3 > .card { margin-bottom: 0; }

.detail-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.detail-table tr + tr td { border-top: 1px solid var(--cream-200); }
.detail-table td { padding: 10px 0; vertical-align: middle; }
.detail-label { color: var(--gray-400); font-weight: 600; font-size: 13px; width: 150px; }
.detail-value { color: var(--gray-800); font-weight: 600; }

.card-title-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title-bar .card-title { margin-bottom: 0; }
.card-subtitle { font-size: 12px; color: var(--gray-400); font-weight: 400; }

.stats-bars-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stats-row-4 { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: 12px; align-items: center; }
.stats-row-3 { display: grid; grid-template-columns: 64px 1fr 1fr; gap: 12px; align-items: center; }
.stats-row-mb { margin-bottom: 12px; }
.stat-bar-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.stat-bar-label { font-size: 13px; font-weight: 600; color: var(--gray-600); }
.stat-bar-value { font-size: 13px; font-weight: 700; color: var(--gray-800); }
.stat-bar-track { background: var(--cream-200); border-radius: 999px; height: 8px; }
.stat-bar-fill  { height: 8px; border-radius: 999px; transition: width .5s; }

/* Credentials */
.cred-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--gray-600);
    padding: 6px 10px;
    background: var(--cream-100);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    margin-bottom: 4px;
}
.cred-section-admin {
    border-left-color: var(--danger);
    color: var(--danger);
    background: rgba(229,83,75,.06);
}
.cred-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.cred-table tr + tr td { border-top: 1px solid var(--cream-200); }
.cred-table td { padding: 12px 0; vertical-align: middle; }
.cred-label { color: var(--gray-400); font-weight: 600; font-size: 13px; width: 180px; }
.cred-secret { font-family: monospace; font-size: 15px; letter-spacing: 3px; color: var(--gray-400); }
.cred-secret.revealed { color: var(--gray-800); letter-spacing: normal; font-size: 13px; }
.cred-actions { width: 1%; white-space: nowrap; text-align: right; vertical-align: middle; padding-left: 8px; }
.cred-btn { background: none; border: none; cursor: pointer; color: var(--gray-400); padding: 5px 7px; border-radius: 6px; font-size: 14px; transition: color .15s, background .15s; }
.cred-btn:hover { color: var(--gray-800); background: var(--cream-200); }

/* Log */
.log-output { background: #1e1612; color: #e8ddd4; padding: 16px; border-radius: var(--radius); font-size: 11.5px; overflow-x: auto; max-height: 450px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; line-height: 1.6; margin: 0; }
.log-toolbar { display: flex; gap: 8px; align-items: center; }
.log-stats { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px; background: var(--cream-100); border: 1px solid var(--cream-200); border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.log-stat-block { display: flex; flex-direction: column; gap: 2px; }
.log-stat-val { font-size: 18px; font-weight: 800; color: var(--gray-800); line-height: 1; }
.log-stat-lbl { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; }
.log-stats-divider { width: 1px; background: var(--cream-200); align-self: stretch; }
.log-stats-scanner { width: 100%; display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: 12px; font-weight: 700; padding-top: 10px; border-top: 1px solid var(--cream-200); }
.log-stats-paths { width: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; padding-top: 10px; border-top: 1px solid var(--cream-200); color: var(--gray-600); }
.log-stats-paths strong { color: var(--gray-400); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.log-path-badge { background: var(--cream-200); color: var(--gray-600); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }

/* Resource grid */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.resource-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--cream-100);
    border: 1px solid var(--cream-200);
    border-radius: var(--radius);
    padding: 16px;
}

.resource-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    background: #FDE8D4;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.resource-info { flex: 1; min-width: 0; }
.resource-value { font-size: 16px; font-weight: 800; color: var(--gray-800); }
.resource-label { font-size: 12px; font-weight: 600; color: var(--gray-400); margin-top: 2px; }
.resource-bar { background: var(--cream-200); border-radius: 999px; height: 6px; margin-top: 8px; }
.resource-bar-fill { height: 6px; border-radius: 999px; transition: width .3s; }

/* Container mini cards */
.container-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

.container-mini-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--cream-100);
    border: 1px solid var(--cream-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
}

.container-mini-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.container-mini-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    background: #FDE8D4;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.container-mini-body { flex: 1; min-width: 0; }
.container-mini-name { font-size: 14px; font-weight: 700; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.container-mini-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.container-mini-arrow { color: var(--gray-400); font-size: 12px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--cream-200); }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--cream-200); color: var(--gray-800); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cream-100); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-green  { background: #D1FAE5; color: #166534; }
.badge-red    { background: #FFE4E4; color: #9B1C1C; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-gray   { background: var(--cream-200); color: var(--gray-600); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 700; cursor: pointer; border: none; text-decoration: none; font-family: 'Nunito', system-ui, sans-serif; transition: opacity .15s, box-shadow .15s; }
.btn:hover { opacity: .88; box-shadow: var(--shadow-md); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-gray     { background: var(--cream-200); color: var(--gray-800); }
.btn-sm       { padding: 5px 10px; font-size: 13px; }

/* Form sections */
.form-section { margin-bottom: 28px; }
.form-section:last-of-type { margin-bottom: 0; }

.form-section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--gray-800);
    padding: 8px 12px;
    margin-bottom: 16px;
    border-left: 5px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: rgba(232, 130, 58, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.form-section-title:hover { background: rgba(232, 130, 58, 0.13); }

.form-section-chevron {
    margin-left: auto;
    font-size: 11px;
    color: var(--gray-400);
    transition: transform .25s ease;
}

.form-section-body {
    overflow: hidden;
    transition: max-height .3s ease, opacity .25s ease;
}

.form-check { display: flex; align-items: center; gap: 10px; }
.form-check input[type="checkbox"] { width: 18px; min-width: 18px; }
.form-check label { font-size: 14px; font-weight: 600; color: var(--gray-800); cursor: pointer; margin: 0; }

.form-actions { display: flex; gap: 12px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--cream-200); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--gray-600); }
input:not([type="checkbox"]):not([type="radio"]), select {
    padding: 9px 12px;
    border: 1px solid var(--cream-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: 'Nunito', system-ui, sans-serif;
    color: var(--gray-800);
    background: var(--cream-50);
    width: 100%;
    appearance: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,130,58,.15); }
.select-wrap { position: relative; }
.select-wrap::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; font-size: 11px; }

/* Login */
.login-wrap { display: flex; min-height: 100vh; }

.login-brand {
    flex: 1;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.login-brand-content { text-align: center; color: #fff; }
.login-brand-content i { font-size: 72px; color: var(--accent); display: block; margin-bottom: 24px; }
.login-brand-content h1 { font-size: 34px; font-weight: 800; margin-bottom: 10px; }
.login-brand-content p { font-size: 15px; color: rgba(255,255,255,.45); }

.login-form-panel {
    width: 460px;
    min-width: 360px;
    background: var(--cream-100);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.login-box { width: 100%; }
.login-box h2 { font-size: 22px; font-weight: 800; color: var(--gray-800); margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--gray-400); margin-bottom: 28px; }
.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; padding: 11px; }
.error-msg { background: #FFE4E4; color: #9B1C1C; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 600; margin-bottom: 20px; }
.alert-success { background: #D1FAE5; color: #166534; }
.alert-danger   { background: #FFE4E4; color: #9B1C1C; }

/* Actions */
.actions { display: flex; gap: 8px; }

/* Spinner */
.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--cream-200);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

code {
    background: var(--cream-200);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
}

/* Checkbox custom */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    border: 1px solid var(--cream-200);
    border-radius: 4px;
}

/* Stats section label */
.stats-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-400);
    margin-bottom: 12px;
    margin-top: 4px;
}

/* Status dot color variants */
.status-dot-success { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.status-dot-danger  { background: var(--danger); }

/* Mobile container cards */
.container-list-cards { display: none; flex-direction: column; gap: 8px; }

.container-mobile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--cream-100);
    border: 1px solid var(--cream-200);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
}
.container-mobile-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }

.container-mobile-card-body { flex: 1; min-width: 0; }
.container-mobile-card-name { font-size: 14px; font-weight: 700; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.container-mobile-card-domain { font-size: 12px; color: var(--gray-400); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.container-mobile-card-arrow { color: var(--gray-400); font-size: 12px; flex-shrink: 0; }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: relative;
    cursor: default;
    flex-shrink: 0;
}

.status-dot::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    background: var(--gray-800);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 200;
}

.status-dot:hover::after {
    opacity: 1;
}

/* ─── Backup progress steps ─── */
.backup-steps { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }

.backup-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
}

.backup-step-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.backup-step-label { flex: 1; }
.backup-step-msg   { font-size: 12px; font-weight: 400; color: var(--gray-400); }

.backup-step.step-pending .backup-step-icon  { background: var(--cream-200); color: var(--gray-400); }
.backup-step.step-pending .backup-step-label { color: var(--gray-400); }
.backup-step.step-running .backup-step-icon  { background: #FEF3C7; color: var(--warning); }
.backup-step.step-running .backup-step-label { color: var(--gray-800); }
.backup-step.step-done    .backup-step-icon  { background: #D1FAE5; color: var(--success); }
.backup-step.step-done    .backup-step-label { color: var(--success); }
.backup-step.step-error   .backup-step-icon  { background: #FFE4E4; color: var(--danger); }
.backup-step.step-error   .backup-step-label { color: var(--danger); }

/* ─── Hamburger button (hidden on desktop) ─── */
.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 18px;
    padding: 6px 8px;
    border-radius: var(--radius);
    align-items: center;
    justify-content: center;
    transition: background .15s;
    margin-right: 4px;
    flex-shrink: 0;
}
.topbar-menu-btn:hover { background: var(--cream-200); }

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
}

/* ─── Mobile ─── */
@media (max-width: 768px) {

    .topbar-menu-btn { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 200;
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .layout.sidebar-open .sidebar-overlay {
        display: block;
    }

    .main { margin-left: 0; }

    .topbar { padding: 0 16px; }

    .content { padding: 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .detail-grid,
    .detail-grid-3,
    .stats-bars-grid,
    .form-grid { grid-template-columns: 1fr; }

    .login-wrap { flex-direction: column; }
    .login-brand { flex: none; padding: 32px 24px; }
    .login-form-panel { width: 100%; min-width: 0; padding: 32px 24px; }

    .detail-actions { gap: 8px; }

    .form-actions { flex-direction: column; }
    .form-actions .btn { justify-content: center; }

    .stats-row-4 { grid-template-columns: 1fr; row-gap: 8px; }
    .stats-row-3 { grid-template-columns: 1fr 1fr; row-gap: 8px; }
    .stats-row-3 .stats-section-label { grid-column: 1 / -1; }

    .detail-actions .btn .btn-text { display: none; }
    .detail-actions .btn { padding: 8px 10px; }

    .container-list-table { display: none; }
    .container-list-cards { display: flex; }
}
