* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f8fafc;
    color: #111827;
    font-size: 14px;
    line-height: 1.5;
}

a { color: #2c7be5; text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
pre {
    background: #f3f4f6;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}

.muted { color: #6b7280; }
.small { font-size: 12px; }

/* APP LAYOUT */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: #0f172a;
    color: #e5e7eb;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar .brand {
    padding: 0 20px 20px;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 12px;
}

.sidebar nav { flex: 1; padding: 0 8px; }
.sidebar nav a {
    display: block;
    padding: 8px 12px;
    color: #cbd5e1;
    border-radius: 6px;
    margin: 2px 0;
    font-size: 13px;
}
.sidebar nav a:hover { background: #1e293b; text-decoration: none; }
.sidebar nav a.active { background: #2c7be5; color: #fff; }

.nav-group-title {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: #94a3b8;
    padding: 16px 12px 4px;
}

.user-block {
    padding: 12px 20px;
    border-top: 1px solid #1f2937;
    font-size: 12px;
}
.user-name { color: #cbd5e1; margin-bottom: 4px; }
.logout-link { color: #f87171; font-size: 12px; }

.main {
    flex: 1;
    padding: 24px 32px 0;
    margin-left: 240px;
    overflow-x: auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page {
    flex: 1 0 auto;
}

.cms-footer {
    flex-shrink: 0;
    margin-top: 32px;
    padding: 16px 0;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
}
.page { max-width: 1100px; }

/* FLASHES */
.flashes { margin-bottom: 16px; }
.flash {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error   { background: #fee2e2; color: #991b1b; }
.flash-info    { background: #dbeafe; color: #1e3a8a; }

/* CARDS */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}
.card-link {
    display: block;
    padding: 20px 20px 12px;
    color: inherit;
    flex: 1;
}
.card-link:hover { text-decoration: none; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .meta { list-style: none; padding: 0; margin: 12px 0 0; font-size: 12px; color: #4b5563; }
.card .meta li { margin: 4px 0; }
.card-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid #f3f4f6;
}
.card-actions .btn { flex: 1; text-align: center; }

/* PANELS */
.panel {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    margin-bottom: 20px;
}

/* TABS */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid #e5e7eb; }
.tab {
    padding: 8px 14px;
    color: #4b5563;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 13px;
}
.tab:hover { color: #111827; text-decoration: none; }
.tab.tab-active { color: #2c7be5; border-bottom-color: #2c7be5; }

/* FORMS */
label {
    display: block;
    font-size: 13px;
    margin-bottom: 14px;
    color: #374151;
}
label > input,
label > textarea,
label > select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #2c7be5;
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.15);
}

.inline-label { display: inline-flex; align-items: center; gap: 8px; }
.inline-label input { width: auto; margin: 0; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.grid-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* BUTTONS */
.btn {
    display: inline-block;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: #2c7be5; color: #fff; border-color: #2c7be5; }
.btn-primary:hover { background: #1f6fd4; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline {
    background: transparent;
    color: #2c7be5;
    border: 1px solid #2c7be5;
}
.btn-outline:hover { background: #eff6ff; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.inline-form { display: inline-block; }

/* PAGE HEADER (heading + action button row) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 4px; }
.page-header .btn { white-space: nowrap; }

/* MEDIA */
.media-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.media-preview {
    width: 220px;
    height: 140px;
    background: #111827 center/cover no-repeat;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    overflow: hidden;
}
.media-preview-light { background: #f3f4f6; }
.media-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.media-form { flex: 1; min-width: 240px; }
.media-form input[type=file] { display: block; margin-bottom: 10px; }

/* DATA TABLE */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}
.data-table th { background: #f9fafb; font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }
.payload-snippet {
    display: inline-block;
    max-width: 480px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* SLIDES */
.slides-list { list-style: none; margin: 0; padding: 0; }
.slide-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: grab;
}
.slide-item img { width: 80px; height: 60px; object-fit: cover; border-radius: 4px; }
.slide-item.dragging { opacity: 0.5; }
.grip { color: #9ca3af; font-size: 18px; cursor: grab; }

.slides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.slide-delete {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    padding-bottom: 8px;
}
.slide-delete img { width: 100%; height: 100px; object-fit: cover; display: block; margin-bottom: 6px; }

/* FORM BUILDER */
.builder-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.fields-list { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.field-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
}
.field-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.field-type-badge {
    background: #2c7be5;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.field-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.field-card-grid label { margin-bottom: 0; }
.field-card .full { grid-column: 1 / -1; }
.field-actions { margin-left: auto; display: flex; gap: 4px; }
.builder-footer {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

/* FORM PREVIEW */
.form-preview {
    background: #111827;
    padding: 24px;
    border-radius: 10px;
    color: #fff;
}
.form-preview .pf-field { margin-bottom: 12px; }
.form-preview .pf-label { display: block; margin-bottom: 4px; font-size: 13px; color: #cbd5e1; }
.form-preview input,
.form-preview textarea,
.form-preview select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.95);
    color: #111827;
    font-size: 14px;
}
.form-preview .pf-options { display: flex; flex-wrap: wrap; gap: 12px; color: #e5e7eb; }
.form-preview .pf-submit {
    margin-top: 6px;
    padding: 10px 20px;
    background: #2c7be5;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

/* TOOLBAR */
.toolbar-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* LOGIN */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0f172a;
    padding: 24px;
}
.login-card {
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .btn-primary { width: 100%; padding: 10px; font-size: 14px; margin-top: 8px; }
