:root {
    --ink: #18352b;
    --muted: #6d7d76;
    --green: #166b4f;
    --green-dark: #0e4d39;
    --lime: #c7e76d;
    --cream: #f5f4ed;
    --paper: #fffef9;
    --line: #dde4df;
    --danger: #b43d3d;
    --shadow: 0 18px 50px rgba(22, 64, 49, .09);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--cream); font-family: "DM Sans", sans-serif; }
a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; overflow-y: auto; background: var(--green-dark); color: white; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; font: 700 17px/1.1 Manrope, sans-serif; }
.brand small { display: block; margin-top: 4px; color: #bcd1c8; font: 500 11px DM Sans, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; border-radius: 13px; color: var(--green-dark); background: var(--lime); font-weight: 800; }
.sidebar nav { display: grid; gap: 8px; margin-top: 52px; }
.sidebar nav a { display: flex; gap: 12px; padding: 12px 14px; border-radius: 11px; color: #c9dbd4; font-weight: 600; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.11); color: white; }
.sidebar nav span { width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 20px; }
.sidebar-footer a { color: #c9dbd4; font-size: 14px; }
.main { min-width: 0; }
.topbar { min-height: 104px; padding: 22px 36px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); background: rgba(255,254,249,.78); backdrop-filter: blur(12px); }
.topbar h1 { margin: 3px 0 0; font: 700 24px Manrope, sans-serif; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-menu strong, .user-menu small { display: block; }
.user-menu small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-weight: 700; }
.avatar.large { width: 48px; height: 48px; }
.link-button { padding: 6px 0 6px 10px; border: 0; background: none; color: var(--green); cursor: pointer; font-weight: 600; }
.menu-button { display: none; border: 0; background: none; color: var(--ink); font-size: 24px; }
.content { max-width: 1440px; padding: 34px 36px 56px; }
.welcome-strip { padding: 28px 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 18px; color: white; background: linear-gradient(120deg, var(--green-dark), var(--green)); box-shadow: var(--shadow); }
.welcome-strip h2 { margin: 5px 0 4px; font: 700 26px Manrope, sans-serif; }
.welcome-strip p { margin: 0; color: #cfe1da; }
.welcome-strip .eyebrow { color: var(--lime); }
.stats-grid { margin: 22px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card { min-height: 150px; padding: 23px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 8px 30px rgba(22,64,49,.04); }
.stat-card.accent { color: white; border-color: var(--green); background: var(--green); }
.stat-card strong { margin: 13px 0 6px; font: 800 34px Manrope, sans-serif; }
.stat-card small, .stat-label { color: var(--muted); }
.stat-card.accent small, .stat-card.accent .stat-label { color: #d8e9e2; }
.stat-label { font-weight: 600; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.panel.compact { padding: 22px; margin-bottom: 18px; }
.panel.compact h3 { margin: 0 0 16px; font: 700 17px Manrope, sans-serif; }
.panel-heading { padding: 23px 25px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 0; font: 700 20px Manrope, sans-serif; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 20px; text-align: left; color: var(--muted); background: #f8f8f3; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td { padding: 16px 20px; border-top: 1px solid var(--line); font-size: 14px; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); }
.unread-row td { background: #fbfff2; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge.new { color: #5a7007; background: #eaf6bd; }
.badge.read { color: #315c83; background: #e1effa; }
.badge.resolved { color: #35705a; background: #daf0e5; }
.row-link { white-space: nowrap; font-weight: 700; }
.empty-state { padding: 68px 24px; text-align: center; color: var(--muted); }
.empty-state span { font-size: 38px; color: var(--green); }
.empty-state h3 { margin: 13px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; }
.filters { padding: 18px 22px; display: flex; align-items: end; gap: 12px; border-bottom: 1px solid var(--line); }
.filters label { min-width: 180px; }
.filters .search-field { flex: 1; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); border: 1px solid #cbd6d0; border-radius: 9px; background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,107,79,.12); }
label small { color: var(--muted); font-weight: 400; }
.button { min-height: 43px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 700; }
.button.primary { color: white; background: var(--green); }
.welcome-strip .button.primary { color: var(--green-dark); background: var(--lime); }
.button.secondary { color: var(--green); border-color: var(--green); background: white; }
.button.ghost { color: var(--ink); border-color: var(--line); background: transparent; }
.button.danger { color: white; background: var(--danger); }
.button.full { width: 100%; }
.alert { margin-bottom: 18px; padding: 13px 16px; border-radius: 10px; font-size: 14px; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert.success { color: #225f49; border: 1px solid #b8dfcf; background: #e5f5ed; }
.alert.error { color: #8d3030; border: 1px solid #ecc0c0; background: #fff0f0; }
.alert.warning { color: #725719; border: 1px solid #ead99e; background: #fff8dd; }
.pagination { padding: 20px; }
.pagination ul { margin: 0; padding: 0; display: flex; gap: 6px; list-style: none; }
.pagination a { min-width: 34px; height: 34px; padding: 0 9px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; }
.pagination .active a { color: white; background: var(--green); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.back-link.top { display: inline-block; margin-bottom: 18px; font-weight: 700; }
.message-card { padding: 30px; }
.message-header { padding-bottom: 22px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.message-header h2 { margin: 12px 0 0; font: 700 25px Manrope, sans-serif; }
.message-header time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.sender { margin: 24px 0; display: flex; align-items: center; gap: 12px; }
.sender strong, .sender a { display: block; }
.sender a { margin-top: 3px; font-size: 13px; }
.message-body { min-height: 160px; margin-bottom: 28px; color: #344b42; font-size: 16px; line-height: 1.75; }
.danger-zone { border-color: #edcccc; box-shadow: none; }
.danger-zone p { color: var(--muted); font-size: 13px; }
.stack-form { display: grid; gap: 17px; }
.account-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 20px; }
.account-grid .panel { padding-bottom: 25px; }
.account-grid .stack-form { padding: 0 25px; }
.profile-list { margin: 0; padding: 10px 25px; }
.profile-list div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.profile-list dt { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.profile-list dd { margin: 5px 0 0; font-weight: 600; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: var(--paper); }
.login-visual { min-height: 100vh; padding: 70px; display: flex; align-items: end; color: white; background: linear-gradient(180deg, rgba(8,57,41,.1), rgba(8,57,41,.9)), url("https://images.unsplash.com/photo-1488521787991-ed7bbaae773c?auto=format&fit=crop&w=1600&q=85") center/cover; }
.visual-content { max-width: 650px; }
.visual-kicker { color: var(--lime); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; }
.visual-content h1 { margin: 18px 0; font: 800 clamp(42px, 6vw, 78px)/1.02 Manrope, sans-serif; letter-spacing: -.04em; }
.visual-content p { max-width: 580px; color: #d8e7e1; font-size: 18px; line-height: 1.6; }
.login-panel { padding: 45px 7vw; display: grid; place-items: center; }
.login-card { width: min(430px, 100%); }
.login-brand { color: var(--ink); }
.login-heading { margin: 56px 0 28px; }
.login-heading h2 { margin: 8px 0 4px; font: 800 34px Manrope, sans-serif; }
.login-heading p { margin: 0; color: var(--muted); }
.back-link { display: inline-block; margin-top: 24px; font-size: 13px; font-weight: 600; }
.page-card-grid { margin-top: 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.page-card { padding: 25px; display: flex; flex-direction: column; gap: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.page-card-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; color: var(--green-dark); background: var(--lime); font: 800 21px Manrope, sans-serif; }
.page-card h2 { margin: 12px 0 4px; font: 700 21px Manrope, sans-serif; }
.page-card p { margin: 0; color: var(--muted); }
.editor-toolbar { position: sticky; top: 0; z-index: 8; margin-bottom: 20px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,254,249,.94); box-shadow: 0 8px 30px rgba(22,64,49,.08); backdrop-filter: blur(10px); }
.editor-toolbar > div { display: flex; align-items: center; gap: 14px; }
.editor-toolbar p { margin: 0; color: var(--muted); }
.back-link-inline { font-weight: 700; }
.publish-toggle { display: flex; align-items: center; gap: 8px; }
.publish-toggle input { width: 18px; min-height: 18px; }
.editor-section { margin-bottom: 20px; overflow: visible; }
.editor-fields { padding: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.editor-fields > label:has(textarea), .editor-fields .image-field { grid-column: 1 / -1; }
.editor-fields textarea { resize: vertical; line-height: 1.55; }
.image-field { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 16px; align-items: end; border: 1px dashed #becdc5; border-radius: 12px; background: #fafbf7; }
.image-field > label:first-child { align-self: start; }
.image-field img { width: 170px; height: 110px; grid-row: 1 / span 2; grid-column: 2; object-fit: cover; border-radius: 9px; background: #e8ece8; }
.upload-control { padding: 11px; border-radius: 9px; background: white; }
.editor-actions { padding: 8px 0 20px; display: flex; justify-content: flex-end; gap: 10px; }
.upload-panel { margin-bottom: 22px; padding: 24px; display: grid; grid-template-columns: .8fr 1.2fr; gap: 35px; align-items: center; }
.upload-panel h2 { margin: 5px 0; }
.upload-panel p { margin: 0; color: var(--muted); }
.upload-panel form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 8px 24px rgba(22,64,49,.05); }
.media-card > img { width: 100%; height: 170px; display: block; object-fit: cover; background: #e6ebe7; }
.media-card > div { padding: 14px; }
.media-card strong, .media-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card small { margin: 4px 0 10px; color: var(--muted); }
.media-card input { min-height: 36px; font-size: 11px; }
.media-card form { text-align: right; }
.danger-text { color: var(--danger); }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .user-menu div { display: none; }
    .media-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: -280px; width: 260px; transition: left .2s ease; }
    .menu-open .sidebar { left: 0; }
    .menu-button { display: block; }
    .topbar { padding: 18px 20px; }
    .content { padding: 24px 20px 42px; }
    .detail-grid, .account-grid { grid-template-columns: 1fr; }
    .page-card-grid { grid-template-columns: 1fr; }
    .editor-fields { grid-template-columns: 1fr; }
    .editor-fields > * { grid-column: 1 !important; }
    .upload-panel, .upload-panel form { grid-template-columns: 1fr; }
    .media-grid { grid-template-columns: repeat(2, 1fr); }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .login-panel { min-height: 100vh; padding: 32px 24px; }
}
@media (max-width: 580px) {
    .stats-grid { grid-template-columns: 1fr; }
    .welcome-strip { align-items: flex-start; flex-direction: column; }
    .filters { align-items: stretch; flex-direction: column; }
    .filters label { width: 100%; }
    .user-menu .avatar { display: none; }
    .topbar h1 { font-size: 20px; }
    .message-header { flex-direction: column; }
    .editor-toolbar { position: static; align-items: stretch; flex-direction: column; }
    .editor-toolbar > div { justify-content: space-between; }
    .image-field { grid-template-columns: 1fr; }
    .image-field img { width: 100%; height: 180px; grid-row: auto; grid-column: auto; }
    .media-grid { grid-template-columns: 1fr; }
}
