*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
  direction: rtl;
}

/* Password overlay */
#password-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.password-box {
  background: #111827;
  padding: 24px 28px;
  border-radius: 16px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  color: #e5e7eb;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.password-box h2 {
  margin: 0 0 8px;
}

.password-box p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: #9ca3af;
}

.password-box input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  margin-bottom: 8px;
}

.password-box button {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

#password-error {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #fca5a5;
}

/* App layout */
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  flex-direction: row-reverse;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-direction: row-reverse;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.app-header p {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #2563eb;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button.secondary {
  background: #6b7280;
}

button:active {
  transform: translateY(1px);
}

.grid {
  display: grid;
  gap: 16px;
}

.inputs-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.results-grid,
.charts-grid {
  margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 18px 16px;
  box-shadow: 0 12px 30px rgba(15,23,42,0.06);
  border: 1px solid #e5e7eb;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.card h3 {
  margin: 8px 0 6px;
  font-size: 0.95rem;
  color: #374151;
}

.field {
  margin-bottom: 6px;
}

label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 2px;
  color: #374151;
}

input[type="number"] {
  width: 100%;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
}

input[type="number"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb33;
}

hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 10px 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 4px;
  flex-wrap: wrap;
}

#capacity-warning {
  font-size: 0.8rem;
  color: #b91c1c;
}

/* dynamic list */
.dynamic-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
}

.dynamic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: #4b5563;
}

.dynamic-row {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.dynamic-row input[type="text"] {
  flex: 1;
  padding: 4px 6px;
  border-radius: 7px;
  border: 1px solid #d1d5db;
  font-size: 0.8rem;
}

.dynamic-row input[type="number"] {
  width: 110px;
}

/* KPIs */
.kpi {
  background: #f9fafb;
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 5px;
}

.kpi-label {
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 2px;
}

.kpi-value {
  font-size: 1rem;
  font-weight: 600;
}

.kpi.highlight {
  border-color: #bbf7d0;
  background: #ecfdf5;
}

/* tables & charts */
.sc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 6px;
}

.sc-table th,
.sc-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 5px 6px;
  text-align: center;
}

.sc-table th {
  background: #f3f4f6;
}

/* print / pdf */
@media print {
  #password-overlay { display:none !important; }
  .app { padding: 10px; }
  .header-actions, .actions { display:none !important; }
}