/* Crispy Crust v94 - Owner Accounting, Supplier Payables, VAT & Contracts Hub */
/* Strict DESIGN_SYSTEM.md: #020617 / #0f172a / #1e293b, Gold #f59e0b, Emerald #10b981, Crimson #dc2626, Cairo RTL */

.accounting-hub-shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 18px 40px;
  box-sizing: border-box;
  color: #f8fafc;
  font-family: 'Cairo', sans-serif !important;
  direction: rtl;
}

.acc-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.72));
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.acc-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.acc-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.42);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.acc-header-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #f8fafc;
}

.acc-header-sub {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-top: 2px;
}

.acc-owner-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  font-size: 0.78rem;
  font-weight: 700;
}

.acc-subtabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.acc-subtab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid rgba(51, 65, 85, 0.7);
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.acc-subtab-btn:hover {
  border-color: rgba(245, 158, 11, 0.5);
  color: #f8fafc;
}

.acc-subtab-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

.acc-panel-card {
  background: #0f172a;
  border: 1px solid rgba(51, 65, 85, 0.65);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.acc-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.acc-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.acc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.acc-period-group {
  display: inline-flex;
  background: #020617;
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.acc-period-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.acc-period-btn.active {
  background: #f59e0b;
  color: #020617;
}

.acc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(51, 65, 85, 0.8);
  background: #1e293b;
  color: #f8fafc;
  transition: all 0.16s ease;
}

.acc-btn:hover {
  border-color: rgba(245, 158, 11, 0.55);
}

.acc-btn-gold {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #020617;
}

.acc-btn-gold:hover {
  background: #fbbf24;
  border-color: #fbbf24;
}

.acc-btn-emerald {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.acc-btn-emerald:hover {
  background: rgba(16, 185, 129, 0.25);
}

.acc-btn-crimson {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.45);
  color: #f87171;
}

.acc-btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.acc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.acc-kpi-card {
  background: #0f172a;
  border: 1px solid rgba(51, 65, 85, 0.65);
  border-radius: 13px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.acc-kpi-card.accent-gold { border-top: 3px solid #f59e0b; }
.acc-kpi-card.accent-emerald { border-top: 3px solid #10b981; }
.acc-kpi-card.accent-crimson { border-top: 3px solid #dc2626; }
.acc-kpi-card.accent-sky { border-top: 3px solid #38bdf8; }

.acc-kpi-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}

.acc-kpi-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0;
}

.acc-kpi-value.val-emerald { color: #34d399; }
.acc-kpi-value.val-crimson { color: #f87171; }
.acc-kpi-value.val-gold { color: #fbbf24; }
.acc-kpi-value.val-sky { color: #38bdf8; }

.acc-kpi-sub {
  font-size: 0.76rem;
  color: #64748b;
}

.acc-form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}

.acc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.acc-field.span-2 {
  grid-column: span 2;
}

.acc-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
}

.acc-input,
.acc-select,
.acc-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #1e293b;
  border: 1px solid rgba(71, 85, 105, 0.75);
  border-radius: 9px;
  color: #f8fafc;
  padding: 8px 11px;
  font-size: 0.86rem;
  font-family: 'Cairo', sans-serif !important;
  outline: none;
}

.acc-input:focus,
.acc-select:focus,
.acc-textarea:focus {
  border-color: #f59e0b;
}

.acc-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.acc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.acc-table th {
  text-align: right;
  padding: 10px 12px;
  background: #020617;
  color: #94a3b8;
  font-weight: 700;
  border-bottom: 1px solid rgba(51, 65, 85, 0.7);
  white-space: nowrap;
}

.acc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  vertical-align: middle;
}

.acc-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.45);
}

.acc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.acc-badge-emerald {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.acc-badge-gold {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.acc-badge-crimson {
  background: rgba(220, 38, 38, 0.16);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.acc-badge-sky {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.acc-two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.acc-cat-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.acc-cat-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #cbd5e1;
}

.acc-cat-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
}

.acc-cat-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.acc-receipt-preview {
  background: #020617;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  padding: 16px;
  color: #e2e8f0;
  font-size: 0.82rem;
}

.acc-receipt-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
}

.acc-json-box {
  background: #020617;
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.76rem;
  color: #38bdf8;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 10px;
}

.acc-empty {
  text-align: center;
  padding: 28px 16px;
  color: #64748b;
  font-size: 0.88rem;
}

.acc-pay-inline {
  background: #020617;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.acc-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1e293b;
  border: 1px solid rgba(71, 85, 105, 0.75);
  border-radius: 10px;
}

@media (max-width: 960px) {
  .acc-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .acc-two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .accounting-hub-shell {
    padding: 10px 10px 32px;
  }
  .acc-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .acc-subtabs-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .acc-subtab-btn {
    justify-content: center;
    padding: 9px 10px;
    font-size: 0.8rem;
  }
  .acc-form-grid {
    grid-template-columns: 1fr;
  }
  .acc-field.span-2 {
    grid-column: span 1;
  }
  .acc-kpi-value {
    font-size: 1.18rem;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #tab-accounting,
  #tab-accounting * {
    visibility: visible;
  }
  #tab-accounting {
    position: absolute;
    inset: 0;
    background: #ffffff !important;
    color: #0f172a !important;
  }
  .acc-subtabs-bar,
  .acc-toolbar .acc-btn,
  .acc-period-group {
    display: none !important;
  }
}
