:root {
  --bg: #eef2ef;
  --panel: #ffffff;
  --panel-soft: #f7f9f7;
  --text: #182522;
  --muted: #66746f;
  --line: #d8e0dc;
  --primary: #1f6b5d;
  --primary-dark: #155348;
  --accent: #b75f3f;
  --gold: #c38a24;
  --blue: #3f6680;
  --danger: #a64040;
  --ok: #2f7a4c;
  --shadow: 0 16px 36px rgba(18, 34, 30, 0.12);
  --radius: 8px;
  --sidebar: 264px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: #1e2e2a;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(360px, 1fr);
  align-items: stretch;
}

.login-card {
  margin: auto;
  width: min(380px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 17px;
}

.brand-lockup span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.brand-lockup.compact {
  padding: 18px 16px 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  font-weight: 800;
}

.login-form {
  margin-top: 30px;
  display: grid;
  gap: 14px;
}

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

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 10px 11px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 107, 93, 0.14);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

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

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  color: var(--primary-dark);
  border-color: #b8cec7;
  background: #edf6f3;
}

.secondary-btn:hover {
  border-color: var(--primary);
}

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

.ghost-btn:hover {
  border-color: #afbeb8;
  background: var(--panel-soft);
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--text);
  border-color: var(--line);
  background: #fff;
}

.icon-btn:hover {
  border-color: #afbeb8;
  background: var(--panel-soft);
}

button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.login-preview {
  display: grid;
  place-items: center;
  padding: 48px;
  background:
    linear-gradient(90deg, rgba(31, 107, 93, 0.10) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 107, 93, 0.10) 1px, transparent 1px),
    #dde7e3;
  background-size: 44px 44px;
}

.preview-window {
  width: min(720px, 80%);
  aspect-ratio: 1.45;
  padding: 18px;
  border: 1px solid rgba(45, 73, 66, 0.20);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 24px 60px rgba(36, 56, 51, 0.18);
}

.preview-topbar {
  height: 34px;
  border-radius: 6px;
  background: #223b35;
}

.preview-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.preview-grid span {
  height: 96px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
}

.preview-grid span:nth-child(2) {
  border-top: 5px solid var(--accent);
}

.preview-grid span:nth-child(3) {
  border-top: 5px solid var(--gold);
}

.preview-grid span:nth-child(4) {
  border-top: 5px solid var(--blue);
}

.preview-lines {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.preview-lines b {
  height: 12px;
  width: 100%;
  border-radius: 4px;
  background: #cdd9d4;
}

.preview-lines b:nth-child(2) {
  width: 74%;
}

.preview-lines b:nth-child(3) {
  width: 52%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f9fbfa;
}

.nav {
  padding: 8px;
  display: grid;
  gap: 4px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #263832;
  background: transparent;
  font-weight: 700;
}

.nav button:hover {
  background: #edf3f0;
}

.nav button.active {
  color: var(--primary-dark);
  border-color: #c8dad4;
  background: #e6f1ed;
}

.nav svg {
  width: 18px;
  height: 18px;
}

.sidebar-exit {
  margin: auto 12px 14px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(238, 242, 239, 0.92);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.topbar p {
  min-height: 18px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.content {
  padding: 24px 26px 42px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.card,
.stat-card,
.table-wrap,
.timeline,
.chat-panel,
.kanban-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card {
  padding: 16px;
}

.card-head,
.row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h2,
.card h3,
.kanban-column h2 {
  margin: 0;
  line-height: 1.2;
}

.card h2 {
  font-size: 18px;
}

.card h3,
.kanban-column h2 {
  font-size: 16px;
}

.card p {
  color: var(--muted);
  line-height: 1.45;
}

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

.stat-card {
  padding: 16px;
  min-height: 112px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.badge-row,
.toolbar-row,
.attachment-row,
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #243832;
  background: #edf2ef;
  border: 1px solid #d8e0dc;
  font-size: 12px;
  font-weight: 800;
}

.badge.todo,
.badge.draft {
  color: #34444f;
  background: #e8eef2;
}

.badge.in_progress,
.badge.active {
  color: #174f44;
  background: #e0f0eb;
}

.badge.review,
.badge.paused {
  color: #775217;
  background: #f6ead1;
}

.badge.done {
  color: #285b39;
  background: #def0e5;
}

.badge.urgent,
.badge.high {
  color: #7a2d2d;
  background: #f4dddd;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}

.section-title:first-child {
  margin-top: 0;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.empty {
  padding: 28px;
  border: 1px dashed #bfcac5;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
  align-items: start;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.kanban-column {
  min-height: 280px;
  padding: 12px;
}

.kanban-column h2 {
  margin-bottom: 10px;
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  margin-bottom: 10px;
}

.task-card h3 {
  font-size: 15px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

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

tr:last-child td {
  border-bottom: 0;
}

.timeline {
  padding: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-date {
  color: var(--primary-dark);
  font-weight: 800;
}

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

.file-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.file-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  color: var(--muted);
  background: #edf2ef;
}

.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.attachment-row {
  margin-top: 12px;
}

.attachment-thumb {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #edf2ef;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(360px, calc(100vh - 245px)) auto;
  min-height: 480px;
}

.messages {
  overflow-y: auto;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.message {
  max-width: 780px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.message.mine {
  margin-left: auto;
  border-color: #b8cec7;
  background: #edf6f3;
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-body {
  margin-top: 6px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-form textarea {
  min-height: 44px;
  max-height: 130px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 27, 24, 0.48);
}

.modal {
  width: min(820px, 100%);
  max-height: min(92vh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal form {
  overflow-y: auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-soft);
}

.permission-grid input {
  width: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

@media (max-width: 1160px) {
  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kanban {
    grid-template-columns: repeat(4, minmax(250px, 1fr));
  }

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

@media (max-width: 820px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-preview {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding: 8px 10px;
  }

  .nav button {
    width: auto;
    flex: 0 0 auto;
  }

  .sidebar-exit {
    margin: 8px 10px 12px;
    align-self: flex-start;
  }

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

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

  .content {
    padding: 16px 16px 28px;
  }

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .form-grid,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .brand-lockup.compact {
    padding-bottom: 4px;
  }

  .card-head,
  .row-head {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .danger-btn {
    width: 100%;
  }

  .inline-actions .icon-btn,
  .top-actions .icon-btn {
    width: 38px;
  }
}
