body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}

.topbar {
    background: #0f172a;
    color: white;
    padding: 12px 0;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.brand-sub {
    font-size: 12px;
    color: #cbd5e1;
}

.topbar a {
    color: #ffffff;
    margin-left: 8px;
    text-decoration: none;
    background: #1d4ed8;
    padding: 8px 10px;
    border-radius: 8px;
    display: inline-block;
    font-size: 13px;
}

.topbar a:hover {
    background: #1e40af;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar nav form {
    margin: 0;
}

.topbar nav form button {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    background: #0f766e;
}

.card {
    background: #ffffff;
    border-radius: 10px;
    padding: 16px;
    margin: 14px 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-card {
    max-width: 420px;
    margin: 30px auto;
}

.grid {
    display: grid;
    gap: 12px;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 5px;
    font-size: 14px;
}

input, select, button {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 14px;
}

button {
    background: #1d4ed8;
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background: #1e40af;
}

.danger {
    background: #dc2626;
}

.danger:hover {
    background: #991b1b;
}

.alert {
    padding: 10px;
    border-radius: 8px;
    margin: 8px 0 14px;
}

.alert.success {
    background: #dcfce7;
}

.alert.error {
    background: #fee2e2;
}

.links {
    margin-top: 10px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.button-link {
    background: #0ea5e9;
    color: white;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    display: inline-block;
}

.button-link.mini {
    padding: 6px 10px;
    font-size: 12px;
}

.edit-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.edit-actions .button-link {
    margin: 0;
}

.danger-link {
    background: #dc2626;
}

.danger-link:hover {
    background: #991b1b;
}

.success-btn {
    background: #16a34a;
}

.success-btn:hover {
    background: #15803d;
}

/* Son Kayıtlar / Dönem Kayıtları: Sil ve Düzenle aynı yükseklikte, yazı biraz daha küçük */
table .button-link.mini,
table button.danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 25px;
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
}

table form {
    margin: 0;
    display: inline;
}

.import-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.import-form input[type="file"] {
    font-size: 13px;
    background: #fff;
    border: 1px solid #cbd5e1;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.admin-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-export-bar {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.admin-sign-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 8px;
}

.admin-filter-bar {
    margin: 0 0 8px 0;
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.admin-filter-bar .filter-col-daire,
.admin-filter-bar .filter-col-sube {
    min-width: 300px;
    flex: 1 1 320px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}

.admin-filter-bar .filter-col-daire select,
.admin-filter-bar .filter-col-sube select {
    width: 100%;
    min-width: 100%;
    box-sizing: border-box;
    display: block;
}

.permission-section {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}

.permission-check-grid {
    display: grid;
    gap: 8px;
}

.permission-check-grid label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.selectable-row.selected-row td {
    background: #e0f2fe !important;
    border-color: #7dd3fc;
}

.row-menu {
    position: relative;
}

.row-menu summary {
    list-style: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    user-select: none;
}

.row-menu summary::-webkit-details-marker {
    display: none;
}

.row-menu-panel {
    position: absolute;
    right: 0;
    top: 22px;
    z-index: 30;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 6px;
    min-width: 150px;
}

.row-options-btn {
    background: #0f172a;
    color: #fff;
    border-radius: 8px;
    padding: 3px 10px;
    font-size: 18px;
    line-height: 1;
}

.row-options-dialog {
    border: none;
    border-radius: 10px;
    padding: 14px;
    width: min(92vw, 360px);
}

.row-options-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.row-options-dialog h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.row-options-actions {
    display: grid;
    gap: 8px;
}

.row-options-actions .button-link,
.row-options-actions form button {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    min-height: 34px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px;
    line-height: 1 !important;
    padding: 0 10px !important;
}

/* Hidden attribute'u modal buton stilleri override etmesin */
.row-options-actions [hidden] {
    display: none !important;
}

.row-options-actions form {
    margin: 0;
}

.row-options-footer {
    margin-top: 10px;
    text-align: right;
}

.row-options-footer button {
    background: #dc2626;
}

.row-options-footer button:hover {
    background: #991b1b;
}

.compare-chart {
    display: grid;
    gap: 8px;
}

.compare-row {
    display: grid;
    gap: 4px;
}

.compare-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.compare-label {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compare-label span {
    font-weight: 400;
    color: #475569;
}

.compare-bar-wrap {
    height: 18px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.compare-bar {
    height: 100%;
    border-radius: 999px;
}

.compare-bar.period {
    background: linear-gradient(90deg, #2563eb, #38bdf8);
}

.compare-bar.year {
    background: linear-gradient(90deg, #7c3aed, #c084fc);
}

.compare-value {
    text-align: right;
    font-weight: 700;
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.recent-scroll {
    max-height: 480px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 900px;
}

th, td {
    border: 1px solid #e2e8f0;
    padding: 5px;
    text-align: center;
    vertical-align: middle;
    font-size: 14px;
    line-height: 1.15;
    white-space: nowrap;
}

table.compact-table th,
table.compact-table td {
    padding: 2px 3px;
    font-size: 12px;
    line-height: 1.1;
}

/* Son Kayıtlar / Dönem Kayıtları başlık satırı: yüksek, belirgin ve sticky */
table.compact-table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: 9px;
    padding-bottom: 9px;
    background: linear-gradient(180deg, #ffffff 0%, #eaf2ff 100%);
    box-shadow: inset 0 1px 0 #ffffff, inset 0 -1px 0 #cbd5e1, 0 2px 6px rgba(15, 23, 42, 0.12);
    font-weight: 700;
}

.period-row td {
    background: #eaf2ff;
    font-weight: 700;
}

code {
    display: block;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 10px;
    overflow-x: auto;
}

.entry-form input,
.entry-form select,
.entry-form button {
    font-size: 14px;
    font-family: Arial, sans-serif;
    font-weight: 400;
}

.entry-spacer {
    visibility: hidden;
}

.totals-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.totals-grid .card {
    margin: 0;
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .topbar .container {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .topbar nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    .topbar a {
        margin-left: 0;
    }

    .header-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .mobile-entry-form.two-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Mobilde ilk alan (Tarih) tek satır olsun */
    .mobile-entry-form > label:first-of-type {
        grid-column: 1 / -1;
    }

    .reports-filter-form.two-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .full {
        grid-column: auto;
    }

    .mobile-entry-form .full,
    .reports-filter-form .full {
        grid-column: 1 / -1;
    }

    .entry-spacer {
        display: none;
    }

    .card {
        padding: 12px;
        margin: 10px 0;
    }

    th, td {
        font-size: 12px;
        padding: 4px;
    }

    table.compact-table th,
    table.compact-table td {
        padding: 2px 2px;
        font-size: 10px;
        line-height: 1.05;
    }

    table.compact-table thead th {
        top: 0;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    table .button-link.mini,
    table button.danger {
        height: 23px;
        padding: 1px 7px;
        font-size: 10px;
        line-height: 1;
    }

    table.compact-table {
        min-width: 640px;
    }

    .recent-scroll {
        max-height: 560px;
    }

    .button-link {
        padding: 8px 10px;
    }

    .totals-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .compare-row {
        gap: 4px;
    }

    .admin-sign-grid {
        grid-template-columns: 1fr;
    }

    .admin-filter-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: stretch;
    }

    .admin-filter-bar .filter-col-daire,
    .admin-filter-bar .filter-col-sube,
    .admin-filter-bar .filter-col-daire select,
    .admin-filter-bar .filter-col-sube select {
        width: 100%;
        min-width: 0;
    }

    /* Mobilde imza alanlarini istenen sirayla alt alta diz */
    .admin-sign-grid {
        grid-template-columns: 1fr;
    }
    .admin-sign-grid label:nth-child(1) { order: 1; } /* Sef Unvan */
    .admin-sign-grid label:nth-child(4) { order: 2; } /* Sef Ad Soyad */
    .admin-sign-grid label:nth-child(2) { order: 3; } /* Mudur Unvan */
    .admin-sign-grid label:nth-child(5) { order: 4; } /* Mudur Ad Soyad */
    .admin-sign-grid label:nth-child(3) { order: 5; } /* Daire Baskani Unvan */
    .admin-sign-grid label:nth-child(6) { order: 6; } /* Daire Baskani Ad Soyad */

    .compare-value {
        text-align: right;
    }

    .totals-grid .card {
        padding: 8px;
    }

    .totals-grid h3 {
        font-size: 14px;
        margin: 0 0 6px 0;
    }

    .totals-grid p {
        font-size: 12px;
        margin: 4px 0;
    }
}
