:root {
  --ink: #1a1712;
  --ink-3: #4a443c;
  --ink-5: #8a8278;
  --paper: #fbfaf7;
  --rule: #e8e3d8;
  --red: #b91c1c;
  --green: #15803d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Tahoma, 'Segoe UI', Vazir, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.6;
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
  transition: background .15s;
}
button:hover { background: var(--ink); color: var(--paper); }
button.primary { background: var(--ink); color: var(--paper); }
button.primary:hover { background: #000; }
button.ghost { border-color: var(--rule); color: var(--ink-3); }
button.danger { border-color: var(--red); color: var(--red); }
button.danger:hover { background: var(--red); color: white; }

input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: white;
  color: var(--ink);
  width: 100%;
  border-radius: 0;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  margin-bottom: 4px;
}
label > input, label > textarea, label > select {
  margin-top: 6px;
  font-weight: 400;
}

textarea { resize: vertical; min-height: 80px; }

.muted { color: var(--ink-5); font-size: 12px; }
.error {
  color: var(--red);
  background: #fef2f2;
  padding: 8px 12px;
  border-right: 3px solid var(--red);
  font-size: 12px;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card {
  background: white;
  border: 1px solid var(--rule);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.card h1 { font-size: 18px; margin: 0 0 4px; }
.card p { margin: 0 0 24px; }
.card label { margin-top: 14px; }
.card button { width: 100%; margin-top: 20px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: white;
  border-bottom: 1px solid var(--rule);
}
.topbar .brand { font-weight: 900; font-size: 15px; letter-spacing: -.3px; }
.topbar .actions { display: flex; gap: 10px; }

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.tabs button {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.tabs button:hover {
  background: transparent;
  color: var(--ink);
}
.tabs button.tab-active {
  color: var(--ink);
  border-bottom-color: var(--red);
}

.risk-row { grid-template-columns: 1fr auto; }
.risk-row .row-meta strong { font-size: 13px; }

.pill.level-critical    { background: #7f1d1d; color: white; }
.pill.level-high        { background: #b91c1c; color: white; }
.pill.level-medium      { background: #92400e; color: white; }
.pill.level-low         { background: #166534; color: white; }
.pill.level-opportunity { background: #1e40af; color: white; }

.page { max-width: 1100px; margin: 0 auto; padding: 32px; }
.page h2 { font-size: 22px; letter-spacing: -.5px; margin: 0 0 24px; }

.list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  align-items: center;
  background: white;
  padding: 14px 18px;
}
.row-cover {
  width: 88px;
  height: 66px;
  background-color: #eee;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--rule);
}
.row-main h3 { font-size: 14px; font-weight: 700; margin: 4px 0; }
.row-main p { margin: 0; }
.row-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; }

.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  background: #f2efe8;
  color: var(--ink-3);
  letter-spacing: .5px;
}
.pill.red { background: var(--red); color: white; }

.editor .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.editor .col.span-2 { grid-column: 1 / -1; }
.editor .row-end { display: flex; justify-content: flex-start; }

.checkbox {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}
.checkbox input { width: auto; margin: 0; }
.checkbox span { font-weight: 700; color: var(--ink); }

.cover-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 6px;
}
.cover-row input[type=file] { flex: 1; }
.cover-row img {
  width: 120px;
  height: 80px;
  object-fit: cover;
  background: #eee;
  border: 1px solid var(--rule);
}
.cover-row img[src=""] { visibility: hidden; }

@media (max-width: 720px) {
  .editor .grid { grid-template-columns: 1fr; }
  .editor .col.span-2 { grid-column: 1; }
  .topbar { padding: 12px 16px; }
  .page { padding: 16px; }
  .row { grid-template-columns: 64px 1fr; }
  .row-actions { grid-column: 1 / -1; }
  .row-cover { width: 64px; height: 48px; }
}
