/* Behin Tarım — Final görsel standardı
   Masaüstü: yoğun, Excel tipi, tek ekran odaklı.
   Mobil: mevcut kart ve dokunma alanları korunur. */
:root {
  --final-grid-border: #8fa8bc;
  --final-grid-border-soft: #b8c7d3;
  --final-grid-head-top: #d9eaf7;
  --final-grid-head-bottom: #c7deef;
  --final-grid-hover: #9fc9e9;
  --final-grid-selected: #7fb7df;
  --final-grid-dirty: #fff0a8;
  --final-grid-focus: #175b8f;
  --final-sticky-bg: #f8fbfd;
}

@media (min-width: 821px) {
  body.compact-backoffice-ui .content {
    padding: 5px 7px 10px;
  }

  body.compact-backoffice-ui .page-head--compact-standard,
  body.compact-backoffice-ui .page-head--compact-title-only {
    gap: 4px 7px;
    margin-bottom: 5px;
    padding: 5px 7px;
    border-radius: 8px;
  }

  body.compact-backoffice-ui .page-head--compact-standard {
    grid-template-columns: minmax(155px, .42fr) minmax(0, 3.58fr);
  }

  body.compact-backoffice-ui .page-head--compact-standard .page-title,
  body.compact-backoffice-ui .page-head--compact-title-only .page-title {
    font-size: clamp(15px, 1.25vw, 19px);
  }

  body.compact-backoffice-ui .global-page-head-extra {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  body.compact-backoffice-ui .global-page-summary.summary-grid {
    flex: 0 0 auto;
    gap: 2px;
    overflow: visible;
  }

  body.compact-backoffice-ui .global-page-summary .summary-card {
    flex: 0 0 auto;
    min-width: 58px;
    padding: 2px 5px;
    border-radius: 5px;
  }

  body.compact-backoffice-ui .global-page-summary .summary-card span {
    font-size: 7.5px;
  }

  body.compact-backoffice-ui .global-page-summary .summary-card strong {
    font-size: 10.5px;
  }

  body.compact-backoffice-ui .global-page-filter-card {
    flex: 1 1 auto;
    min-width: 420px;
    padding: 2px 4px;
    border-radius: 6px;
  }

  body.compact-backoffice-ui .global-page-filter-card .page-toolbar,
  body.compact-backoffice-ui .global-page-filter-card .filter-form,
  body.compact-backoffice-ui .global-page-filter-card form[class*="filter"] {
    gap: 2px;
    flex-wrap: nowrap;
  }

  body.compact-backoffice-ui .global-page-filter-card label {
    flex: 1 1 95px;
    min-width: 76px;
  }

  body.compact-backoffice-ui .global-page-filter-card label > span {
    font-size: 7.5px;
  }

  body.compact-backoffice-ui .global-page-filter-card input,
  body.compact-backoffice-ui .global-page-filter-card select,
  body.compact-backoffice-ui .global-page-filter-card textarea,
  body.compact-backoffice-ui .global-page-filter-card .btn,
  body.compact-backoffice-ui .global-page-filter-card button {
    min-height: 24px;
    height: 24px;
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 8.5px;
  }

  body.compact-backoffice-ui .card {
    margin-bottom: 5px;
    padding: 5px 7px;
    border-radius: 7px;
    box-shadow: none;
  }

  body.compact-backoffice-ui .section-title-row {
    min-height: 20px;
    margin-bottom: 3px;
  }

  body.compact-backoffice-ui .section-title-row h2,
  body.compact-backoffice-ui .card h2 {
    font-size: 12px;
  }

  body.compact-backoffice-ui input,
  body.compact-backoffice-ui select,
  body.compact-backoffice-ui textarea,
  body.compact-backoffice-ui .form-control {
    min-height: 26px;
    padding: 2px 5px;
    border-radius: 5px;
    font-size: 9.5px;
  }

  body.compact-backoffice-ui .btn,
  body.compact-backoffice-ui .button,
  body.compact-backoffice-ui .btn-small {
    min-height: 25px;
    padding: 3px 6px;
    border-radius: 5px;
    font-size: 9px;
  }

  body.compact-backoffice-ui .table-wrap,
  body.compact-backoffice-ui .data-table-container,
  body.compact-backoffice-ui .y01-matrix-wrap,
  body.compact-backoffice-ui .milk-matrix-wrap,
  body.compact-backoffice-ui .s04-entry-wrap,
  body.compact-backoffice-ui .s04-responsive-table {
    max-height: calc(100dvh - 170px);
    overflow: auto;
    border-radius: 3px !important;
    scrollbar-width: thin;
  }

  body.compact-backoffice-ui .sticky-actions,
  body.compact-backoffice-ui .sticky-action-bar,
  body.compact-backoffice-ui .mobile-action-bar,
  body.compact-backoffice-ui .s04-action-bar {
    position: sticky;
    bottom: 2px;
    z-index: 24;
    margin-top: 3px;
    padding: 3px 5px;
    border: 1px solid #9fb4c5;
    border-radius: 6px;
    background: rgb(255 255 255 / 0.96);
    box-shadow: 0 -2px 8px rgb(15 23 42 / .10);
    backdrop-filter: blur(5px);
  }
}

/* Tek ortak Excel tablo standardı */
.table-wrap,
.data-table-container,
.y01-matrix-wrap,
.milk-matrix-wrap,
.s04-entry-wrap,
.s04-responsive-table {
  border: 1px solid var(--final-grid-border) !important;
}

table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

table th,
table td {
  border-right: 1px solid var(--final-grid-border-soft) !important;
  border-bottom: 1px solid var(--final-grid-border-soft) !important;
  text-align: center !important;
  vertical-align: middle !important;
}

table tr > :first-child {
  border-left: 0 !important;
}

table thead tr:first-child > * {
  border-top: 0 !important;
}

.table-wrap table thead th,
.data-table-container table thead th,
.y01-matrix-wrap table thead th,
.milk-matrix-wrap table thead th,
.s04-entry-wrap table thead th,
.s04-responsive-table table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  color: #17324f !important;
  background: linear-gradient(180deg, var(--final-grid-head-top), var(--final-grid-head-bottom)) !important;
  font-weight: 800;
}

