:root {
  --bg: #f3eee4;
  --bg-2: #ebe2d3;
  --panel: rgba(255, 252, 246, 0.95);
  --ink: #1f1914;
  --muted: #685d53;
  --line: #ddcfbc;
  --accent: #166534;
  --accent-2: #b45309;
  --accent-3: #0f766e;
  --shadow: 0 20px 50px rgba(64, 47, 28, 0.09);
  --shadow-soft: 0 10px 25px rgba(64, 47, 28, 0.05);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(180, 83, 9, 0.13), transparent 28%),
    radial-gradient(circle at left bottom, rgba(15, 118, 110, 0.1), transparent 24%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.45), transparent 40%),
    var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.shell,
.sidebar,
.content,
.panel,
.hero,
.page-head,
.ongoing-card,
.stat-card,
.panel-head,
.clean-list li,
.form-grid,
.date-grid {
  min-width: 0;
}

.sidebar {
  padding: 24px 20px;
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.94), rgba(247, 239, 225, 0.86));
  border-left: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.brand {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  color: inherit;
  margin-bottom: 24px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand h1 {
  margin: 0 0 6px;
  font-size: 1.65rem;
}

.muted {
  color: var(--muted);
  line-height: 1.9;
  margin: 0;
}

.nav {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.mobile-nav,
.mobile-footer-actions {
  display: none;
}

.nav a {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  font-weight: 600;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.nav a:hover {
  transform: translateY(-1px);
  background: white;
  border-color: #cdb79a;
}

.nav-badge-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: #c62828;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
}

.small-user {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.content {
  padding: 28px;
}

#page-content {
  scroll-margin-top: 12px;
}

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

.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid rgba(217, 205, 191, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 24px;
  background: transparent;
  border: 0;
  box-shadow: none;
  display: grid;
  place-items: center;
  overflow: visible;
}

.login-brand img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(221, 207, 188, 0.7);
  background: rgba(255, 252, 246, 0.72);
  border-radius: 18px;
  backdrop-filter: blur(10px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero,
.panel,
.stat-card,
.ongoing-card {
  background: var(--panel);
  border: 1px solid rgba(217, 205, 191, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero,
.page-head,
.panel,
.ongoing-card {
  padding: 22px;
}

.page-head,
.hero,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-weight: 800;
}

.hero h2,
.page-head h2,
.panel h3 {
  margin: 0 0 10px;
}

.hero h2,
.page-head h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.3rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.add-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.add-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.expandable-panel .expandable-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: max-height 220ms ease, opacity 180ms ease, transform 180ms ease, margin-top 180ms ease;
}

.expandable-panel.is-expanded .expandable-content {
  max-height: 420px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 16px;
}

.button,
button {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  background: #efe4d6;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  white-space: normal;
  overflow-wrap: anywhere;
}

.button.primary,
button.primary {
  background: linear-gradient(135deg, var(--accent), #15803d);
  color: white;
}

.button.ghost,
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
}

.button.danger,
button.danger {
  color: #8a1c1c;
  border-color: rgba(138, 28, 28, 0.22);
}

.button.wide {
  width: 100%;
  text-align: center;
}

.stats-grid,
.two-col,
.ongoing-grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

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

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.ongoing-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.stat-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 243, 231, 0.88));
}

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

.stat-card strong {
  font-size: 2rem;
}

.ongoing-names {
  display: block;
  font-size: 1rem;
  line-height: 1.9;
  white-space: normal;
  word-break: break-word;
}

.ongoing-names.is-empty {
  font-size: 0.95rem;
  opacity: 0.88;
}

.stat-card.accent {
  background: linear-gradient(135deg, #1f6f5f, #2f8a76);
  color: white;
}

.stat-card.accent span {
  color: rgba(255, 255, 255, 0.82);
}

.form-grid,
.date-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  margin-top: 10px;
}

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

.form-grid label,
.date-grid {
  width: 100%;
}

label span,
.date-grid strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #b58a55;
  box-shadow: 0 0 0 4px rgba(181, 138, 85, 0.12);
}

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

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

.date-grid strong {
  grid-column: 1 / -1;
}

.date-grid.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.15);
}

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

.checkbox input {
  width: auto;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
}

.clean-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clean-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.clean-list li > * {
  min-width: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.flash-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
}

.flash.success {
  background: rgba(22, 101, 52, 0.09);
  color: #12492a;
  border-color: rgba(22, 101, 52, 0.15);
}

.flash.error {
  background: rgba(183, 60, 60, 0.09);
  color: #7d2323;
  border-color: rgba(183, 60, 60, 0.14);
}

.report-block + .report-block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

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

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

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

  .topbar,
  .page-head,
  .hero,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-grid,
  .two-col,
  .ongoing-grid,
  .form-grid.wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    font-size: 15px;
  }

  .content,
  .login-shell {
    padding: 14px;
  }

  .sidebar {
    display: none;
  }

  #page-content {
    scroll-margin-top: 8px;
  }

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

  .mobile-nav a {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.6;
    padding: 12px 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    font-weight: 700;
  }

  .mobile-nav .nav-badge-link {
    justify-content: center;
    gap: 8px;
  }

  .login-brand {
    width: 84px;
    height: 84px;
    border-radius: 22px;
  }

  .mobile-footer-actions {
    display: grid;
    gap: 10px;
    margin-top: 22px;
    padding: 16px;
    border: 1px solid rgba(217, 205, 191, 0.8);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow-soft);
  }

  .topbar {
    padding: 10px 12px;
    margin-bottom: 14px;
  }

  .topbar-actions,
  .hero-actions,
  .panel-actions,
  .row-actions {
    align-items: stretch;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .topbar-actions .button,
  .hero-actions .button,
  .panel-actions .button,
  .row-actions .button,
  .hero-actions a,
  .panel-actions a,
  .row-actions a {
    width: 100%;
    text-align: center;
  }

  .hero,
  .page-head,
  .panel,
  .ongoing-card,
  .login-card,
  .stat-card {
    padding: 16px;
    border-radius: 18px;
  }

  .panel-head {
    align-items: stretch;
  }

  .page-head h2,
  .hero h2 {
    font-size: 1.35rem;
    line-height: 1.7;
  }

  .panel h3 {
    margin-bottom: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card strong {
    font-size: 1.35rem;
    line-height: 1.8;
  }

  .form-grid,
  .form-grid.wide,
  .date-grid,
  .date-grid.compact {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .form-grid > *,
  .date-grid > * {
    min-width: 0;
  }

  .checkbox {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .clean-list li {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px 12px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(88px, 110px) 1fr;
    gap: 10px;
    align-items: start;
    white-space: normal;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(221, 207, 188, 0.75);
    font-size: 0.95rem;
  }

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

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.86rem;
    line-height: 1.8;
  }

  td form,
  td .button,
  td a.button {
    width: 100%;
  }

  td,
  td a,
  td span,
  td strong,
  small,
  .muted {
    overflow-wrap: anywhere;
  }
}
