:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff4ff;
    --bg: #f3f4f6;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;
    --gray: #6b7280;
    --gray-bg: #e5e7eb;
    --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

/* ---- Icons ---- */
.icon { vertical-align: -0.18em; flex-shrink: 0; }

/* ---- Header / Nav ---- */
header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
    box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.logo-icon { display: inline-flex; color: var(--primary); }
.logo-img { height: 56px; width: auto; display: block; }
.logo-fallback { font-weight: 700; font-size: 1.05rem; color: var(--text); }

/* ---- User menu / dropdown ---- */
.user-menu { position: relative; }
.user-chip {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 6px 10px 6px 7px; border-radius: 999px;
    border: 1px solid var(--border); background: #fff; cursor: pointer;
    font-size: .92rem; font-weight: 500; color: var(--text);
}
.user-chip:hover { background: var(--bg); }
.user-chip .avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
}
.user-chip .caret { display: inline-flex; color: var(--muted); transition: transform .15s; }
.user-menu.open .user-chip .caret { transform: rotate(180deg); }

.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 210px; background: #fff;
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 8px 24px rgba(16,24,40,.12); padding: 6px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .14s, transform .14s, visibility .14s; z-index: 30;
}
.user-menu.open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    text-decoration: none; color: var(--text); font-size: .92rem; font-weight: 500;
}
.user-dropdown a .icon { color: var(--muted); }
.user-dropdown a:hover { background: var(--bg); }
.user-dropdown a.active { background: var(--primary-soft); color: var(--primary); }
.user-dropdown a.active .icon { color: var(--primary); }

