:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --paper: #ffffff;
  --wash: #f4f8fb;
  --red: #e03131;
  --orange: #f08c00;
  --blue: #2563eb;
  --green: #16a34a;
  --purple: #7c3aed;
  --grey: #64748b;
  --teal: #0d9488;
  --yellow: #ca8a04;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 32rem),
    linear-gradient(135deg, #fbfdff 0%, #f0f7f5 48%, #fff8ed 100%);
  color: var(--ink);
  min-height: 100vh;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(217, 226, 239, 0.86);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  color: white;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav button,
.ghost,
.icon-button {
  background: #eef5ff;
  color: #1d4ed8;
  border: 1px solid #c9ddff;
  border-radius: 0.7rem;
  padding: 0.56rem 0.75rem;
  font-weight: 750;
}

.nav button.active {
  background: #172033;
  border-color: #172033;
  color: white;
}

.primary,
.danger,
.success,
.warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 0.75rem;
  padding: 0.7rem 0.95rem;
  font-weight: 850;
  color: white;
  min-height: 2.65rem;
}

.primary {
  background: linear-gradient(135deg, var(--purple), #3157d5);
}

.success {
  background: var(--green);
}

.warning {
  background: var(--orange);
}

.danger {
  background: var(--red);
}

.container {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 1.2rem clamp(1rem, 3vw, 2rem) 2.5rem;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-panel {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 1.2rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-hero {
  padding: clamp(1.35rem, 4vw, 3rem);
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.92), rgba(13, 148, 136, 0.82)),
    linear-gradient(45deg, #3b82f6, #f59e0b);
  color: white;
}

.login-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.login-hero p {
  max-width: 34rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: 1.08rem;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 0.9rem;
  align-content: center;
  padding: clamp(1.35rem, 4vw, 2.4rem);
}

.field {
  display: grid;
  gap: 0.38rem;
}

.field span,
.field label {
  font-weight: 800;
  color: #253047;
  font-size: 0.88rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cbd7e8;
  background: white;
  color: var(--ink);
  border-radius: 0.72rem;
  padding: 0.74rem 0.8rem;
  min-height: 2.75rem;
}

.field textarea {
  min-height: 7.5rem;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.brain-box,
.ai-panel,
.panel,
.modal-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 226, 239, 0.95);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.brain-box {
  padding: clamp(1rem, 2.5vw, 1.35rem);
}

.brain-box h2,
.ai-panel h2,
.panel h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  letter-spacing: 0;
}

.brain-actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.ai-panel {
  padding: 1rem;
  border-top: 0.42rem solid var(--purple);
}

.opportunity-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.mini-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #d8c8ff;
  border-radius: 0.85rem;
  background: #fbf8ff;
}

.mini-list p {
  margin: 0;
  color: #4b3b6d;
  line-height: 1.35;
}

.opportunity {
  border: 1px solid #ddcffc;
  background: #f6f0ff;
  border-radius: 0.85rem;
  padding: 0.8rem;
}

.opportunity h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.opportunity p {
  margin: 0.25rem 0;
  color: #3d315a;
  line-height: 1.35;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 0.7rem;
  align-items: end;
  margin: 1rem 0;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(217, 226, 239, 0.9);
  border-radius: 1rem;
}

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

.lane {
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(217, 226, 239, 0.9);
  padding: 0.85rem;
  min-height: 12rem;
}

.lane header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.lane h2 {
  margin: 0;
  font-size: 1rem;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.65rem;
  min-height: 1.65rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: #e9eef7;
  color: #243047;
  font-weight: 900;
  font-size: 0.8rem;
}

.cards {
  display: grid;
  gap: 0.75rem;
}

.task-card {
  background: white;
  border: 1px solid #dbe4ef;
  border-left: 0.42rem solid var(--blue);
  border-radius: 0.92rem;
  padding: 0.85rem;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.08);
}

.task-card.urgent,
.task-card.overdue {
  border-left-color: var(--red);
}

.task-card.high {
  border-left-color: var(--orange);
}

.task-card.ai {
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.16);
}

.task-card.waiting {
  border-left-color: var(--grey);
}

.task-card.done {
  opacity: 0.74;
}

.task-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  min-width: 0;
}

.task-title h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.task-card p {
  margin: 0.45rem 0;
  color: #475467;
  line-height: 1.4;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0;
}

.email-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.85rem 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.28rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 850;
  background: #eef2f7;
  color: #334155;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.badge.priority-urgent {
  background: #ffe3e3;
  color: #a61e1e;
}

.badge.priority-high {
  background: #fff0d5;
  color: #9a5b00;
}

.badge.ai-badge {
  background: #efe4ff;
  color: #5b21b6;
}

.badge.waiting-badge {
  background: #e8eef5;
  color: #475569;
}

