:root {
    --navy: #143f5f;
    --navy-dark: #0f2f47;
    --blue: #2d6f9f;
    --pale: #eaf3fa;
    --border: #d6e0ea;
    --text: #1f2933;
    --muted: #6b7280;
    --surface: #ffffff;
    --page: #f4f7fb;
    --danger: #b42318;
    --success: #176b3a;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--page);
    color: var(--text);
}
a { color: inherit; }
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, var(--navy), var(--navy-dark));
    color: white;
    padding: 22px 16px;
    box-shadow: 8px 0 32px rgba(15, 47, 71, .18);
}
.brand-block {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 8px 24px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    margin-bottom: 18px;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: white;
    color: var(--navy);
    font-weight: 800;
}
.brand-block strong { display: block; font-size: 18px; }
.brand-block small { color: #b7d8ef; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 12px 12px;
    border-radius: 12px;
    color: #eaf3fa;
    font-weight: 700;
}
.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.workspace {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 30px 0 52px;
}
.page-head {
    background: linear-gradient(135deg, #fff, #f7fbff);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 26px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    box-shadow: 0 16px 45px rgba(15, 47, 71, .09);
    margin-bottom: 20px;
}
.eyebrow {
    margin: 0 0 7px;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    font-size: 12px;
}
h1 { margin: 0 0 8px; color: #0b1726; font-size: clamp(26px, 4vw, 38px); }
h2 { margin: 0 0 18px; color: var(--navy); }
p { line-height: 1.55; }
.page-head p { margin: 0; color: var(--muted); max-width: 780px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(15, 47, 71, .08);
    overflow: hidden;
}
.notice {
    padding: 12px 14px;
    border-radius: 12px;
    margin: 0 0 18px;
    border: 1px solid rgba(23,107,58,.2);
    background: #f0fff4;
    color: var(--success);
    font-weight: 700;
}
section {
    padding: 26px;
    border-bottom: 1px solid var(--border);
}
section:last-child { border-bottom: 0; }
.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label span,
.radio-title {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
    color: #263445;
}
input[type="text"], input[type="email"], textarea, select {
    width: 100%;
    border: 1px solid #cfdbe7;
    border-radius: 12px;
    padding: 12px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: 3px solid rgba(45,111,159,.16);
    border-color: var(--blue);
}
label.wide { display: block; margin-bottom: 16px; }
small { display: block; color: var(--muted); margin: -8px 0 12px; }
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 16px;
}
.check span { margin: 0; }
.radio {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fbfdff;
}
.radio label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 3px 14px 3px 0;
}
.download-panel { background: #f8fbfe; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -10px 30px rgba(15,47,71,.07);
}
.buttons,
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    background: #fff;
    color: var(--navy);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
}
.button:hover,
button:hover { border-color: var(--blue); }
.button.primary,
button.primary {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.button.secondary,
button.secondary { background: #f7fbff; }
.button.small,
button.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}
button.danger {
    color: var(--danger);
    border-color: rgba(180,35,24,.25);
}
.inline-form { display: inline; margin: 0; }
.table-card { padding: 0; overflow-x: auto; }
.list-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}
.list-table th,
.list-table td {
    border-bottom: 1px solid var(--border);
    padding: 14px 14px;
    text-align: left;
    vertical-align: top;
}
.list-table th {
    background: #f2f6fa;
    color: var(--navy);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.list-table td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}
.actions-col { width: 190px; }
code {
    background: #eef5fb;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 3px 6px;
}
.template-form { padding: 24px; }
.template-form > .grid { margin-bottom: 24px; }
.builder-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 20px;
}
.builder-main,
.placeholder-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfdff;
    overflow: hidden;
}
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #f2f6fa;
    border-bottom: 1px solid var(--border);
}
.toolbar select,
.toolbar button { width: auto; min-height: 36px; padding: 7px 10px; }
.editor {
    min-height: 560px;
    margin: 0;
    padding: 30px;
    background: #fff;
    line-height: 1.55;
    outline: none;
}
.editor:focus { box-shadow: inset 0 0 0 3px rgba(45,111,159,.12); }
.placeholder-panel { padding: 18px; max-height: 720px; overflow: auto; }
.placeholder-panel h2 { margin-top: 0; }
.placeholder-panel p { color: var(--muted); margin-top: -8px; }
.placeholder-panel details {
    border-top: 1px solid var(--border);
    padding: 10px 0;
}
.placeholder-panel summary {
    cursor: pointer;
    font-weight: 800;
    color: var(--navy);
}
.placeholder-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
}
.placeholder-list button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}
.form-end { margin-top: 22px; }
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-radius: 0 0 22px 22px;
    }
    .sidebar nav { grid-template-columns: repeat(2, 1fr); }
    .page-head { flex-direction: column; align-items: flex-start; }
    .grid.two, .grid.three, .builder-layout { grid-template-columns: 1fr; }
    .workspace { width: min(100% - 24px, 1180px); padding-top: 18px; }
    .sticky-actions { position: static; }
}
.empty-state {
    padding: 42px 24px;
    text-align: center;
    background: #fbfdff;
}
.empty-state p { color: var(--muted); }
.empty-row {
    text-align: center;
    padding: 34px 18px !important;
    color: var(--muted);
    background: #fbfdff;
}

.editor table,
.editor .template-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0 18px;
    font-size: 14px;
}
.editor th,
.editor td {
    border: 1px solid #d6e0ea;
    padding: 8px 10px;
    vertical-align: top;
}
.editor th {
    background: #f2f6fa;
    color: #143f5f;
    text-align: left;
    font-weight: 800;
}
.editor h1,
.editor h2,
.editor h3 { color: #143f5f; }
.editor h1 { font-size: 26px; margin: 0 0 18px; }
.editor h2 { font-size: 18px; margin: 22px 0 10px; }
.editor small { color: #6b7280; }

.toolbar-separator {
    display: inline-block;
    width: 1px;
    min-height: 34px;
    background: #d6e0ea;
    margin: 0 2px;
}
.editor table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0 18px;
    table-layout: fixed;
}
.editor table th,
.editor table td {
    border: 1px solid #cfdbe7;
    padding: 9px 10px;
    min-width: 42px;
    vertical-align: top;
}
.editor table th {
    background: #f2f6fa;
    color: #143f5f;
    font-weight: 800;
    text-align: left;
}
.editor table.key-value th,
.editor table.template-table.key-value th {
    width: 30%;
    background: #f6f8fa;
    color: #334155;
}
.editor table.checklist th {
    text-align: left;
}
.editor table.checklist td:not(:first-child) {
    text-align: center;
}
.editor td:focus,
.editor th:focus {
    outline: 3px solid rgba(45,111,159,.18);
    outline-offset: -3px;
}
.editor .callout {
    border: 1px solid #d6e0ea;
    background: #f5f8fc;
    padding: 12px 16px;
    margin: 14px 0 18px;
    font-weight: 800;
}