main.container { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 14px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- Search box ---- */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-box input {
    height: 40px; width: 230px; padding: 0 12px 0 35px;
    border: 1px solid var(--border); border-radius: 8px; font-size: .92rem; font-family: inherit;
    background: #fff; color: var(--text); -webkit-appearance: none; appearance: none;
    transition: border-color .12s, box-shadow .12s;
}
.search-box input::placeholder { color: #9ca3af; }
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
h1 { display: inline-flex; align-items: center; gap: 10px; font-size: 1.5rem; margin: 0; font-weight: 700; }
h1 .icon { color: var(--primary); }
h3 { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 1.05rem; }
h3 .icon { color: var(--muted); }

.lead { color: var(--muted); margin-top: 0; }

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem; font-weight: 500;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; background: #fff; }
.data-table th, .data-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { background: #fafafa; font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cell-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.cell-link:hover { text-decoration: underline; }
.data-table td form { display: inline; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 9px 4px; border-bottom: 1px solid var(--border); }
.info-table tr:last-child td { border-bottom: none; }
.info-table td:first-child { color: var(--muted); width: 38%; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 11px; border-radius: 20px; font-size: .82rem; font-weight: 600; line-height: 1.5; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ---- Stat cards ---- */
.cards-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 170px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card.accent { border-color: var(--primary); background: var(--primary-soft); }
.stat-label { display: block; color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat-value { display: block; font-size: 2rem; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.stat-value small { font-size: .9rem; font-weight: 500; color: var(--muted); margin-left: 5px; }
.stat-value.neg { color: var(--red); }

/* ---- Forms ---- */
.form-row { margin-bottom: 17px; display: flex; flex-direction: column; }
.form-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 7px; font-size: .9rem; }
.form-row label .icon { color: var(--muted); }
.form-row input[type=text], .form-row input[type=date], .form-row input[type=number],
.form-row input[type=password], .form-row select, .form-row textarea {
    padding: 0 12px; height: 42px; border: 1px solid var(--border); border-radius: 8px;
    font-size: .95rem; background: #fff; color: var(--text); width: 100%; font-family: inherit;
    -webkit-appearance: none; appearance: none; transition: border-color .12s, box-shadow .12s;
}
.form-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; cursor: pointer;
}
.form-row textarea { height: auto; padding: 10px 12px; min-height: 84px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row input::placeholder { color: #9ca3af; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.checkbox-row label { flex-direction: row; align-items: center; font-weight: 400; gap: 8px; }
.checkbox-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.hint { color: var(--muted); font-size: .8rem; margin-top: 5px; font-weight: 400; }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.flash-error { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.flash-warning { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon { color: var(--border); margin-bottom: 12px; }
.empty p { margin-bottom: 16px; }
.empty .btn { display: inline-flex; }

.danger-zone { border-color: #fecaca; }
.back-link a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--primary); }

.dropdown-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Login ---- */
main.login-page { display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 62px); padding-top: 0; padding-bottom: 0; }
.login-wrap { display: flex; justify-content: center; width: 100%; }
.login-card { width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-icon { display: inline-flex; color: var(--primary); }
.login-logo-img { height: 60px; width: auto; margin: 0 auto 14px; display: block; }
.login-sub { font-weight: 700; font-size: 1.1rem; margin: 0 0 4px; }
.login-note { margin-top: 16px; text-align: center; }

/* ---- Balance formula strip ---- */
.balance-formula { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 22px; }
.bf-item { color: var(--muted); font-size: .92rem; }
.bf-item strong { color: var(--text); font-size: 1.05rem; }
.bf-op { color: var(--muted); font-weight: 700; }
.bf-result { color: var(--primary); }
.bf-result strong { color: var(--primary); font-size: 1.15rem; }

/* ---- Inline edit (devreden) ---- */
.inline-edit { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-edit input { height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px;
    font-size: .92rem; font-family: inherit; background: #fff; color: var(--text);
    -webkit-appearance: none; appearance: none; }
.inline-edit input[type=number] { width: 90px; }
.inline-edit input[type=text] { width: 160px; }
.inline-edit input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.inline-edit span { color: var(--muted); font-size: .88rem; }

/* ---- File input ---- */
.form-row input[type=file] {
    padding: 11px 12px; border: 1px dashed var(--border); border-radius: 8px;
    background: #fafafa; width: 100%; font-family: inherit; font-size: .9rem; color: var(--muted); cursor: pointer;
}
.form-row input[type=file]::file-selector-button {
    margin-right: 12px; padding: 7px 13px; border: 1px solid var(--border); border-radius: 7px;
    background: #fff; color: var(--text); font-family: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
}
.form-row input[type=file]::file-selector-button:hover { background: var(--bg); }

/* ---- Error list ---- */
.hata-listesi { margin: 8px 0 16px; padding-left: 20px; color: var(--amber); font-size: .9rem; }
.hata-listesi li { margin-bottom: 4px; }

footer { border-top: 1px solid var(--border); padding: 20px 0; background: #fff; text-align: center; }
.footer-link { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.footer-link:hover { color: var(--primary); }

@media (max-width: 680px) {
    .container { padding: 0 16px; }
    .header-inner { padding: 9px 16px; }
    .logo { font-size: 1rem; gap: 7px; }
    .logo-img { height: 44px; }
    .user-chip { padding: 5px 9px 5px 6px; }
    .user-chip .user-name { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    main.container { padding-top: 18px; padding-bottom: 40px; }
    h1 { font-size: 1.22rem; }
    .page-head { margin-bottom: 18px; gap: 12px; }
    .card { padding: 18px 16px; }

    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .form-actions .btn { flex: 1; justify-content: center; }

    .head-actions { width: 100%; }
    .search-box { flex: 1; }
    .search-box input { width: 100%; }

    /* İstatistik kartları telefonda 2'şerli */
    .cards-row { gap: 10px; }
    .stat-card { flex: 1 1 calc(50% - 5px); min-width: calc(50% - 5px); padding: 14px 16px; }
    .stat-value { font-size: 1.6rem; }

    .user-dropdown { min-width: 200px; }
    .login-wrap { padding-top: 8px; }
}

@media (max-width: 380px) {
    .stat-card { flex-basis: 100%; min-width: 100%; }
}
