:root {
  color-scheme: light;
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --line: #d7e1df;
  --line-strong: #b8c9c5;
  --text: #16201f;
  --muted: #5b6d69;
  --primary: #176d6b;
  --primary-strong: #0d5150;
  --green: #23865b;
  --amber: #c97913;
  --red: #b93131;
  --blue: #276db4;
  --shadow: 0 18px 50px rgba(28, 49, 46, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: var(--primary);
}

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

.loading-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loading-screen {
  align-content: center;
  gap: 14px;
  color: var(--muted);
}

.login-panel {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

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

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

.brand-row strong {
  display: block;
  font-size: 20px;
}

.brand-row span {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.login-panel h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.2;
}

.login-panel p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.login-actions,
.demo-actions {
  display: grid;
  gap: 10px;
}

.demo-actions {
  margin-top: 14px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  min-height: 72px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.header-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.header-title p {
  margin: 2px 0 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.user-copy {
  min-width: 0;
  text-align: right;
}

.user-copy strong,
.user-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy span {
  color: var(--muted);
  font-size: 13px;
}

.content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-item strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 370px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.left-stack {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 49, 46, 0.08);
}

.panel-header {
  padding: 18px 18px 0;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.task-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.catalog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.compact-form {
  display: grid;
  gap: 10px;
}

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

.catalog-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.catalog-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #32413f;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

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

.file-drop {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.file-drop input {
  padding: 0;
  border: 0;
  min-height: auto;
}

.file-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.attachment-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.attachment-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  aspect-ratio: 1;
}

.attachment-item img,
.attachment-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-item button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(22, 32, 31, 0.78);
  color: #fff;
  font-weight: 800;
}

.table-panel {
  min-width: 0;
}

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

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

.filter-select {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

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

.task-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.task-table th,
.task-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

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

.task-row {
  background: #fff;
}

.task-row:hover,
.task-row.is-selected {
  background: #f1f8f6;
}

.task-title {
  display: grid;
  gap: 4px;
}

.task-title strong {
  font-size: 15px;
}

.task-title span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #edf4f3;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green {
  background: #e5f5ec;
  color: #17643f;
}

.badge.amber {
  background: #fff4df;
  color: var(--amber);
}

.badge.red {
  background: #fde8e8;
  color: var(--red);
}

.badge.blue {
  background: #e8f1fb;
  color: var(--blue);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

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

.btn.secondary {
  background: #e6efed;
  color: var(--primary-strong);
}

.btn.secondary:hover {
  background: #d8e7e4;
}

.btn.ghost {
  background: transparent;
  color: var(--primary-strong);
  border: 1px solid var(--line-strong);
}

.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.btn.filter {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

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

.detail-panel {
  grid-column: 2;
  margin-top: 18px;
}

.detail-body {
  padding: 18px;
  display: grid;
  gap: 18px;
}

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

.detail-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.detail-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-field strong {
  display: block;
  word-break: break-word;
}

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

.media-grid a,
.media-grid video {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 4 / 3;
}

.media-grid img,
.media-grid video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.completion-box,
.edit-box {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.completion-box form,
.edit-box form {
  display: grid;
  gap: 12px;
}

.message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #e8f1fb;
  color: #164f85;
}

.message.error {
  background: #fde8e8;
  color: var(--red);
}

.empty-state {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

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

  .detail-panel {
    grid-column: 1;
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-box {
    width: 100%;
    justify-content: space-between;
  }

  .user-copy {
    text-align: left;
  }

  .stats-grid,
  .field-row,
  .detail-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .login-panel {
    padding: 22px;
  }
}
