:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --error: #dc2626;
    --error-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f7f8fb;
    --text: #111827;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

/* ---------- Top navigation ---------- */

.topbar {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
}
.brand-text { white-space: nowrap; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}
.nav-account { margin-left: auto; }

.main-nav > a {
    padding: 9px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
}
.main-nav > a:hover { background: var(--bg); color: var(--primary); }

.nav-dropdown { position: relative; }

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    font: inherit;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
}
.nav-dropdown-toggle:hover,
.nav-dropdown.open .nav-dropdown-toggle {
    background: var(--bg);
    color: var(--primary);
}
.nav-dropdown .caret {
    font-size: 10px;
    opacity: 0.6;
    transition: transform .12s ease;
}
.nav-dropdown.open .caret { transform: rotate(180deg); }

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    padding: 6px;
    z-index: 50;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.nav-dropdown-menu a:hover { background: var(--primary-light); color: var(--primary); }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.nav-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    margin: 0 auto;
    background: var(--text);
    transition: transform .15s ease, opacity .15s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
    .nav-toggle { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        background: white;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 10px;
    }
    .main-nav.open { display: flex; }
    .main-nav > a { padding: 11px 12px; }

    .nav-dropdown-menu {
        display: none;
        position: static;
        box-shadow: none;
        border: none;
        margin-top: 0;
        padding: 0 0 0 14px;
    }
    .nav-dropdown.open .nav-dropdown-menu { display: block; }
}

/* ---------- Layout ---------- */

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}

