:root {
    --page: #ffffff;
    --panel: #f6f7f6;
    --surface: #ffffff;
    --border: #e6e9e7;
    --text: #0d1512;
    --muted: #7d8783;
    --primary: #14532d;
    --primary-dark: #0f3d26;
    --primary-mid: #1f7a4c;
    --primary-soft: #e8f4ec;
    --primary-line: #bfdfcb;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --danger-line: #f3c9c4;
    --amber: #9a6a10;
    --amber-soft: #fdf5df;
    --amber-line: #f0dfae;
    --gradient: linear-gradient(135deg, #0f3d26 0%, #17613a 55%, #25875a 100%);
    --radius-panel: 22px;
    --radius-card: 18px;
    --radius-field: 12px;
    --gap: 14px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font: 15px/1.5 "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-mid);
}

h1,
h2 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
    font-size: 18px;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

:focus-visible {
    outline: 2px solid var(--primary-mid);
    outline-offset: 2px;
}

/* Shell */

.admin {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: var(--gap);
    min-height: 100vh;
    padding: var(--gap);
}

.sidebar {
    position: sticky;
    top: var(--gap);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2 * var(--gap));
    padding: 22px 0 10px;
    background: var(--panel);
    border-radius: var(--radius-panel);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 22px 14px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    place-items: center;
    color: #fff;
    background: var(--gradient);
    border-radius: 50%;
}

.brand-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar nav {
    position: relative;
    flex: 1;
    min-height: 0;
    padding-bottom: 8px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d5dad7 transparent;
}

.nav-group {
    display: block;
    padding: 18px 24px 6px;
    font-size: 11.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 24px;
    font: inherit;
    text-align: left;
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 0.15s;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link.active {
    font-weight: 600;
    color: var(--text);
}

.nav-link.active .icon {
    color: var(--primary-mid);
}

.nav-link.active::before {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: 5px;
    content: "";
    background: var(--gradient);
    border-radius: 0 6px 6px 0;
}

.main {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--panel);
    border-radius: var(--radius-panel);
}

.menu-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 340px;
    padding: 0 12px 0 16px;
    color: var(--muted);
    background: var(--surface);
    border-radius: 999px;
}

.menu-search:focus-within {
    box-shadow: 0 0 0 2px var(--primary-line);
}

.menu-search input {
    flex: 1;
    min-width: 0;
    padding: 12px 0;
    font: inherit;
    color: var(--text);
    background: none;
    border: 0;
    outline: 0;
}

kbd {
    padding: 2px 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--muted);
    background: var(--panel);
    border-radius: 6px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 0;
    place-items: center;
    color: var(--text);
    background: var(--surface);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.icon-button:hover {
    color: #fff;
    background: var(--primary);
}

.sidebar-toggle {
    display: none;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-left: 4px;
}

.avatar {
    display: grid;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    place-items: center;
    font-weight: 600;
    color: var(--primary);
    background: #d5ecdc;
    border-radius: 50%;
}

.avatar-tone-1 {
    color: #7a4b12;
    background: #fbe7c6;
}

.avatar-tone-2 {
    color: #3b3f8f;
    background: #dfe1fb;
}

.avatar-tone-3 {
    color: #8a2f3d;
    background: #fbdde2;
}

.user-meta {
    display: grid;
    min-width: 0;
    line-height: 1.25;
}

.user-meta strong {
    font-weight: 500;
}

.user-meta small {
    font-size: 12.5px;
    color: var(--muted);
}

.user-meta strong,
.user-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 22px 24px 28px;
    overflow-x: auto;
    background: var(--panel);
    border-radius: var(--radius-panel);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
}

.page-title {
    min-width: 0;
}

.page-header h1 {
    margin: 0;
    font-size: 34px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.page-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* Buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    font: inherit;
    font-weight: 500;
    line-height: 1.3;
    color: #fff;
    text-decoration: none;
    background: var(--gradient);
    border: 1.5px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: filter 0.15s, background 0.15s, color 0.15s;
}

.button:hover {
    filter: brightness(1.12);
}

.button .icon {
    width: 18px;
    height: 18px;
}

.button-outline {
    color: var(--primary);
    background: transparent;
    border-color: var(--primary);
}

