:root {
  --bg-soft: #eef4f8;
  --bg-card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #d8e2ea;
  --brand: #0f766e;
  --brand-2: #0ea5a6;
  --ok: #15803d;
  --err: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 90% 0%, #ccfbf122 0, transparent 30%),
    radial-gradient(circle at 0% 100%, #e0f2fe44 0, transparent 35%),
    var(--bg-soft);
}

.shell {
  width: min(1240px, 94vw);
  margin: 0 auto;
  padding: 2.2rem 0;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

h1, h2, h3 {
  margin: 0;
}

.subtitle {
  margin-top: 0.45rem;
  color: var(--muted);
}

.login-wrap {
  min-height: calc(100vh - 4.4rem);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.3rem;
  box-shadow: 0 14px 30px #0f172a14;
}

.app-layout {
  display: grid;
  gap: 0.8rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.header-right p {
  margin: 0;
  font-weight: 700;
}

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

.top-nav {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.45rem;
  overflow-x: auto;
}

.nav-btn {
  border: 0;
  border-radius: 10px;
  padding: 0.56rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.nav-btn.active {
  color: #fff;
  background: linear-gradient(95deg, var(--brand), var(--brand-2));
}

.module-view {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  background: #fff;
}

.card p {
  margin: 0.45rem 0 0;
  font-weight: 700;
}

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

.stat p {
  font-size: 1.35rem;
}

.form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.form-grid {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
}

input, .select-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.72rem;
  font: inherit;
  background: #fff;
}

.select-input {
  min-height: 120px;
}

input:focus, .select-input:focus {
  outline: 2px solid #ccfbf1;
  border-color: var(--brand);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox input {
  width: auto;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 0.62rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(95deg, var(--brand), var(--brand-2));
}

.ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.row-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.3rem;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  margin-top: 0.8rem;
  background: #fff;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 0.8rem;
}

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

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.36rem;
  text-align: left;
  white-space: nowrap;
  font-size: 0.88rem;
}

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

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0.8rem;
}

.list-clean {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.42rem;
}

.chat-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.62rem;
  cursor: pointer;
}

.chat-item.active {
  border-color: var(--brand-2);
  background: #f0fdfa;
}

.chat-item p {
  margin: 0;
  font-weight: 700;
}

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

.thread-header {
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.thread-body {
  min-height: 300px;
  padding: 0.8rem 0;
  display: grid;
  gap: 0.55rem;
}

.msg {
  max-width: 72%;
  border-radius: 10px;
  padding: 0.52rem 0.64rem;
  background: #f8fafc;
}

.msg.out {
  margin-left: auto;
  background: #ecfeff;
}

.thread-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.feedback {
  min-height: 1.3em;
  margin-top: 0.72rem;
}

.feedback.error {
  color: var(--err);
}

.feedback.success {
  color: var(--ok);
}

@media (max-width: 980px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 740px) {
  .shell {
    padding: 1rem 0;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

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

  .row-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .row-actions {
    flex-direction: column;
  }
}
