* { box-sizing: border-box; }
html, body {
    height: 100%;
}
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #efeae2;
    color: #202124;
    overflow: hidden;
}
a { text-decoration: none; color: inherit; }
button, input, textarea, select { font: inherit; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f0fe, #f8f9fa);
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 10px 35px rgba(60,64,67,.15);
    padding: 32px;
}
.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1a73e8;
    color: #fff;
    font-weight: bold;
    margin-bottom: 12px;
}
.login-card h1 { margin: 0 0 6px; font-size: 30px; }
.login-card p { margin: 0 0 24px; color: #5f6368; }
.login-form { display: grid; gap: 10px; }
.login-form input, .login-form button, .stack-form input, .stack-form button, .stack-form select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid #dadce0;
    padding: 14px;
    background: #fff;
}
.login-form button, .stack-form button, #send-btn, .ghost-btn {
    border: 0;
    background: #1a73e8;
    color: #fff;
    cursor: pointer;
    transition: .2s ease;
}
.login-form button:hover, .stack-form button:hover, #send-btn:hover, .ghost-btn:hover {
    transform: translateY(-1px);
}
.login-help { margin-top: 18px; font-size: 14px; color: #5f6368; }
.alert { margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; }
.alert.error { background: #fce8e6; color: #a50e0e; }
.alert.info { background: #e8f0fe; color: #174ea6; }

.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    width: 100%;
}
.sidebar {
    background: #ffffff;
    border-right: 1px solid #dadce0;
}
.sidebar-fixed {
    position: relative;
    height: 100vh;
    overflow: hidden;
}
.sidebar-inner {
    height: 100vh;
    overflow-y: auto;
    padding: 18px;
}
.sidebar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.brand { font-size: 24px; font-weight: 700; }
.sub-brand { color: #5f6368; margin-top: 2px; font-size: 14px; }
.global-badge, .badge {
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #d93025;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
    font-weight: bold;
}
.sidebar-section { margin-top: 22px; }
.section-title {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5f6368;
    margin-bottom: 10px;
}
.sidebar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ghost-btn {
    display: inline-flex;
    padding: 10px 14px;
    border-radius: 12px;
    background: #1a73e8;
}
.search-input {
    width: 100%;
    border: 1px solid #dadce0;
    border-radius: 14px;
    padding: 12px 14px;
}
.conversation-list {
    display: grid;
    gap: 8px;
}
.conversation-item {
    width: 100%;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #edf0f2;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}
.conversation-item:hover, .conversation-item.active {
    background: #e8f0fe;
    border-color: #c2dbff;
}
.conversation-item .label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-chat {
    min-width: 0;
    background: #efeae2;
    background-image:
      radial-gradient(rgba(255,255,255,.25) 1px, transparent 1px),
      radial-gradient(rgba(255,255,255,.15) 1px, transparent 1px);
    background-size: 24px 24px, 24px 24px;
    background-position: 0 0, 12px 12px;
}
.main-chat-fixed {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    overflow: hidden;
}
.chat-header {
    padding: 18px 22px;
    background: #f0f2f5;
    border-bottom: 1px solid #dadce0;
}
.chat-header-fixed {
    position: relative;
    z-index: 2;
}
.chat-header h2 {
    margin: 0;
    font-size: 24px;
}
.chat-subtitle {
    margin-top: 4px;
    color: #5f6368;
    font-size: 14px;
}

.messages-area {
    padding: 22px;
}
.messages-area-fixed {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scroll-behavior: smooth;
}
.empty-state {
    max-width: 520px;
    margin: 80px auto;
    text-align: center;
    color: #5f6368;
}
.empty-state-title {
    font-size: 24px;
    font-weight: 700;
    color: #202124;
    margin-bottom: 8px;
}

.msg {
    max-width: 72%;
    background: #ffffff;
    border-radius: 8px 8px 8px 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    padding: 8px 10px 6px;
    margin-bottom: 10px;
    position: relative;
    word-wrap: break-word;
}
.msg.mine {
    margin-left: auto;
    background: #d9fdd3;
    border-radius: 8px 8px 2px 8px;
}
.msg-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #667781;
    margin-bottom: 6px;
}
.msg-body {
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 14px;
}
.msg-file {
    margin-top: 8px;
}
.msg-file a {
    color: #0b57d0;
    font-weight: 600;
}
.msg-image {
    max-width: 280px;
    border-radius: 10px;
    display: block;
}
.msg-status {
    margin-top: 6px;
    text-align: right;
    font-size: 11px;
    color: #667781;
}

.composer {
    gap: 10px;
    align-items: end;
    padding: 12px 16px;
    background: #f0f2f5;
    border-top: 1px solid #dadce0;
}
.composer-fixed {
    display: grid;
    grid-template-columns: 1fr 220px 110px;
    position: relative;
    z-index: 2;
}
.composer-input-wrap textarea {
    width: 100%;
    min-height: 52px;
    max-height: 140px;
    resize: vertical;
    border: 1px solid #dadce0;
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}
.composer-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #5f6368;
}
#file {
    border: 1px solid #dadce0;
    border-radius: 14px;
    padding: 12px;
    background: #fff;
}
#send-btn {
    padding: 14px 16px;
    border-radius: 14px;
}

.admin-page { background: #f1f3f4; overflow: auto; }
.admin-wrap { padding: 24px; }
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.bottom-grid { margin-top: 18px; }
.admin-card {
    background: #fff;
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(60,64,67,.16);
}
.admin-card h2 { margin-top: 0; }
.stack-form { display: grid; gap: 12px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid #eceff1;
    font-size: 14px;
}

.sidebar-inner::-webkit-scrollbar,
.messages-area-fixed::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.sidebar-inner::-webkit-scrollbar-thumb,
.messages-area-fixed::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.18);
    border-radius: 999px;
}
.sidebar-inner::-webkit-scrollbar-track,
.messages-area-fixed::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

@media (max-width: 1024px) {
    .app-layout { grid-template-columns: 280px 1fr; }
    .composer-fixed { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    body { overflow: auto; }
    .app-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }
    .sidebar-fixed,
    .sidebar-inner,
    .main-chat-fixed {
        height: auto;
    }
    .sidebar-fixed { overflow: visible; }
    .sidebar-inner { overflow: visible; }
    .main-chat-fixed {
        grid-template-rows: auto minmax(320px, 1fr) auto;
    }
    .messages-area-fixed {
        min-height: 320px;
    }
    .admin-grid { grid-template-columns: 1fr; }
    .msg { max-width: 90%; }
}
