*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --gruen:      #1a6b4a;
    --gruen-hell: #e8f5ef;
    --gruen-rand: #b2d9c5;
    --text:       #1c2826;
    --text-soft:  #4a5e58;
    --border:     #d0ddd9;
    --bg:         #f7faf9;
    --white:      #ffffff;
    --radius:     12px;
    --shadow:     0 2px 16px rgba(26,107,74,0.10);
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(26,107,74,0.10), transparent 24%),
        linear-gradient(180deg, #f9fcfb 0%, var(--bg) 100%);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2 {
    font-weight: 700;
}

.soft {
    color: var(--text-soft);
}

.small-text {
    font-size: 13px;
}

.login-body,
.admin-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
}

.login-card,
.admin-shell,
.card,
.chat-panel,
.sidebar,
.user-row,
.bubble,
.empty-box,
.empty-state,
.group-admin-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 28px;
    display: grid;
    gap: 18px;
}

.brand-badge,
.channel-pill {
    display: inline-block;
    background: var(--gruen-hell);
    color: var(--gruen);
    border: 1px solid var(--gruen-rand);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
}

.channel-pill {
    margin-bottom: 10px;
}

.stack,
.compact-stack {
    display: grid;
    gap: 14px;
}

.compact-stack {
    gap: 10px;
}

label span,
.label-title {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text-soft);
}

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    font: inherit;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--gruen);
    box-shadow: 0 0 0 3px rgba(26,107,74,0.12);
}

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

.btn,
.emoji-btn,
.upload-btn span {
    border: 1px solid var(--gruen-rand);
    border-radius: 12px;
    padding: 11px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: .18s ease;
    background: var(--white);
    color: var(--gruen);
    box-shadow: 0 8px 18px rgba(26,107,74,0.08);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover,
.emoji-btn:hover,
.upload-btn span:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(26,107,74,0.12);
}

.btn-primary {
    background: linear-gradient(180deg, #1f7a55 0%, var(--gruen) 100%);
    color: #fff;
    border-color: #1f7a55;
}

.btn-secondary {
    background: linear-gradient(180deg, #ffffff 0%, #f4fbf7 100%);
    color: var(--gruen);
}

.btn-ghost {
    background: #fff;
    color: var(--text-soft);
    border-color: var(--border);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid;
}

.alert.success {
    background: var(--gruen-hell);
    color: var(--gruen);
    border-color: var(--gruen-rand);
}

.alert.error {
    background: #fff3f3;
    color: #922b2b;
    border-color: #f1b8b8;
}

.compact-alert {
    padding: 10px 12px;
}

.app-shell {
    display: grid;
    grid-template-columns: 316px minmax(0, 1fr);
    gap: 14px;
    height: 100vh;
    padding: 14px;
    overflow: hidden;
}

.sidebar {
    padding: 14px;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    align-content: start;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.sidebar-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: start;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(208,221,217,0.9);
}

.sidebar-top h1 {
    font-size: 20px;
    line-height: 1.2;
    margin-top: 8px;
}

.sidebar-subtitle {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-soft);
}

.user-chip {
    background: linear-gradient(180deg, #f4fbf7 0%, #e8f5ef 100%);
    border: 1px solid var(--gruen-rand);
    border-radius: 12px;
    padding: 10px 12px;
    display: grid;
    gap: 2px;
    min-width: 120px;
    text-align: right;
    font-size: 12px;
}

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

.sidebar-actions .btn {
    flex: 1 1 120px;
    justify-content: center;
}

.sidebar-scroll {
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    justify-content: flex-start;
}

.sidebar-section-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    align-items: stretch;
    justify-content: flex-start;
    flex: 0 0 auto;
}

.sidebar-section-grow {
    min-height: 0;
    flex: 0 0 auto;
}

.user-list-title {
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
}

.user-list {
    display: grid;
    gap: 6px;
    align-content: start;
    margin: 0;
}

.user-list-static {
    overflow: visible;
}

.user-list-groups {
    padding-bottom: 4px;
}

.user-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 10px;
    padding: 8px 10px;
    align-items: start;
    transition: .18s ease;
    border-color: rgba(208,221,217,0.92);
    margin: 0;
}

.user-row:hover,
.user-row.active {
    border-color: var(--gruen-rand);
    background: linear-gradient(180deg, #f2faf6 0%, var(--gruen-hell) 100%);
    transform: translateY(-1px);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gruen);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
}

.group-avatar {
    background: #2f8a64;
}

.user-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.name-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.user-meta strong {
    font-size: 13px;
    line-height: 1.15;
}

.user-meta .soft {
    font-size: 11px;
}

.sidebar-info {
    color: var(--text-soft);
}

.sidebar-typing {
    font-size: 11px;
    line-height: 1.15;
    color: var(--gruen);
    font-weight: 600;
}

.sidebar-typing.is-hidden {
    display: none;
}

