/* ── RESET & BASE ── */
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Inter',system-ui,sans-serif;font-size:14px;color:#1e1e2e;background:#f4f5fa;min-height:100vh}
a{color:#4f46e5;text-decoration:none}a:hover{text-decoration:underline}
input,textarea,select,button{font-family:inherit;font-size:14px}
textarea{resize:vertical}

/* ── NAVBAR ── */
.navbar{background:#fff;border-bottom:1px solid #e5e7eb;height:58px;display:flex;align-items:center;justify-content:space-between;padding:0 24px;position:sticky;top:0;z-index:100;box-shadow:0 1px 4px rgba(0,0,0,.06)}
.navbar-brand{display:flex;align-items:center;gap:8px;font-weight:700;font-size:1rem;color:#1e1e2e;text-decoration:none}
.brand-icon{font-size:1.4rem}
.navbar-menu{display:flex;gap:4px}
.nav-link{padding:6px 14px;border-radius:7px;color:#6b7280;font-weight:500;transition:.15s;text-decoration:none}
.nav-link:hover,.nav-link.active{background:#ede9fe;color:#4f46e5;text-decoration:none}
.navbar-user{display:flex;align-items:center;gap:10px}
.user-badge{font-size:.8rem;font-weight:600;padding:4px 12px;background:#f3f4f6;border-radius:20px;color:#374151}
.user-badge.admin{background:#ede9fe;color:#7c3aed}
.btn-logout{font-size:.8rem;color:#6b7280;padding:4px 10px;border-radius:6px;border:1px solid #e5e7eb;transition:.15s}
.btn-logout:hover{background:#fee2e2;color:#dc2626;border-color:#fca5a5;text-decoration:none}

/* ── FLASH ── */
.flash{padding:12px 20px;font-size:.9rem;font-weight:500;display:flex;align-items:center;justify-content:space-between}
.flash-success{background:#d1fae5;color:#065f46;border-bottom:1px solid #a7f3d0}
.flash-error{background:#fee2e2;color:#991b1b;border-bottom:1px solid #fca5a5}
.flash-close{background:none;border:none;font-size:1.2rem;cursor:pointer;color:inherit;opacity:.6}
.flash-close:hover{opacity:1}

/* ── MAIN ── */
.main-content{padding:28px 32px;max-width:1400px;margin:0 auto}

/* ── PAGE HEADER ── */
.page-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:24px;gap:16px}
.page-title{font-size:1.5rem;font-weight:700;color:#1e1e2e}
.page-subtitle{color:#6b7280;font-size:.9rem;margin-top:2px}
.breadcrumb{font-size:.82rem;color:#9ca3af;margin-bottom:4px;display:block;text-decoration:none}
.breadcrumb:hover{color:#4f46e5}

/* ── BUTTONS ── */
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 18px;border-radius:8px;font-weight:500;border:none;cursor:pointer;transition:.15s;text-decoration:none;white-space:nowrap}
.btn:hover{text-decoration:none;transform:translateY(-1px)}
.btn-primary{background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;box-shadow:0 2px 8px rgba(79,70,229,.25)}
.btn-primary:hover{box-shadow:0 4px 14px rgba(79,70,229,.35);color:#fff}
.btn-ghost{background:transparent;border:1.5px solid #e5e7eb;color:#374151}
.btn-ghost:hover{border-color:#4f46e5;color:#4f46e5;background:#ede9fe}
.btn-outline{background:transparent;border:1.5px solid #e5e7eb;color:#374151;display:block;text-align:center}
.btn-outline:hover{border-color:#4f46e5;color:#4f46e5;background:#f5f3ff;text-decoration:none}
.btn-full{width:100%;justify-content:center}
.btn-success{background:#059669;color:#fff}
.btn-success:hover{background:#047857;color:#fff}
.btn-danger-ghost{background:transparent;border:1.5px solid #fca5a5;color:#dc2626}
.btn-danger-ghost:hover{background:#fee2e2}
.btn-sm{padding:5px 12px;font-size:.82rem}
.btn-xs{padding:3px 8px;font-size:.78rem;border-radius:5px}

/* ── FORMS ── */
.form-group{margin-bottom:16px}
label{display:block;font-weight:500;color:#374151;margin-bottom:5px;font-size:.85rem}
.req{color:#4f46e5}
input[type=text],input[type=email],input[type=url],input[type=password],input[type=date],input[type=number],textarea,select{
  width:100%;padding:9px 13px;border:1.5px solid #e5e7eb;border-radius:8px;color:#1e1e2e;background:#fff;transition:.15s}
input:focus,textarea:focus,select:focus{outline:none;border-color:#4f46e5;box-shadow:0 0 0 3px rgba(79,70,229,.1)}
.field-hint{font-size:.75rem;color:#9ca3af;margin-top:3px}
.select-inline{width:auto;padding:3px 8px;border-radius:5px;font-size:.82rem}

/* ── DASHBOARD GRID ── */
.projects-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:20px}
.project-card{background:#fff;border-radius:14px;padding:22px;border:1.5px solid #e5e7eb;transition:.2s;display:flex;flex-direction:column;gap:12px}
.project-card:hover{border-color:#c4b5fd;box-shadow:0 4px 20px rgba(79,70,229,.1)}
.project-card-header{display:flex;align-items:center;justify-content:space-between}
.template-badge{font-size:.75rem;font-weight:600;padding:3px 10px;background:#f5f3ff;color:#7c3aed;border-radius:20px}
.owner-badge{font-size:.72rem;color:#9ca3af}
.project-name{font-size:1rem;font-weight:700;color:#1e1e2e}
.project-url{font-size:.8rem;color:#9ca3af;word-break:break-all}
.project-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.doc-count{font-size:.78rem;font-weight:600;background:#e0e7ff;color:#4338ca;padding:2px 8px;border-radius:20px}
.updated-at{font-size:.75rem;color:#9ca3af}

/* ── EMPTY STATE ── */
.empty-state{text-align:center;padding:64px 32px;color:#9ca3af}
.empty-icon{font-size:3rem;margin-bottom:12px}
.empty-state h3{font-size:1.1rem;color:#374151;font-weight:600;margin-bottom:8px}
.empty-state p{max-width:340px;margin:0 auto 20px;line-height:1.6}

/* ── PROJECT DOCS ── */
.docs-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:20px}
.doc-card{background:#fff;border-radius:14px;padding:24px;border:1.5px solid #e5e7eb;display:flex;flex-direction:column;gap:14px}
.doc-card.has-doc{border-color:#c4b5fd}
.doc-card-icon{font-size:2.5rem}
.doc-card-body{flex:1}
.doc-card-body h3{font-size:1rem;font-weight:700;margin-bottom:4px}
.doc-desc{font-size:.82rem;color:#6b7280;margin-bottom:10px}
.doc-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.status-badge{font-size:.75rem;font-weight:600;padding:3px 10px;border-radius:20px}
.status-published{background:#d1fae5;color:#065f46}
.status-draft{background:#fef3c7;color:#92400e}
.doc-version{font-size:.75rem;color:#9ca3af}
.doc-date{font-size:.75rem;color:#9ca3af}
.doc-empty-note{font-size:.82rem;color:#d1d5db;font-style:italic}
.doc-card-actions{display:flex;gap:8px;flex-wrap:wrap}

/* ── EDITOR ── */
.editor-layout{display:grid;grid-template-columns:380px 1fr;height:calc(100vh - 58px);overflow:hidden}
.editor-sidebar{background:#fff;border-right:1px solid #e5e7eb;overflow-y:auto;display:flex;flex-direction:column}
.editor-sidebar::-webkit-scrollbar{width:4px}
.editor-sidebar::-webkit-scrollbar-thumb{background:#e5e7eb;border-radius:4px}
.editor-sidebar-header{padding:20px 22px 16px;border-bottom:1px solid #f3f4f6}
.editor-sidebar-header h2{font-size:1.05rem;font-weight:700;margin:4px 0}
.version-badge{font-size:.75rem;color:#9ca3af}
.editor-preview{overflow-y:auto;background:#f4f5fa;display:flex;flex-direction:column}
.preview-toolbar{background:#fff;border-bottom:1px solid #e5e7eb;padding:10px 20px;display:flex;align-items:center;justify-content:space-between}
.preview-label{font-size:.82rem;font-weight:600;color:#6b7280}
.preview-content{padding:24px;flex:1}
.preview-placeholder{display:flex;align-items:center;justify-content:center;height:200px;color:#9ca3af;font-size:.95rem}
.editor-actions{padding:16px 22px;border-top:1px solid #f3f4f6;display:flex;gap:8px;background:#fff;position:sticky;bottom:0}
.editor-actions .btn{flex:1;justify-content:center}

/* ── FORM SECTIONS ── */
.form-section{padding:16px 22px;border-bottom:1px solid #f3f4f6}
.form-section-title{font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#9ca3af;margin-bottom:12px}

/* ── TOGGLES ── */
.toggle-list{display:flex;flex-direction:column;gap:4px}
.toggle-item{display:flex;align-items:center;justify-content:space-between;padding:9px 12px;border-radius:8px;cursor:pointer;transition:.15s}
.toggle-item:hover{background:#f5f3ff}
.toggle-disabled{opacity:.5;cursor:not-allowed;pointer-events:none}
.toggle-info{display:flex;flex-direction:column;gap:1px}
.toggle-name{font-size:.85rem;font-weight:500;color:#1e1e2e}
.toggle-desc{font-size:.73rem;color:#9ca3af}
.toggle-switch{position:relative;width:38px;height:21px;flex-shrink:0}
.toggle-switch input{opacity:0;width:0;height:0;position:absolute}
.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background:#e5e7eb;border-radius:21px;transition:.25s}
.slider:before{content:'';position:absolute;width:15px;height:15px;left:3px;bottom:3px;background:#fff;border-radius:50%;transition:.25s;box-shadow:0 1px 3px rgba(0,0,0,.15)}
input:checked+.slider{background:#4f46e5}
input:checked+.slider:before{transform:translateX(17px)}

/* ── DOCUMENT PREVIEW STYLES ── */
.doc-preview{background:#fff;border-radius:12px;padding:36px 40px;max-width:780px;margin:0 auto;box-shadow:0 2px 12px rgba(0,0,0,.06)}
.doc-header{border-bottom:2px solid #4f46e5;padding-bottom:18px;margin-bottom:24px}
.doc-preview h1{font-size:1.8rem;color:#4f46e5;font-family:'DM Serif Display',Georgia,serif;margin-bottom:4px}
.doc-subtitle{color:#6b7280;font-style:italic;font-size:.9rem}
.doc-date{font-size:.78rem;color:#9ca3af;margin-top:4px}
.doc-intro{color:#374151;line-height:1.75;margin-bottom:22px;font-size:.93rem}
.doc-preview h2{font-size:1.05rem;color:#4f46e5;border-left:3px solid #4f46e5;padding-left:10px;margin:24px 0 10px}
.doc-preview h3{font-size:.9rem;font-weight:700;color:#1e1e2e;margin:14px 0 6px}
.doc-preview p{color:#374151;line-height:1.75;margin-bottom:10px;font-size:.9rem}
.doc-preview ul,.doc-preview ol{padding-left:20px;margin-bottom:10px}
.doc-preview li{color:#374151;line-height:1.7;font-size:.9rem;margin-bottom:4px}
.doc-note{background:#ede9fe;border-left:3px solid #4f46e5;padding:10px 14px;border-radius:5px;margin:10px 0;font-style:italic;font-size:.85rem;color:#3730a3}
.doc-table{width:100%;border-collapse:collapse;margin:12px 0;font-size:.85rem}
.doc-table thead tr{background:#4f46e5}
.doc-table thead th{color:#fff;padding:8px 12px;text-align:left;font-weight:500}
.doc-table tbody tr:nth-child(even){background:#f5f3ff}
.doc-table tbody td{padding:7px 12px;border-bottom:1px solid #e5e7eb;color:#374151}
.doc-table td.yes{color:#dc2626;font-weight:600}
.doc-table td.no{color:#059669}
.doc-footer{border-top:1px solid #e5e7eb;padding-top:14px;margin-top:28px;font-size:.75rem;color:#9ca3af;font-style:italic}

/* ── TABLES ── */
.table-container{background:#fff;border-radius:12px;border:1px solid #e5e7eb;overflow:hidden}
.data-table{width:100%;border-collapse:collapse}
.data-table thead tr{background:#f9fafb;border-bottom:1px solid #e5e7eb}
.data-table thead th{padding:12px 16px;text-align:left;font-weight:600;font-size:.8rem;color:#6b7280;text-transform:uppercase;letter-spacing:.04em}
.data-table tbody tr{border-bottom:1px solid #f3f4f6;transition:.1s}
.data-table tbody tr:hover{background:#fafafa}
.data-table tbody tr.row-inactive{opacity:.5}
.data-table tbody td{padding:12px 16px;color:#374151;font-size:.88rem;vertical-align:middle}
.actions-cell{display:flex;gap:6px;align-items:center;flex-wrap:wrap}

/* ── BADGES ── */
.badge{display:inline-block;font-size:.72rem;font-weight:600;padding:3px 10px;border-radius:20px;border:none;cursor:default}
.badge-active{background:#d1fae5;color:#065f46}
.badge-inactive{background:#fee2e2;color:#991b1b}
.badge-admin{background:#ede9fe;color:#7c3aed}
.badge-you{background:#e0e7ff;color:#4338ca;font-size:.68rem;padding:1px 7px;border-radius:20px;margin-left:5px}
.badge-cat{background:#e0f2fe;color:#0369a1}

/* ── MODALS ── */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:1000;display:flex;align-items:center;justify-content:center;padding:20px}
.modal{background:#fff;border-radius:16px;max-height:90vh;overflow-y:auto;width:100%;max-width:540px;box-shadow:0 20px 60px rgba(0,0,0,.2)}
.modal-wide{max-width:820px}
.modal-header{padding:20px 24px;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff}
.modal-header h3{font-size:1rem;font-weight:700}
.modal-close{background:none;border:none;font-size:1.5rem;cursor:pointer;color:#9ca3af;line-height:1}
.modal-close:hover{color:#1e1e2e}
.modal-body{padding:20px 24px}
.modal-footer{padding:16px 24px;border-top:1px solid #e5e7eb;display:flex;justify-content:flex-end;gap:10px}

/* ── TEMPLATE GRID (new project modal) ── */
.template-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;max-height:300px;overflow-y:auto;padding:4px}
.template-option{cursor:pointer}
.template-option input{display:none}
.template-option-inner{display:flex;flex-direction:column;padding:10px 12px;border-radius:8px;border:1.5px solid #e5e7eb;transition:.15s;gap:3px}
.template-option:hover .template-option-inner{border-color:#c4b5fd}
.template-option input:checked+.template-option-inner{border-color:#4f46e5;background:#f5f3ff}
.template-option-icon{font-size:1.4rem}
.template-option-name{font-weight:600;font-size:.85rem;color:#1e1e2e}
.template-option-desc{font-size:.75rem;color:#6b7280;line-height:1.4}

/* ── HISTORY TABLE ── */
.history-table{width:100%;border-collapse:collapse;font-size:.88rem}
.history-table th{padding:8px 12px;text-align:left;background:#f9fafb;font-weight:600;color:#6b7280;border-bottom:1px solid #e5e7eb}
.history-table td{padding:8px 12px;border-bottom:1px solid #f3f4f6}

/* ── TOAST ── */
.toast{position:fixed;bottom:24px;right:24px;padding:12px 20px;border-radius:10px;font-size:.88rem;font-weight:500;box-shadow:0 8px 24px rgba(0,0,0,.15);transform:translateY(60px);opacity:0;transition:all .3s cubic-bezier(.34,1.56,.64,1);z-index:2000}
.toast.show{transform:translateY(0);opacity:1}
.toast-success{background:#1e1e2e;color:#d1fae5}
.toast-error{background:#dc2626;color:#fff}

/* ── FOOTER ── */
.footer{text-align:center;padding:16px;font-size:.75rem;color:#9ca3af;border-top:1px solid #e5e7eb;background:#fff;margin-top:auto}

/* ── ALERT ── */
.alert{padding:12px 16px;border-radius:8px;margin-bottom:16px;font-size:.88rem}
.alert-error{background:#fee2e2;color:#991b1b;border:1px solid #fca5a5}
.alert-success{background:#d1fae5;color:#065f46}

/* ── LOGIN ── */
.login-body{display:flex;align-items:center;justify-content:center;min-height:100vh;background:linear-gradient(135deg,#ede9fe,#e0e7ff)}
.login-container{width:100%;max-width:400px;padding:20px}
.login-card{background:#fff;border-radius:20px;padding:40px;box-shadow:0 16px 48px rgba(79,70,229,.15)}
.login-logo{text-align:center;margin-bottom:28px}
.login-icon{font-size:3rem;display:block;margin-bottom:8px}
.login-logo h1{font-size:1.6rem;font-weight:700;color:#1e1e2e}
.login-logo p{color:#6b7280;font-size:.9rem}
.login-form .form-group{margin-bottom:18px}
.btn-login{width:100%;padding:12px;background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;border:none;border-radius:10px;font-size:1rem;font-weight:600;cursor:pointer;transition:.15s}
.btn-login:hover{opacity:.9;transform:translateY(-1px)}

/* ── RESPONSIVE ── */
@media(max-width:900px){
  .editor-layout{grid-template-columns:1fr;height:auto}
  .editor-sidebar{height:auto;max-height:60vh}
  .main-content{padding:16px}
  .projects-grid,.docs-grid{grid-template-columns:1fr}
}