@media (min-width: 821px) {
  body.compact-backoffice-ui table th,
  body.compact-backoffice-ui table td {
    height: 27px;
    padding: 2px 4px !important;
    font-size: 9.5px;
    line-height: 1.08;
  }

  body.compact-backoffice-ui table thead th {
    height: 29px;
    font-size: 9px;
  }

  body.compact-backoffice-ui table td input:not([type="checkbox"]):not([type="radio"]),
  body.compact-backoffice-ui table td select,
  body.compact-backoffice-ui table td textarea {
    min-height: 23px;
    height: 23px;
    padding: 1px 4px;
    font-size: 9px;
    text-align: center !important;
    text-align-last: center;
  }
}

table tbody tr:hover > td,
table tbody tr:hover > th {
  background: var(--final-grid-hover) !important;
}

table tbody tr.is-row-selected > td,
table tbody tr.is-row-selected > th {
  background: var(--final-grid-selected) !important;
  box-shadow: inset 0 1px 0 #3d7ead, inset 0 -1px 0 #3d7ead;
}

table input:focus,
table select:focus,
table textarea:focus {
  position: relative;
  z-index: 12;
  outline: 2px solid var(--final-grid-focus) !important;
  outline-offset: -1px;
  border-color: var(--final-grid-focus) !important;
  box-shadow: none !important;
}

table input.is-dirty,
table select.is-dirty,
table textarea.is-dirty,
table .is-dirty input,
table .is-dirty select,
table .is-dirty textarea,
table tr.has-unsaved input:not(:disabled) {
  color: #5c4300 !important;
  border-color: #d5a500 !important;
  background: var(--final-grid-dirty) !important;
  box-shadow: inset 0 0 0 1px #d5a500 !important;
}

/* Genel otomatik sabit kimlik kolonları. Özel S01/Y01/S04 kolonları kendi kurallarını korur. */
table .is-sticky-identity {
  position: sticky !important;
  left: var(--sticky-left, 0px) !important;
  z-index: 6;
  background: var(--final-sticky-bg) !important;
  box-shadow: 1px 0 0 var(--final-grid-border);
}

table thead .is-sticky-identity {
  z-index: 12;
  background: linear-gradient(180deg, var(--final-grid-head-top), var(--final-grid-head-bottom)) !important;
}

table tbody tr:hover > .is-sticky-identity {
  background: var(--final-grid-hover) !important;
}

table tbody tr.is-row-selected > .is-sticky-identity {
  background: var(--final-grid-selected) !important;
}