.badge.quick {
  background: #fff7cc;
  color: #8a6500;
}

.task-actions {
  display: flex;
  gap: 0.38rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}

.task-actions button {
  flex: 1 1 auto;
  min-height: 2.25rem;
  padding: 0.45rem 0.58rem;
  border-radius: 0.62rem;
  background: #eef5ff;
  color: #1d4ed8;
  font-weight: 800;
}

.task-actions button.delete {
  background: #fff1f1;
  color: #c92a2a;
}

.empty {
  color: var(--muted);
  border: 1px dashed #cbd7e8;
  border-radius: 0.85rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.55);
  line-height: 1.42;
}

.panel {
  padding: 1rem;
  margin-bottom: 1rem;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.insight-card {
  background: #ffffff;
  border: 1px solid #dbe4ef;
  border-radius: 0.9rem;
  padding: 0.9rem;
}

.insight-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.insight-card p {
  margin: 0;
  color: #344054;
  line-height: 1.4;
}

.task-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.task-table th,
.task-table td,
.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e3eaf4;
  padding: 0.7rem;
  text-align: left;
  vertical-align: top;
}

.task-table th,
.admin-table th {
  color: #475467;
  font-size: 0.82rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.48);
}

.modal-card {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 1rem;
}

.modal-card h2 {
  margin: 0 0 0.75rem;
}

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

.full {
  grid-column: 1 / -1;
}

.review-list {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.suggestion-card {
  border: 1px solid #dbe4ef;
  border-radius: 0.9rem;
  padding: 0.8rem;
  background: #fff;
}

.suggestion-card.discarded {
  opacity: 0.55;
}

.prompt-box {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #101828;
  color: #f8fafc;
  padding: 0.9rem;
  border-radius: 0.8rem;
  line-height: 1.45;
}

.prompt-details {
  margin-top: 0.75rem;
}

.prompt-details summary {
  cursor: pointer;
  color: #1d4ed8;
  font-weight: 850;
  margin-bottom: 0.5rem;
}

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: #172033;
  color: white;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .hero-panel,
  .board {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 740px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 18rem),
      linear-gradient(135deg, #fbfdff 0%, #f2faf8 100%);
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 0.85rem;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .top-actions > .primary,
  .top-actions > .ghost {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .login-panel,
  .form-grid,
  .insight-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav button {
    width: 100%;
    padding-inline: 0.45rem;
    min-height: 2.55rem;
  }

  .container {
    padding: 0.85rem 0.75rem 1.5rem;
  }

  .brain-box,
  .ai-panel,
  .panel,
  .lane {
    border-radius: 0.85rem;
  }

  .brain-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .brain-actions button,
  .task-actions button,
  .opportunity button {
    width: 100%;
  }

  .task-title {
    align-items: stretch;
    flex-direction: column;
  }

  .task-title .icon-button {
    width: 100%;
  }

  .badges {
    gap: 0.3rem;
  }

  .badge {
    border-radius: 0.6rem;
    white-space: normal;
  }

  .task-table,
  .task-table thead,
  .task-table tbody,
  .task-table tr,
  .task-table td,
  .admin-table,
  .admin-table thead,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .task-table thead,
  .admin-table thead {
    display: none;
  }

  .task-table,
  .admin-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .task-table tr,
  .admin-table tr {
    margin: 0 0 0.85rem;
    padding: 0.75rem;
    border: 1px solid #dbe4ef;
    border-radius: 0.9rem;
    background: #fff;
    box-shadow: 0 8px 20px rgba(31, 41, 55, 0.06);
  }

  .task-table td,
  .admin-table td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
    border-bottom: 1px solid #eef2f7;
    padding: 0.58rem 0;
    overflow-wrap: anywhere;
  }

  .task-table td:last-child,
  .admin-table td:last-child {
    border-bottom: 0;
  }

  .task-table td::before,
  .admin-table td::before {
    content: attr(data-label);
    color: #64748b;
    font-weight: 850;
    font-size: 0.78rem;
  }

  .modal {
    align-items: end;
    padding: 0;
  }

  .modal-card {
    width: 100%;
    max-height: 94vh;
    border-radius: 1rem 1rem 0 0;
    padding: 1rem 0.85rem;
  }

  .toast {
    width: calc(100% - 1.5rem);
    border-radius: 0.85rem;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    width: 2.25rem;
    height: 2.25rem;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand p,
  .hint {
    font-size: 0.8rem;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary,
  .danger,
  .success,
  .warning,
  .ghost,
  .icon-button {
    min-height: 2.75rem;
  }

  .login-wrap {
    padding: 0.75rem;
    place-items: stretch;
  }

  .login-panel {
    border-radius: 0.9rem;
  }

  .login-hero h2 {
    font-size: 2rem;
  }

  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
  }

  .task-table td,
  .admin-table td {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
