:root {
  color-scheme: light;
  --bg: #edf5ee;
  --panel: #fbfffa;
  --ink: #173024;
  --muted: #5d6d62;
  --accent: #26734a;
  --accent-2: #175c39;
  --line: rgba(31, 35, 40, 0.12);
  font-family: Vazirmatn, Segoe UI, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(circle at top right, rgba(38, 115, 74, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(72, 145, 91, 0.13), transparent 28%),
    var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  padding: 24px;
  border-left: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark, .logo.placeholder {
  width: 54px; height: 54px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #55a96a);
  color: white; font-weight: 700;
}
.brand h1, .paper-header h2 { margin: 0; }
.brand p, .paper-header p, .status, .paper-meta { margin: 0; color: var(--muted); }

.field, .upload-card {
  display: grid; gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}
.field input, .field select, .upload-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.upload-card {
  cursor: pointer;
  border-style: dashed;
}
.upload-card span { font-weight: 600; }
.upload-card input { padding: 0; border: 0; }

.primary {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent), #4e9a61);
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary {
  border: 1px solid var(--accent-2);
  border-radius: 16px;
  padding: 12px 16px;
  background: white;
  color: var(--accent-2);
  font-weight: 700;
  cursor: pointer;
}
.secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.workspace { padding: 24px; overflow: auto; }
.paper {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(31, 35, 40, 0.08);
  overflow: hidden;
}
.paper-header {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: linear-gradient(180deg, rgba(38, 115, 74, 0.1), transparent);
  border-bottom: 1px solid var(--line);
}
.header-copy { display: flex; gap: 14px; align-items: center; }
.logo { width: 62px; height: 62px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.paper-meta { display: grid; gap: 4px; text-align: left; font-size: 14px; }
.notice, .paper-footer {
  padding: 12px 24px;
  font-size: 12px;
  line-height: 1.8;
  text-align: justify;
  border-bottom: 1px solid var(--line);
  background: rgba(38, 115, 74, 0.05);
}
.paper-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: rgba(31, 111, 120, 0.04);
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; table-layout: fixed; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: right;
  vertical-align: top;
}
thead th {
  position: sticky;
  top: 0;
  background: #dcefe0;
  color: #174b2d;
  border-bottom: 2px solid rgba(38, 115, 74, 0.28);
  z-index: 1;
}
tbody tr[data-row-id]:nth-of-type(even) td { background: #f1f8f2; }
.row-no-col, .row-no { width: 60px; text-align: center; }
.row-order {
  width: 42px;
  padding: 6px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  text-align: center;
  direction: ltr;
  font-weight: 700;
}
.handle-col, .handle-cell { width: 82px; text-align: center; }
.col-0 { width: 11%; }
.col-1 { width: 30%; }
.col-2 { width: 31%; }
.col-3 { width: 10%; }
.col-4 { width: 18%; }
.cell-wrap {
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  line-height: 1.45;
}
.university-cell,
.major-cell { min-height: 3.2em; }
.major-cell {
  direction: rtl;
  unicode-bidi: plaintext;
}
.university-cell {
  direction: rtl;
  unicode-bidi: plaintext;
}
.code-cell { direction: ltr; }
.type-cell { white-space: nowrap; }
.row-badge {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
.handle {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: grab;
}
.delete-row {
  width: 30px;
  height: 30px;
  margin-right: 4px;
  border: 1px solid rgba(161, 39, 29, 0.28);
  border-radius: 9px;
  background: #fff7f5;
  color: #a1271d;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}
.dragging {
  opacity: 1;
  background: #fffdf7;
  outline: 2px solid rgba(38, 115, 74, 0.45);
  outline-offset: -2px;
  box-shadow: 0 10px 24px rgba(31, 35, 40, 0.12);
}
.dragging td {
  background: #fffdf7;
}
.drag-over { background: transparent; }
.drop-indicator td {
  padding: 0;
  border-bottom: 0;
}
.drop-indicator span {
  display: block;
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(38, 115, 74, 0.14), rgba(38, 115, 74, 0.24));
  border: 1px solid rgba(38, 115, 74, 0.35);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.empty-state {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
}
.description-cell {
  white-space: normal;
  word-break: break-word;
  line-height: 1.45;
}
.status.error { color: #a1271d; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-left: 0; border-bottom: 1px solid var(--line); }
  .paper-header { flex-direction: column; align-items: flex-start; }
}

@media print {
  body { background: white; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .paper-meta { display: none; }
  .workspace { width: 100%; padding: 0; }
  .paper {
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .handle-col,
  .handle-cell { display: none; }
  .row-order {
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
  }
  table {
    min-width: 0;
    font-size: 8.5pt;
  }
  th, td { padding: 6px 4px; }
  .row-no-col, .row-no { width: 8%; }
  .col-0 { width: 10%; }
  .col-1 { width: 27%; }
  .col-2 { width: 28%; }
  .col-3 { width: 12%; }
  .col-4 { width: 15%; }
  .drop-indicator { display: none; }
}
