:root {
    --bg: #f4f1ec;
    --surface: #fffdf8;
    --ink: #17201b;
    --muted: #667068;
    --line: #ddd7cd;
    --accent: #176d4a;
    --accent-dark: #0d4d35;
    --danger: #b23b3b;
    --warning: #9b651c;
    --shadow: 0 18px 55px rgba(23, 32, 27, .11);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    background: #17201b;
    color: white;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand span,
.profile-pill span,
.avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: 900;
}

.brand small,
.profile-pill small,
td small,
.list-item small {
    display: block;
    color: var(--muted);
}

.brand small { color: rgba(255,255,255,.58); }

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

.sidebar nav a,
.logout {
    color: rgba(255,255,255,.75);
    padding: 12px 13px;
    border-radius: 8px;
    font-weight: 750;
}

.chat-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.nav-badge {
    min-width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #d94d3f;
    color: white;
    font-size: 12px;
    font-weight: 900;
}

.nav-badge.hidden {
    display: none;
}

.sidebar nav a:hover,
.logout:hover {
    color: white;
    background: rgba(255,255,255,.1);
}

.logout { margin-top: auto; }

.main {
    margin-left: 270px;
    padding: 28px;
    min-height: 100vh;
}

.main-login {
    margin-left: 0;
    padding: 0;
}

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

.topbar h1 {
    margin: 4px 0 0;
    font-size: 34px;
}

.muted { color: var(--muted); margin: 0; }
.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 850;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 1fr) 430px;
    align-items: center;
    gap: 40px;
    padding: 48px;
    color: white;
    background:
        linear-gradient(90deg, rgba(23,32,27,.90), rgba(23,32,27,.30)),
        url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=80") center / cover;
}

.login-hero h1 {
    margin: 0;
    font-size: clamp(64px, 10vw, 132px);
    line-height: .9;
}

.login-hero p {
    max-width: 620px;
    color: rgba(255,255,255,.82);
    font-size: 20px;
}

.login-highlights,
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.login-highlights span,
.tag-list span {
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
    padding: 8px 12px;
}

.login-card,
.form-panel,
.panel,
.table-shell,
.document-main,
.document-side,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-card,
.form-panel,
.empty-state {
    padding: 28px;
    display: grid;
    gap: 16px;
    color: var(--ink);
}

.login-card h2,
.panel h2,
.section-head h2,
.document-main h2 {
    margin: 0;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 760;
    font-size: 13px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    padding: 11px 12px;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23,109,74,.13);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check input { width: auto; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    border-radius: 8px;
    padding: 10px 13px;
    font-weight: 850;
}

.btn.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.btn.primary:hover { background: var(--accent-dark); }
.btn.small { padding: 7px 10px; font-size: 13px; }

.demo-box {
    display: grid;
    gap: 4px;
    padding: 14px;
    background: #f6f2e9;
    border-radius: 8px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metrics article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metrics span {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 850;
}

.metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 38px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 20px;
}

.panel {
    padding: 18px;
}

.panel.large { grid-row: span 2; }