h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin-top: 32px; }
h3 { font-size: 13px; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.text-capitalize { text-transform: capitalize; }

/* ---------- Dashboard quick actions ---------- */

.quick-actions {
    display: flex;
    gap: 16px;
    margin: 18px 0 30px;
    flex-wrap: wrap;
}
.quick-action-card {
    flex: 1 1 240px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.quick-action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    transform: translateY(-2px);
}
.quick-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}
.quick-action-icon.icon-seo { background: #ecfdf5; color: #059669; }
.quick-action-icon.icon-smo { background: #eff6ff; color: #2563eb; }
.quick-action-icon.icon-client { background: #fdf4ff; color: #a21caf; }
.quick-action-icon.icon-plagiarism { background: #fff7ed; color: #c2410c; }
.quick-action-icon.icon-content { background: #f5f3ff; color: #7c3aed; }
.quick-action-icon.icon-email { background: #fef2f2; color: #dc2626; }

.quick-action-text { display: flex; flex-direction: column; gap: 2px; }
.quick-action-label { font-weight: 700; font-size: 15px; }
.quick-action-sub { font-size: 12px; color: var(--muted); }

/* ---------- Stat cards ---------- */

.cards { display: flex; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 24px;
    min-width: 150px;
    box-shadow: var(--shadow-sm);
}
.card-number { font-size: 30px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.card-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.actions-row { margin: 16px 0; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-link { background: none; color: var(--primary); padding: 9px 6px; }
.btn-large { padding: 12px 22px; font-size: 15px; }

/* ---------- Tables ---------- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
}
.table th, .table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table th { background: #f9fafb; font-weight: 600; color: #374151; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafaff; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: #f3f4f6; color: var(--muted); }

/* ---------- Forms ---------- */

.form { max-width: 640px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--text);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.field-error { color: var(--error); font-size: 13px; display: block; margin-top: 4px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-check label { font-weight: 500; }

.platform-checklist {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 14px;
}

.filter-form .filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: white;
    border: 1px solid var(--border);
    padding: 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.filter-form .form-group { margin-bottom: 0; min-width: 150px; }
.filter-submit { display: flex; gap: 8px; }

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: var(--success-bg); color: #166534; }
.alert-error { background: var(--error-bg); color: #991b1b; }

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    padding: 18px 0;
    margin-top: 44px;
}

/* ---------- Misc ---------- */

.inline-form { display: inline; }
.btn-link-inline {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-link-inline:hover { text-decoration: underline; }
.btn-link-danger { color: var(--error); }

code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
}

.category-levels-container {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 14px 2px;
    max-height: 420px;
    overflow-y: auto;
}
.category-level-group label {
    font-size: 12.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-control[readonly] {
    background: #f9fafb;
    color: var(--text);
    font-weight: 500;
    cursor: default;
}

.plagiarism-score {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 15px;
    margin-bottom: 16px;
}
.plagiarism-score strong { color: var(--error); font-size: 18px; }

.plagiarism-highlighted-text {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    line-height: 1.7;
    white-space: pre-wrap;
    margin-bottom: 20px;
}
.plagiarism-highlighted-text mark {
    background: var(--warning-bg);
    color: #92400e;
    padding: 1px 3px;
    border-radius: 3px;
    cursor: help;
}

/* ---------- Content generation (two-panel editor) ---------- */

.content-gen-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 230px);
    min-height: 480px;
}
.content-gen-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.content-gen-panel-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    background: #f9fafb;
}
.content-gen-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}
.content-gen-toolbar button {
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.content-gen-toolbar button:hover { background: var(--primary-light); border-color: var(--primary); }
.content-gen-editable {
    flex: 1;
    padding: 16px 18px;
    overflow-y: auto;
    outline: none;
    line-height: 1.7;
    font-size: 14px;
}
.content-gen-editable:empty:before {
    content: attr(data-placeholder);
    color: var(--muted);
}
.content-gen-editable h1, .content-gen-editable h2, .content-gen-editable h3 { margin: 0.6em 0 0.3em; }
.content-gen-editable ul, .content-gen-editable ol { margin: 0.4em 0; padding-left: 22px; }
.content-gen-editable p { margin: 0 0 0.8em; }

/* Right panel uses Quill (see Views/ContentGeneration/Index.cshtml) instead of the
   plain contenteditable toolbar above - #outputEditor becomes .ql-container, and
   Quill auto-inserts its own .ql-toolbar right before it, matching this panel's
   flex-column layout (header -> toolbar -> scrollable editor) with no extra markup. */
.content-gen-panel-quill .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
    font-family: inherit;
    flex-shrink: 0;
}
.content-gen-panel-quill .ql-container.ql-snow {
    border: none;
    flex: 1;
    overflow-y: auto;
    font-family: inherit;
    font-size: 14px;
}
.content-gen-panel-quill .ql-editor {
    padding: 16px 18px;
    line-height: 1.7;
    min-height: 100%;
}
.content-gen-panel-quill .ql-editor.ql-blank::before {
    color: var(--muted);
    font-style: normal;
    left: 18px;
}

.content-gen-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

@media (max-width: 860px) {
    .content-gen-layout { grid-template-columns: 1fr; height: auto; }
    .content-gen-panel { height: 420px; }
    .content-gen-controls a { margin-left: 0 !important; }
}

/* ---------- Bulk email progress bar ---------- */

.email-progress-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
}
.email-progress-bar {
    width: 100%;
    height: 10px;
    background: #eef0f4;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 20px;
}
.email-progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width .4s ease;
}

/* ---------- Auth pages (Login/Register/Forgot Password etc.) ---------- */

.auth-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-shell {
    width: 100%;
    max-width: 420px;
    padding: 40px 20px;
}
.auth-brand {
    justify-content: center;
    margin-bottom: 20px;
    font-size: 18px;
}
.auth-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
}
.auth-card h1 { text-align: center; font-size: 22px; }
.auth-card .form { max-width: none; }
.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    font-size: 13px;
}
.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--muted);
}

/* ---------- Client hierarchy tree ---------- */

.client-tree, .client-tree ul {
    list-style: none;
    margin: 0;
    padding-left: 0;
}
.client-tree ul {
    padding-left: 24px;
    border-left: 1px dashed var(--border);
    margin-left: 8px;
}
.client-tree li { margin: 6px 0; }
.client-tree-node {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
}
.client-tree-node .name { font-weight: 600; }
.client-tree-node .actions { margin-left: auto; display: flex; gap: 10px; font-size: 13px; }
