:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-alt: #eef3f7;
  --ink: #16202a;
  --muted: #627083;
  --line: #d9e0e7;
  --primary: #315f72;
  --primary-strong: #234756;
  --accent: #b4533a;
  --success: #2e7d56;
  --error: #a23b3b;
  --shadow: 0 18px 45px rgba(28, 43, 56, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.hidden,
[hidden] {
  display: none !important;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(110deg, rgba(49, 95, 114, 0.92), rgba(180, 83, 58, 0.76)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 420px;
  width: min(1040px, 100%);
  min-height: 620px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
  padding: 48px;
  background: rgba(255, 255, 255, 0.62);
}

.auth-brand h1,
.topbar h1,
.panel h2 {
  margin: 0;
}

.auth-brand h1 {
  max-width: 500px;
  font-size: 56px;
  line-height: 1;
}

.auth-brand p {
  max-width: 540px;
  color: var(--muted);
  font-size: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  margin: 8px auto 24px;
}

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

.domain-row span,
.profile-chip,
.metric-row article {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.domain-row span {
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--primary-strong);
  font-weight: 700;
}

.auth-panel {
  align-self: center;
  padding: 36px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.segmented button {
  border: 0;
  border-radius: 6px;
  padding: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(28, 43, 56, 0.08);
}

.auth-form,
.form-panel,
.modal-panel {
  display: grid;
  gap: 16px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
}

select[multiple] {
  min-height: 130px;
}

.primary-button,
.secondary-button,
.icon-button,
.logout-form button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 13px 16px;
  background: var(--primary);
  color: #fff;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--primary-strong);
}

.icon-button {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
}

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

.flash-ok {
  background: rgba(46, 125, 86, 0.12);
  color: var(--success);
}

.flash-error {
  background: rgba(162, 59, 59, 0.12);
  color: var(--error);
}

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

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100vh;
  padding: 16px 10px;
  background: #17232d;
  color: #dce7ee;
}

.rail a,
.logout-form button {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 12px;
}

.rail a span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.rail a.active,
.rail a:hover,
.logout-form button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.rail b {
  position: absolute;
  right: 8px;
  top: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}

.logout-form {
  margin-top: auto;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  padding: 22px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar p {
  margin: 0 0 3px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

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

.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  padding: 8px 12px;
  border-radius: 8px;
}

.profile-chip span,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.profile-chip small {
  display: block;
  color: var(--muted);
}

.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(28, 43, 56, 0.06);
}

.panel > h2,
.admin-panel > p {
  padding: 20px;
}

.panel-heading,
.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.message-head h2 {
  margin: 0;
  font-size: 18px;
}

.message-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.conversation-list {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.conversation-list a,
.notification-list a {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
}

.conversation-list a.active,
.conversation-list a:hover,
.notification-list a:hover,
.notification-list a.unread {
  background: var(--panel-alt);
}

.conversation-list small,
.notification-list small,
.event-item small,
.people-grid small {
  color: var(--muted);
}

.message-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-height: calc(100vh - 132px);
}

.messages {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 18px;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  max-width: 760px;
}

.message.own {
  margin-left: auto;
}

.message.own > div:last-child {
  background: #e5f0f4;
}

.message > div:last-child {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message header {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.message p {
  margin: 5px 0 0;
  line-height: 1.5;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.event-list,
.notification-list,
.people-grid {
  padding: 16px;
}

.event-item {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.event-item h3,
.event-item p {
  margin: 0 0 4px;
}

.form-panel {
  padding: 18px;
}

.notification-list {
  display: grid;
  gap: 8px;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.people-grid article {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.people-grid h3,
.people-grid p {
  margin: 0;
}

.call-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.call-actions .secondary-button {
  min-height: 36px;
  padding: 8px;
  font-size: 13px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 20px;
}

.metric-row article {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 8px;
}

.metric-row strong {
  overflow-wrap: anywhere;
  font-size: 24px;
}

.metric-row span {
  color: var(--muted);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 24, 32, 0.48);
}

.modal-panel {
  width: min(520px, 100%);
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .auth-shell,
  .app-shell,
  .chat-layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    padding: 32px;
  }

  .auth-brand h1 {
    font-size: 40px;
  }

  .rail {
    position: static;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    height: auto;
  }

  .brand-mark.small,
  .logout-form {
    margin: 0;
  }

  .topbar,
  .event-item,
  .composer {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .profile-chip {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .auth-page,
  .workspace {
    padding: 12px;
  }

  .auth-panel {
    padding: 22px;
  }

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

  .metric-row {
    grid-template-columns: 1fr;
  }
}