.section-head,
.toolbar,
.actions,
.inline-form,
.approval-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-head {
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-head a { color: var(--accent); font-weight: 850; }

.stack {
    display: grid;
    gap: 10px;
}

.list-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.list-item p { color: var(--muted); margin: 5px 0; }

.toolbar {
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar input { flex: 1; min-width: 260px; }

.table-shell {
    overflow-x: auto;
}

.table-shell.compact {
    box-shadow: none;
}

table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
}

.status {
    display: inline-flex;
    border-radius: 999px;
    padding: 6px 10px;
    background: #e8f0e9;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 850;
}

.hash {
    display: block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.form-grid,
.detail-grid,
.settings-grid,
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.file-drop {
    padding: 18px;
    border: 1px dashed #a8a094;
    border-radius: 8px;
    background: #fbf7ee;
}

.file-drop::after {
    content: attr(data-file);
    color: var(--accent);
}

.document-detail {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) 380px;
    gap: 20px;
}

.document-main,
.document-side {
    padding: 22px;
}

.detail-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.detail-grid .wide {
    grid-column: 1 / -1;
}

.detail-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.actions,
.approval-box {
    flex-wrap: wrap;
    margin-top: 18px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline article {
    border-left: 3px solid var(--accent);
    background: #f7f3eb;
    padding: 12px;
    border-radius: 0 8px 8px 0;
}

.employee-grid,
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.employee-card,
.news-item,
.admin-tile,
.calendar-list article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.employee-card {
    display: grid;
    gap: 12px;
}

.employee-card h3,
.news-item h2,
.calendar-list h3 {
    margin: 0;
}

.employee-card p,
.news-item p,
.calendar-list p {
    color: var(--muted);
}

.employee-card dl {
    margin: 0;
    display: grid;
    gap: 4px;
}

.employee-card dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.employee-card dd {
    margin: 0;
}

.news-item span {
    color: var(--accent);
    font-weight: 850;
    text-transform: uppercase;
    font-size: 12px;
}

.calendar-list {
    display: grid;
    gap: 12px;
}

.calendar-list article {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 16px;
    align-items: center;
}

.calendar-list time {
    display: grid;
    place-items: center;
    height: 70px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: 900;
}

.admin-tile {
    display: grid;
    gap: 8px;
}

.admin-tile:hover {
    border-color: var(--accent);
}

.settings-grid .wide {
    grid-column: 1 / -1;
}

.chat-shell {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px;
    height: calc(100vh - 138px);
    min-height: 620px;
}

.chat-sidebar,
.chat-main {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-height: 0;
}

.chat-sidebar {
    padding: 16px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
}

.chat-conversations {
    overflow: auto;
    display: grid;
    gap: 8px;
    align-content: start;
}

.chat-conversation {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.chat-conversation.active,
.chat-conversation:hover {
    border-color: var(--accent);
    background: #eef7f1;
}

.chat-create {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.chat-create h3 {
    margin: 0;
}

.chat-main {
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.chat-header h2 {
    margin: 0;
}

.presence-list {
    display: flex;
    gap: 6px;
}

.presence-list span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    font-weight: 900;
    font-size: 12px;
}

.messages {
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #faf7f1;
}

.message {
    max-width: 74%;
    align-self: flex-start;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.message.mine {
    align-self: flex-end;
    background: #e6f3ec;
    border-color: #c1decf;
}

.message p {
    margin: 5px 0;
    color: var(--ink);
}

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

.shared-doc {
    display: inline-flex;
    margin: 6px 0;
    color: var(--accent);
    font-weight: 850;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.attachment-list a {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--accent-dark);
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 800;
}

.chat-input {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.chat-input input {
    flex: 1;
}

.chat-file-input {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 10px;
    padding: 0 14px 14px;
    background: var(--surface);
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.report-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.report-row strong {
    color: var(--accent);
}

.tag-list span {
    border-color: var(--line);
    background: white;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 800;
}

.alert.success { background: #dff0e7; color: var(--accent-dark); }
.alert.error, .validation { color: var(--danger); }

.live-toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: min(360px, calc(100vw - 44px));
    background: var(--ink);
    color: white;
    border-radius: 8px;
    padding: 14px;
    box-shadow: var(--shadow);
    transform: translateY(24px);
    opacity: 0;
    pointer-events: none;
    transition: 180ms ease;
    z-index: 50;
}

.live-toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.live-toast p {
    margin: 6px 0 10px;
    color: rgba(255,255,255,.76);
}

.live-toast a {
    color: #9ff2c9;
    font-weight: 850;
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: auto;
    }

    .main {
        margin-left: 0;
        padding: 20px;
    }

    .login-page,
    .workspace-grid,
    .document-detail,
    .chat-shell,
    .report-grid,
    .metrics,
    .form-grid,
    .detail-grid,
    .settings-grid,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .login-page {
        padding: 24px;
    }

    .topbar,
    .section-head,
    .inline-form,
    .approval-box,
    .chat-file-input {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-file-input {
        grid-template-columns: 1fr;
    }
}