/* Uzun adlar satırı büyütmez; tam metin tarayıcı ipucunda görünür. */
table .is-truncated-cell {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

/* Sayısal alanlar ve tablo içi kontroller Excel gibi ortalı. */
table [data-type="number"],
table .u-text-right,
table .text-right,
table .money-cell,
table .quantity-value,
table td input:not([type="checkbox"]):not([type="radio"]),
table td select,
table td textarea {
  text-align: center !important;
}

/* Başlık altındaki tekrar bilgi alanları yerine yalnız gerçek uyarılar görünür. */
body.compact-backoffice-ui .y01-note,
body.compact-backoffice-ui .s04-help,
body.compact-backoffice-ui .scale-note {
  display: none !important;
}

@media (max-width: 820px) {
  table .is-sticky-identity {
    position: static !important;
    box-shadow: none;
  }

  table th,
  table td {
    text-align: center !important;
  }
}


/* Kapalı ve kesin kilitli dönemler görünür kalır; dönemsel veriler kırmızı görünür.
   Bu yalnız görsel durumdur. Yazma yetkisini merkezi dönem/modül kilidi belirler. */
.working-period-field--closed > span,
.working-period-field--locked > span,
body.period-status-closed .working-period-field > span,
body.period-status-locked .working-period-field > span {
  color: #991b1b !important;
}

.working-period-field--closed input[readonly],
.working-period-field--locked input[readonly],
body.period-status-closed .working-period-field input[readonly],
body.period-status-locked .working-period-field input[readonly] {
  color: #991b1b !important;
  border-color: #dc2626 !important;
  background: #fee2e2 !important;
  font-weight: 900 !important;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .18) !important;
}

body.period-status-closed .content table tbody td,
body.period-status-locked .content table tbody td,
body.period-status-closed .content .mobile-card,
body.period-status-locked .content .mobile-card {
  color: #991b1b !important;
  background: #fff1f2 !important;
  border-color: #fecaca !important;
}

body.period-status-closed .content table tbody td a,
body.period-status-locked .content table tbody td a,
body.period-status-closed .content table tbody td strong,
body.period-status-locked .content table tbody td strong {
  color: #991b1b !important;
}

body.period-status-closed .content table input,
body.period-status-closed .content table select,
body.period-status-closed .content table textarea,
body.period-status-closed .content .form-grid input:not([type="hidden"]),
body.period-status-closed .content .form-grid select,
body.period-status-closed .content .form-grid textarea,
body.period-status-locked .content table input,
body.period-status-locked .content table select,
body.period-status-locked .content table textarea,
body.period-status-locked .content .form-grid input:not([type="hidden"]),
body.period-status-locked .content .form-grid select,
body.period-status-locked .content .form-grid textarea {
  color: #991b1b !important;
  border-color: #ef4444 !important;
  background: #fee2e2 !important;
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .12) !important;
}

body.period-status-closed .content table input:disabled,
body.period-status-closed .content table select:disabled,
body.period-status-closed .content table textarea:disabled,
body.period-status-locked .content table input:disabled,
body.period-status-locked .content table select:disabled,
body.period-status-locked .content table textarea:disabled {
  opacity: 1 !important;
  -webkit-text-fill-color: #991b1b !important;
}

body.period-status-closed .content .badge.ok,
body.period-status-closed .content .status-badge--success,
body.period-status-locked .content .badge.ok,
body.period-status-locked .content .status-badge--success {
  color: #991b1b !important;
  border-color: #fecaca !important;
  background: #fee2e2 !important;
}

body.period-status-closed .content .summary-card,
body.period-status-locked .content .summary-card,
body.period-status-closed .content .global-page-filter-card,
body.period-status-locked .content .global-page-filter-card {
  color: #991b1b !important;
  border-color: #ef4444 !important;
  background: #fff1f2 !important;
}

body.period-status-closed .content .summary-card span,
body.period-status-closed .content .summary-card strong,
body.period-status-closed .content .summary-card small,
body.period-status-locked .content .summary-card span,
body.period-status-locked .content .summary-card strong,
body.period-status-locked .content .summary-card small {
  color: #991b1b !important;
}

body.period-status-closed .content .kpi strong,
body.period-status-closed .content .mini-card strong,
body.period-status-closed .content .hero-card strong,
body.period-status-closed .content .numeric-value,
body.period-status-locked .content .kpi strong,
body.period-status-locked .content .mini-card strong,
body.period-status-locked .content .hero-card strong,
body.period-status-locked .content .numeric-value {
  color: #991b1b !important;
}
