:root {
    --navy: #14213d;
    --blue: #1d4ed8;
    --sky: #e0f2fe;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #d8dee9;
    --bg: #f3f6fb;
    --white: #ffffff;
    --green: #047857;
    --red: #b91c1c;
    --amber: #b45309;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

a {
    color: var(--blue);
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--navy);
    color: var(--white);
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: grid;
    gap: 3px;
    font-size: 22px;
}

.brand span,
.user-badge small,
.topbar p,
.muted {
    color: var(--muted);
}

.sidebar .brand span {
    color: #b8c7e0;
    font-size: 14px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar a {
    color: #e5edf8;
    padding: 11px 12px;
    border-radius: 8px;
}

.sidebar a.active,
.sidebar a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.logout {
    margin-top: auto;
}

.main {
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 20px;
}

.topbar h1 {
    margin: 0 0 5px;
    font-size: 28px;
}

.topbar p {
    margin: 0;
}

.user-badge {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    display: grid;
    gap: 2px;
    min-width: 150px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.stat {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stat strong {
    display: block;
    font-size: 30px;
    margin-top: 8px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.period-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 14px;
}

.period-panel h2 {
    margin: 8px 0 5px;
    font-size: 26px;
}

.period-actions,
.quick-links,
.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.inline-form input[type="month"] {
    min-width: 150px;
}

.period-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.period-strip a {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 11px;
    background: var(--white);
    color: var(--ink);
    font-size: 13px;
}

.period-strip a.active {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.quick-links {
    margin-bottom: 16px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button,
.button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--blue);
    color: var(--white);
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

.button.secondary,
button.secondary {
    background: #475569;
}

.button.danger,
button.danger {
    background: var(--red);
}

.button.ghost,
button.ghost {
    color: var(--ink);
    background: var(--sky);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

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

th {
    background: #eef4fb;
    color: #334155;
    font-size: 13px;
}

.pill {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    background: #eef2ff;
    color: #3730a3;
    white-space: nowrap;
}

.pill.green {
    background: #d1fae5;
    color: var(--green);
}

.pill.red {
    background: #fee2e2;
    color: var(--red);
}

.pill.amber {
    background: #fef3c7;
    color: var(--amber);
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
}

.alert.error {
    background: #fee2e2;
    border-color: #fecaca;
}

.alert.success {
    background: #dcfce7;
    border-color: #bbf7d0;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-box {
    width: min(420px, 100%);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.conversation {
    display: grid;
    gap: 12px;
}

.preview-box {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #f8fafc;
}

.bubble {
    width: min(680px, 92%);
    padding: 12px 14px;
    border-radius: 8px;
    background: #eef2ff;
}

.bubble.in {
    background: #ecfdf5;
}

.bubble.out {
    margin-left: auto;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .period-panel {
        align-items: flex-start;
        flex-direction: column;
    }
}
