:root {
    --brand: #39A5B7;
    --brand-dark: #2a8898;
    --brand-soft: #e6f6f9;
    --bg: #f7f9fb;
    --card: #ffffff;
    --text: #1f2a37;
    --muted: #6b7280;
    --border: #eef0f3;
    --shadow: 0 8px 24px rgba(17, 24, 39, .06);
    --shadow-lg: 0 16px 40px rgba(17, 24, 39, .08);
    --radius: 16px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 14.5px;
    margin: 0;
    padding: 0;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--border);
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    transition: transform .3s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 22px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 16px; color: var(--text); }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar-nav { padding: 14px 12px; }
.sidebar-nav .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 8px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; margin: 2px 0;
    color: #45526b; border-radius: var(--radius-sm);
    font-weight: 500; font-size: 14px;
    transition: all .15s ease;
}
.sidebar-nav a i { width: 18px; text-align: center; font-size: 15px; color: #8794aa; }
.sidebar-nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.sidebar-nav a:hover i { color: var(--brand-dark); }
.sidebar-nav a.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff; box-shadow: 0 6px 14px rgba(57, 165, 183, .3);
}
.sidebar-nav a.active i { color: #fff; }

.main { flex: 1; margin-left: 260px; min-height: 100vh; }

.topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.lang-switch { display: inline-flex; background: var(--bg); padding: 4px; border-radius: 999px; border: 1px solid var(--border); }
.lang-switch a {
    padding: 6px 14px; font-size: 13px; font-weight: 600;
    color: var(--muted); border-radius: 999px;
}
.lang-switch a.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; background: var(--bg); border-radius: 999px; }
.user-chip .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-chip .name { font-size: 13px; font-weight: 600; }

.content { padding: 28px; max-width: 1280px; margin: 0 auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header .subtitle { color: var(--muted); font-size: 14px; margin-top: 4px; }

.card-soft {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 22px;
}
.card-soft h3 { font-size: 16px; font-weight: 700; margin: 0 0 16px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--border); padding: 22px;
    display: flex; align-items: center; gap: 16px;
    transition: transform .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .icon-wrap { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; color: #fff; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); }
.stat-card .stat-num { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; color: var(--text); }
.form-label .req { color: #ef4444; }
.form-control, .form-select {
    width: 100%; padding: 11px 14px; font-size: 14px;
    background: #fff; border: 1px solid #e1e6ec; border-radius: var(--radius-sm);
    transition: all .15s ease; outline: none;
}
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(57,165,183,.15); }
textarea.form-control { min-height: 110px; resize: vertical; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; font-weight: 600; font-size: 14px; border: 0; border-radius: var(--radius-sm); cursor: pointer; transition: all .15s ease; }
.btn-primary { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; box-shadow: 0 6px 14px rgba(57,165,183,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(57,165,183,.4); color: #fff; }
.btn-light { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-light:hover { background: var(--bg); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-icon { padding: 8px 10px; }

/* Tables */
.table-soft { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-soft thead th { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table-soft tbody td { padding: 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table-soft tbody tr:hover { background: var(--bg); }
.table-thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg); }

/* Image upload preview */
.image-uploader { position: relative; }
.image-uploader .drop-zone {
    border: 2px dashed #d1d8e0; border-radius: var(--radius-sm);
    padding: 26px; text-align: center; cursor: pointer;
    background: var(--bg); transition: all .15s ease;
}
.image-uploader .drop-zone:hover { border-color: var(--brand); background: var(--brand-soft); }
.image-uploader .drop-zone i { font-size: 28px; color: var(--brand); margin-bottom: 8px; display: block; }
.image-uploader .drop-zone .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.preview-item { position: relative; width: 110px; height: 110px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove-btn {
    position: absolute; top: 4px; right: 4px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(0,0,0,.65); color: #fff;
    display: grid; place-items: center;
    cursor: pointer; border: 0; font-size: 11px;
}
.preview-item .remove-btn:hover { background: #ef4444; }

/* Lang tabs */
.lang-tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 999px; margin-bottom: 16px; width: fit-content; }
.lang-tabs button { padding: 8px 18px; border: 0; background: transparent; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; position: relative; }
.lang-tabs button.active { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow); }
.lang-tabs button.has-error { color: #ef4444; }
.lang-tabs button.has-error::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }
.lang-pane { display: none; }
.lang-pane.active { display: block; }

/* Invalid form state */
.form-control.is-invalid, .form-select.is-invalid { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239, 68, 68, .12) !important; }
.invalid-feedback { color: #ef4444; font-size: 12px; margin-top: 4px; display: block; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Toasts */
#toast-stack { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-item { background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px 18px; min-width: 240px; border-left: 4px solid var(--brand); animation: slideIn .25s ease; }
.toast-item.success { border-left-color: #10b981; }
.toast-item.danger { border-left-color: #ef4444; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Confirm-toast popup (replaces native confirm()) */
.confirm-toast-backdrop {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(15, 23, 42, 0.45);
    display: grid; place-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .18s ease;
}
.confirm-toast-backdrop.is-open { opacity: 1; }
.confirm-toast {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 60px -15px rgba(0,0,0,0.35);
    width: 100%;
    max-width: 440px;
    padding: 22px 24px 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transform: translateY(8px) scale(0.98);
    transition: transform .2s ease;
}
.confirm-toast-backdrop.is-open .confirm-toast { transform: translateY(0) scale(1); }
.confirm-toast__icon {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 20px;
}
.confirm-toast__icon--danger { background: #fee2e2; color: #dc2626; }
.confirm-toast__icon--primary { background: var(--brand-soft); color: var(--brand-dark); }
.confirm-toast__body { flex: 1; min-width: 0; }
.confirm-toast__msg {
    font-size: 14.5px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 16px;
}
.confirm-toast__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.confirm-toast__actions .btn { min-width: 90px; }
@media (max-width: 480px) {
    .confirm-toast { flex-direction: column; padding: 20px; }
    .confirm-toast__actions { width: 100%; }
    .confirm-toast__actions .btn { flex: 1; }
}

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand-soft) 0%, #f7f9fb 100%); padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 22px; box-shadow: var(--shadow-lg); padding: 38px; border: 1px solid var(--border); }
.login-logo { display: grid; place-items: center; margin-bottom: 22px; }
.login-logo img { width: 64px; height: 64px; object-fit: contain; border-radius: 16px; }
.login-card h1 { font-size: 22px; font-weight: 700; text-align: center; margin: 0 0 6px; }
.login-card .lead { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }

/* Mobile */
.menu-toggle { display: none; background: transparent; border: 0; font-size: 20px; color: var(--text); cursor: pointer; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 45; }
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 18px; }
}

/* Spinner */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* CKEditor wrapper */
.cke_chrome { border-radius: var(--radius-sm) !important; border-color: #e1e6ec !important; }
