:root {
    --bg:       #f0ede8;
    --surface:  #ffffff;
    --primary:  #5a3e10;
    --primary-h:#7a5c1e;
    --accent:   #b8962e;
    --danger:   #c0392b;
    --success:  #27ae60;
    --text:     #2c2416;
    --muted:    #8a7560;
    --border:   #e8dfc8;
    --radius:   6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Auth layout ─────────────────────────────────────────────── */

.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 20px rgba(0,0,0,.07);
}

.auth-card h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: .3rem;
}

.auth-subtitle {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 1.5rem;
}

.auth-sep {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
    color: var(--muted);
    font-size: .85rem;
}
.auth-sep::before, .auth-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--border);
}
.auth-sep::before { left: 0; }
.auth-sep::after  { right: 0; }
.auth-sep span { position: relative; background: var(--surface); padding: 0 .75rem; }

/* ── App layout ──────────────────────────────────────────────── */

body.app-body {
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 60px;
}

.app-header-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.app-header-name { color: var(--primary); }

.app-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-link {
    font-size: .85rem;
    color: var(--muted);
    text-decoration: none;
}
.header-link:hover { color: var(--primary); }

.header-user {
    font-size: .85rem;
    color: var(--muted);
}

.app-main {
    flex: 1;
    padding: 0;
}

.app-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: .8rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

/* ── Page containers ─────────────────────────────────────────── */

.page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

.page-container--narrow {
    max-width: 700px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

/* ── Cards ───────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.card--danger {
    border-color: #fca5a5;
    background: #fff5f5;
}

.mb-4 { margin-bottom: 1.5rem; }

/* ── Themes grid ─────────────────────────────────────────────── */

.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.theme-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.theme-card--inactive {
    opacity: .65;
}

.theme-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
}

.theme-card-title {
    font-size: 1rem;
    font-weight: 700;
}

.theme-card-title a {
    color: var(--primary);
    text-decoration: none;
}
.theme-card-title a:hover { text-decoration: underline; }

.theme-card-badges {
    display: flex;
    gap: .3rem;
    flex-shrink: 0;
}

.theme-card-owner, .theme-card-terms {
    font-size: .82rem;
    color: var(--muted);
    line-height: 1.4;
}

.theme-card-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: .3rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--muted);
}

.empty-state .btn { margin-top: 1rem; }

/* ── Badges ──────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 3px;
    background: #f0ede8;
    color: var(--muted);
}

.badge-active   { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-public   { background: #dbeafe; color: #1e40af; }

/* ── Forms ───────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: .35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .9rem;
    color: var(--text);
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(184,150,46,.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-hint {
    font-size: .78rem;
    color: var(--muted);
    margin-top: .25rem;
}

.form-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1.5rem;
}

.required { color: var(--danger); }

.checkbox-grid {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface);
    color: var(--text);
    transition: background .12s, border-color .12s;
    white-space: nowrap;
}

.btn:hover { background: var(--bg); border-color: #c8b890; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #a93226; border-color: #a93226; }

.btn-ua {
    background: #002855;
    color: #fff;
    border-color: #002855;
    width: 100%;
    padding: .7rem;
    font-size: .9rem;
}
.btn-ua:hover { background: #003a7a; border-color: #003a7a; }

.btn-sm {
    padding: .3rem .7rem;
    font-size: .82rem;
}

/* ── Alerts ──────────────────────────────────────────────────── */

.alert {
    padding: .75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Tables ──────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.data-table th {
    text-align: left;
    padding: .5rem .75rem;
    background: #fdf8f0;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid #f0e8d8;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fdfaf5; }

.actions-row {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Misc ────────────────────────────────────────────────────── */

.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
