* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #e4eaf2;
  --text: #172033;
  --muted: #718096;
  --primary: #1677ee;
  --primary-soft: #eaf3ff;
  --success: #16a34a;
  --danger: #ef4444;
  --sidebar: #101c2c;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns:
    220px
    290px
    minmax(500px, 1fr)
    350px;
  height: 100vh;
  min-width: 1100px;
  overflow: hidden;
}

/* SIDEBAR */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
  padding: 20px 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 26px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1684f5;
  font-size: 23px;
}

.brand-title {
  font-size: 18px;
  font-weight: 750;
}

.brand-subtitle {
  margin-top: 3px;
  font-size: 11px;
  color: #9eabc0;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 43px;
  padding: 0 12px;
  border-radius: 8px;
  color: #b9c5d5;
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  background: #1677ee;
  color: #fff;
}

.nav-item b {
  margin-left: auto;
  min-width: 21px;
  padding: 2px 6px;
  border-radius: 12px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.system-status {
  margin-top: auto;
  padding: 15px 7px 5px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.status-title {
  margin-bottom: 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.status-row {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  gap: 7px;
  align-items: center;
  margin: 9px 0;
  color: #9eabc0;
  font-size: 10px;
}

.status-row strong {
  color: #22c55e;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
}

/* INBOX */

.inbox-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
}

.account-header h2 {
  margin: 0;
  font-size: 16px;
}

.account-header span {
  color: var(--muted);
  font-size: 11px;
}

.add-button {
  border: 1px solid #cfe1f8;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 6px;
  padding: 7px 10px;
}

.account-list {
  border-bottom: 1px solid var(--border);
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
}

.account-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1684f5;
  color: #fff;
  font-size: 18px;
}

.account-main {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-size: 13px;
  font-weight: 700;
}

.account-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.account-status {
  color: var(--success);
  font-size: 10px;
}

.conversation-toolbar {
  padding: 10px 12px 6px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
}

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

.filter {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11px;
}

.filter.active {
  background: var(--primary);
  color: #fff;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-card {
  display: flex;
  gap: 9px;
  padding: 11px 12px;
  border-bottom: 1px solid #eef2f7;
}

.conversation-card:hover,
.conversation-card.active {
  background: #edf6ff;
}

.conversation-avatar {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dbe7f5;
  color: #42617e;
  font-weight: 700;
}

.conversation-main {
  min-width: 0;
  flex: 1;
}

.conversation-top {
  display: flex;
  justify-content: space-between;
  gap: 5px;
}

.conversation-name {
  font-size: 12px;
  font-weight: 700;
}

.conversation-time {
  color: var(--muted);
  font-size: 9px;
}

.conversation-text {
  margin-top: 4px;
  overflow: hidden;
  color: #4d5b70;
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-ai {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

/* CHAT */

.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f8fafc;
}

.chat-header {
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 9px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.customer-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-right: 10px;
  border-radius: 50%;
  background: #dce8f5;
  color: #54718d;
  font-weight: 700;
}

.chat-customer {
  flex: 1;
  min-width: 0;
}

.customer-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.customer-name-row h2 {
  margin: 0;
  font-size: 16px;
}

.customer-username {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.vip-badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 5px;
  background: #fff1bd;
  color: #a66b00;
  font-size: 9px;
  font-weight: 700;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-actions button {
  border: 0;
  background: transparent;
  color: #506176;
}

.translate-toggle {
  margin-left: 5px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #eaf8ee;
  color: #16803b;
  font-size: 10px;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.empty-chat {
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  margin-bottom: 10px;
  font-size: 36px;
}

.empty-chat h3 {
  margin: 0 0 6px;
  color: var(--text);
}

.empty-chat p {
  max-width: 280px;
  margin: 0;
  font-size: 12px;
}

.message-row {
  margin-bottom: 18px;
}

.message-bubble {
  max-width: 75%;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.message-row.incoming .message-bubble {
  background: #fff;
  border: 1px solid #e7edf4;
}

.message-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.translation-card {
  max-width: 75%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #dce6f2;
  border-radius: 8px;
  background: #f7faff;
}

.translation-label {
  color: #3372ba;
  font-size: 10px;
  font-weight: 700;
}

.translation-text {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.45;
}

.reply-placeholder {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 9px 13px;
}

.composer-tabs {
  display: flex;
  gap: 18px;
}

.composer-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 5px 2px;
  color: #65758b;
  font-size: 11px;
}

.composer-tabs button.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.composer-disabled {
  margin-top: 9px;
  padding: 12px;
  border: 1px dashed #d6deea;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* CUSTOMER PANEL */

.customer-panel {
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid var(--border);
  padding: 17px;
}

.panel-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3,
.section-title h3 {
  margin: 0;
  font-size: 13px;
}

.panel-header button,
.section-title button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
}

.profile-card {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 17px 0;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dce8f5;
  color: #54718d;
  font-size: 18px;
  font-weight: 700;
}

.profile-card h2 {
  margin: 0 0 3px;
  font-size: 15px;
}

.profile-card div:nth-child(2) > div {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 5px;
}

.info-list,
.key-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-list > div,
.key-info > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
}

.info-list span,
.key-info span {
  color: var(--muted);
}

.info-list strong,
.key-info strong {
  text-align: right;
  font-weight: 600;
}

.info-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.summary-empty {
  margin-top: 10px;
  padding: 10px;
  border-radius: 7px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.translation-preview {
  margin-top: 9px;
  padding: 10px;
  border-radius: 7px;
  background: #f0f8ff;
  color: #35485f;
  font-size: 10px;
  line-height: 1.5;
}

.quality-safe {
  margin-top: 7px;
  padding: 8px;
  border-radius: 7px;
  background: #ebf9ef;
  color: #16803b;
  font-size: 10px;
  font-weight: 700;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.action-grid button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #44546a;
  font-size: 10px;
}

.action-grid button.danger {
  color: var(--danger);
  border-color: #fecaca;
}

/* RESPONSIVE */

@media (max-width: 1300px) {
  .app-shell {
    grid-template-columns:
      190px
      260px
      minmax(460px, 1fr)
      300px;
  }
}

/* AUTH LOGIN */

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at top left, #eaf3ff, transparent 38%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(16, 28, 44, .12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.login-brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
}

.login-brand-title {
  font-size: 19px;
  font-weight: 750;
}

.login-brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.login-heading h1 {
  margin: 0 0 8px;
  font-size: 27px;
}

.login-heading p {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.login-form button {
  height: 47px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.login-form button:disabled {
  cursor: wait;
  opacity: .65;
}

.login-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff1f2;
  color: #b42318;
  font-size: 13px;
}

/* OPERATOR SESSION */

.operator-panel {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 14px 7px 4px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.operator-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(22,119,238,.22);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
}

.operator-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.operator-info strong {
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operator-info span {
  overflow: hidden;
  color: #8fa1b8;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: transparent;
  color: #9eabc0;
  font-size: 16px;
}

.logout-button:hover {
  border-color: rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #fff;
}

.logout-button:disabled {
  cursor: wait;
  opacity: .5;
}