.status-online,
.status-offline {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.status-online {
    color: var(--gruen);
}

.status-offline {
    color: var(--text-soft);
}

.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--gruen);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.chat-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    height: 100%;
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #eef8f3 0%, #ffffff 100%);
}

.chat-header h2 {
    font-size: 28px;
    line-height: 1.2;
}

.channel-subtitle {
    margin-top: 6px;
}

.typing-indicator {
    min-height: 20px;
    margin-top: 8px;
    color: var(--gruen);
    font-size: 13px;
    font-weight: 700;
}

.messages {
    padding: 22px 24px;
    overflow: auto;
    display: grid;
    align-content: start;
    gap: 12px;
    min-height: 0;
    background:
        radial-gradient(circle at top left, rgba(26,107,74,0.06), transparent 28%),
        radial-gradient(circle at bottom right, rgba(26,107,74,0.05), transparent 30%),
        #fbfdfc;
}

.message {
    display: flex;
}

.message.incoming {
    justify-content: flex-start;
}

.message.outgoing {
    justify-content: flex-end;
}

.bubble {
    max-width: min(720px, 82%);
    padding: 12px 14px;
}

.incoming .bubble {
    background: var(--white);
}

.outgoing .bubble {
    background: var(--gruen-hell);
    border-color: var(--gruen-rand);
}

.message-author {
    font-size: 12px;
    color: var(--gruen);
    font-weight: 700;
    margin-bottom: 6px;
}

.message-text {
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-time {
    margin-top: 8px;
    color: var(--text-soft);
    font-size: 12px;
    text-align: right;
}

.attachment-box {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.75);
}

.attachment-link {
    color: var(--gruen);
    font-weight: 700;
    word-break: break-all;
}

.attachment-meta {
    color: var(--text-soft);
    font-size: 12px;
}

.attachment-image-link {
    display: inline-block;
}

.attachment-image {
    max-width: 240px;
    max-height: 180px;
    width: auto;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
}

.composer {
    padding: 18px 20px;
    border-top: 1px solid var(--border);
    background: #fff;
    display: grid;
    gap: 12px;
}

.composer-top,
.composer-bottom {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

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

.emoji-btn {
    padding: 8px 10px;
    line-height: 1;
    background: var(--gruen-hell);
}

.upload-btn {
    display: inline-block;
}

.upload-btn input {
    display: none;
}

.upload-btn span {
    display: inline-block;
    background: var(--white);
}

.selected-file {
    min-height: 18px;
    color: var(--gruen);
    font-size: 13px;
    font-weight: 700;
}

.empty-box,
.empty-state {
    padding: 10px 12px;
}

.empty-state {
    margin: auto;
    text-align: center;
    display: grid;
    gap: 10px;
    max-width: 420px;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.admin-shell {
    width: min(1220px, 100%);
    padding: 24px;
    display: grid;
    gap: 18px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: start;
}

.card {
    padding: 20px;
    display: grid;
    gap: 16px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--text-soft);
    font-size: 13px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.check-item span {
    margin: 0;
    color: var(--text);
}

.group-admin-list {
    display: grid;
    gap: 14px;
}

.group-admin-card {
    padding: 16px;
    display: grid;
    gap: 14px;
}

.group-admin-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.login-footer {
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 980px) {
    body {
        overflow: auto;
    }

    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .sidebar,
    .chat-panel {
        height: auto;
    }

    .sidebar {
        overflow: visible;
    }

    .sidebar-scroll {
        overflow: visible;
        padding-right: 0;
    }

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

@media (max-width: 720px) {
    .login-body,
    .admin-body {
        padding: 14px;
    }

    .app-shell {
        padding: 12px;
        gap: 12px;
    }

    .sidebar,
    .chat-panel,
    .card,
    .admin-shell {
        padding: 14px;
    }

    .sidebar-top {
        flex-direction: column;
    }

    .user-chip {
        width: 100%;
        text-align: left;
    }

    .sidebar-actions .btn {
        flex: 1 1 auto;
    }

    .chat-header,
    .messages,
    .composer {
        padding: 14px;
    }

    .chat-header h2 {
        font-size: 22px;
    }

    .attachment-image {
        max-width: 100%;
        max-height: 220px;
    }
}

#notify-enable { position: relative; z-index: 2; }
.btn:disabled { opacity: .75; cursor: default; }

#notify-enable[hidden] { display: none !important; }


.sidebar-scroll::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
    background: #c9ddd4;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-scroll::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
    background: transparent;
}


.quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.quick-replies-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.quick-replies-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-reply-btn {
    border: 1px solid var(--gruen-rand);
    background: var(--gruen-hell);
    color: var(--gruen);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.quick-reply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26,107,74,0.10);
    background: #f0faf5;
}

.quick-reply-btn:active {
    transform: translateY(0);
}

.admin-textarea {
    min-height: 160px;
    resize: vertical;
}