.button-outline:hover {
    color: #fff;
    background: var(--primary);
    filter: none;
}

.button-light {
    color: var(--primary-dark);
    background: #fff;
}

.link {
    padding: 0;
    font: inherit;
    color: var(--primary-mid);
    background: none;
    border: 0;
    cursor: pointer;
}

td.actions a,
td.actions .link,
.page-actions .link,
h2 > a,
.chip-link {
    display: inline-block;
    padding: 4px 13px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--primary);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--primary-line);
    border-radius: 999px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

td.actions a:hover,
td.actions .link:hover,
.page-actions .link:hover,
h2 > a:hover,
.chip-link:hover {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.danger,
td.actions .link.danger,
.page-actions .link.danger {
    color: var(--danger);
    border-color: var(--danger-line);
}

td.actions .link.danger:hover,
.page-actions .link.danger:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.page-actions .link {
    padding: 10px 20px;
    font-size: inherit;
}

.inline {
    display: inline;
}

/* Cards */

.card {
    padding: 20px;
    background: var(--surface);
    border-radius: var(--radius-card);
}

.card + .card,
.card + h2,
.stats + h2,
nav + h2 {
    margin-top: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.card-header h2 {
    margin: 0;
}

.alert {
    margin: 0 0 16px;
    padding: 12px 16px;
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    border-radius: 14px;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: var(--danger-line);
}

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

/* Stat tiles */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--gap);
    margin-bottom: var(--gap);
}

.stat {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 148px;
    padding: 18px 20px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border-radius: var(--radius-card);
}

a.stat {
    transition: transform 0.15s, box-shadow 0.15s;
}

a.stat:hover {
    box-shadow: 0 10px 24px rgba(15, 61, 38, 0.1);
    transform: translateY(-2px);
}

.stat-label {
    padding-right: 44px;
    font-size: 16.5px;
    font-weight: 500;
}

.stat-arrow {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--text);
    border-radius: 50%;
}

.stat-value {
    margin-top: auto;
    font-size: 50px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.stat-note {
    font-size: 12.5px;
    color: var(--primary-mid);
}

.stat-primary {
    color: #fff;
    background: var(--gradient);
}

.stat-primary .stat-arrow {
    color: var(--primary-dark);
    background: #fff;
    border-color: #fff;
}

.stat-primary .stat-note {
    color: #c5ecd2;
}

/* Dashboard */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

.dashboard-side {
    display: grid;
    gap: var(--gap);
}

.dashboard-side .card + .card {
    margin-top: 0;
}

.entries {
    margin: 0;
    padding: 0;
    list-style: none;
}

.entries li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
}

.entries li + li {
    border-top: 1px solid var(--border);
}

.entries-compact li {
    padding: 9px 0;
}

.entries-compact li + li {
    border-top: 0;
}

.entry-main {
    display: grid;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
    color: var(--text);
    text-decoration: none;
}

.entry-main strong {
    font-weight: 500;
}

.unread .entry-main strong {
    font-weight: 600;
}

.entry-main small {
    font-size: 12.5px;
    color: var(--muted);
}

.entry-main strong,
.entry-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-main:hover strong {
    color: var(--primary-mid);
}

.tile {
    display: grid;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 12px;
}

.tile-tone-1 {
    color: #3b3f8f;
    background: #e6e8fc;
}

.tile-tone-2 {
    color: #7a4b12;
    background: #fcefd6;
}

.tile-tone-3 {
    color: #8a2f3d;
    background: #fce5e9;
}

.feature-card {
    padding: 22px 20px;
    color: #fff;
    background:
        repeating-radial-gradient(circle at 105% 115%, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 13px),
        linear-gradient(150deg, #0b2e1c 0%, #14532d 60%, #1f7a4c 100%);
    border-radius: var(--radius-card);
}

.feature-card h2 {
    margin: 0;
    font-weight: 500;
}

.feature-card p {
    margin: 4px 0 18px;
    font-size: 22px;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

/* Status chips */

.chip,
.status-sent,
.status-failed,
.status-pending {
    display: inline-block;
    padding: 1px 9px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 7px;
}

.chip-green,
.status-sent {
    color: #17613a;
    background: var(--primary-soft);
    border-color: var(--primary-line);
}

.status-failed {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: var(--danger-line);
}

.chip-amber,
.status-pending {
    color: var(--amber);
    background: var(--amber-soft);
    border-color: var(--amber-line);
}

/* Tables */

table {
    width: 100%;
    border-spacing: 0;
    border-collapse: separate;
    background: var(--surface);
}

table.card {
    padding: 6px 10px;
}

th,
td {
    padding: 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
    border-bottom: 0;
}

th {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

td.actions {
    white-space: nowrap;
    text-align: right;
}

td.actions > * + * {
    margin-left: 6px;
}

td.sms-text {
    max-width: 420px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.thumb {
    display: block;
    width: 68px;
    height: 46px;
    object-fit: cover;
    background: var(--panel);
    border-radius: 10px;
}

.unread td {
    font-weight: 600;
}

/* Forms */

.form {
    max-width: 780px;
    padding: 24px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.field input:not([type="checkbox"]),
.field select,
.field textarea,
.search input,
.search select {
    width: 100%;
    padding: 11px 14px;
    font: inherit;
    color: var(--text);
    background: #fbfcfb;
    border: 1px solid var(--border);
    border-radius: var(--radius-field);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:not([type="checkbox"]):focus,
.field select:focus,
.field textarea:focus,
.search input:focus,
.search select:focus {
    background: #fff;
    border-color: var(--primary-mid);
    outline: 0;
    box-shadow: 0 0 0 4px rgba(31, 122, 76, 0.13);
}

.field textarea {
    resize: vertical;
}

.field input[type="file"] {
    padding: 8px;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 6px 14px;
    font: inherit;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-soft);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0 6px 0 0;
    vertical-align: -3px;
    accent-color: var(--primary);
}

.field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.field .checkbox {
    font-weight: 400;
}

.preview {
    display: block;
    max-width: 220px;
    max-height: 140px;
    margin-bottom: 8px;
    border-radius: var(--radius-field);
}

.current-file {
    display: inline-block;
    margin-bottom: 8px;
}

fieldset {
    min-width: 0;
    margin: 0 0 20px;
    padding: 18px 18px 2px;
    border: 1px solid var(--border);
    border-radius: 16px;
}

legend {
    padding: 0 8px;
    font-weight: 600;
}

.error {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--danger);
}

.form-actions {
    margin-top: 4px;
}

.search {
    display: flex;
    gap: 8px;
    max-width: 600px;
    margin-bottom: 16px;
}

.search input,
.search select {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border-color: transparent;
    border-radius: 999px;
}

.search input {
    padding-left: 18px;
}

.message {
    white-space: pre-wrap;
}

/* Pagination */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.pagination .page-link {
    display: grid;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    place-items: center;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border-radius: 999px;
}

.pagination a.page-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.pagination .active .page-link {
    color: #fff;
    background: var(--gradient);
}

.pagination .disabled .page-link {
    color: #b4bcb8;
}

/* Login */

.guest {
    display: grid;
    min-height: 100vh;
    padding: 20px;
    place-items: center;
    background: var(--panel);
}

.login {
    width: 100%;
    max-width: 400px;
    padding: 32px 30px;
    border-radius: var(--radius-panel);
    box-shadow: 0 24px 60px rgba(15, 61, 38, 0.08);
}

.login .brand-mark {
    width: 46px;
    height: 46px;
    margin-bottom: 16px;
}

.login h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.login-intro {
    margin: 4px 0 22px;
    color: var(--muted);
}

.login .checkbox {
    display: block;
    margin-bottom: 20px;
}

.login .button {
    width: 100%;
}

/* Small screens */

.sidebar-backdrop {
    display: none;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .admin {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 30;
        width: min(290px, 86vw);
        height: auto;
        border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform 0.2s, visibility 0.2s;
    }

    .sidebar-open .sidebar {
        visibility: visible;
        transform: none;
    }

    .sidebar-open .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 20;
        display: block;
        background: rgba(13, 21, 18, 0.4);
    }

    .sidebar-toggle {
        display: grid;
    }

    .menu-search,
    .user-meta {
        display: none;
    }

    .content {
        padding: 18px 16px 22px;
    }

    .page-header h1 {
        font-size: 27px;
    }

    .stat-value {
        font-size: 42px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
