/* ============ Reset / Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

/* HTML 'hidden' ozniteligi her zaman gizlesin (display:grid/flex override edemez) */
[hidden] { display: none !important; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; font-size: 15px; }

:root {
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-dark: #3730a3;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warn: #f59e0b;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.18);
}

/* ============ Views ============ */
.view { min-height: 100vh; }

/* ============ Login ============ */
.view-login {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,.25), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(16,185,129,.2), transparent 60%),
    linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #312e81 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px);
  border-radius: 22px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-lg);
}
.brand { text-align: center; margin-bottom: 24px; }
.brand-logo {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  font-size: 30px; font-weight: 800;
  box-shadow: 0 10px 30px rgba(79,70,229,.45);
}
.brand-logo.small { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; box-shadow: 0 6px 16px rgba(79,70,229,.35); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.brand p  { margin: 6px 0 0; color: var(--ink-3); font-size: 14px; }

/* ============ Forms ============ */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}
/* Rakam + Birim (mt/kg) yan yana */
.rakam-wrap { display: flex; gap: 8px; }
.rakam-wrap input { flex: 1; }
.rakam-wrap select {
  flex: 0 0 88px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

/* Textarea (Aciklama) */
.field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); }

/* Readonly text input (otomatik dolan alanlar: tarih/saat) */
.readonly-field {
  background: #f1f5f9 !important;
  color: var(--ink-2) !important;
  cursor: not-allowed;
}
.readonly-field:focus { box-shadow: none !important; border-color: var(--line) !important; }

.hint { color: var(--ink-3); font-size: 12px; }

.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions.end { justify-content: flex-end; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 600; font-size: 14px;
  transition: transform .06s, box-shadow .15s, background .15s, color .15s, border-color .15s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,.45); }
.btn-success {
  color: #fff;
  background: linear-gradient(135deg, var(--success) 0%, #34d399 100%);
  box-shadow: 0 4px 14px rgba(16,185,129,.35);
  flex: 1;
}
.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
  box-shadow: 0 4px 14px rgba(239,68,68,.35);
  flex: 1;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }

.icon-btn {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-3);
  padding: 4px 10px;
  border-radius: 8px;
}
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 22px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.topbar-title { font-weight: 700; color: var(--ink); }
.topbar-user { font-size: 12px; color: var(--ink-3); }
.role-chip {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  background: #eef2ff; color: var(--primary-dark);
  font-weight: 600; font-size: 11px; text-transform: capitalize;
}

.tabs {
  flex: 1; display: flex; gap: 6px; justify-content: center;
  background: #f1f5f9; padding: 4px; border-radius: 12px;
}
.tab {
  border: 0; background: transparent;
  padding: 8px 16px; border-radius: 9px;
  font-weight: 600; font-size: 14px; color: var(--ink-3);
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(15,23,42,.08);
}

/* ============ Content ============ */
.content { padding: 28px 22px 60px; max-width: 1100px; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.page-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.page-head.between { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

/* ============ Cards / Tables ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.form-card { padding: 22px; max-width: 520px; }
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.data-table thead th {
  font-weight: 600;
  color: var(--ink-3);
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table tbody tr:hover { background: #fafbff; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--ink-3); padding: 30px !important; }

/* Status badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-warn::before { background: #f59e0b; }
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-ok::before  { background: #10b981; }

/* Toggle buttons in table */
.btn-toggle {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 9px;
  border: 0;
  color: #fff;
  font-weight: 600;
}
.btn-toggle.red   { background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%); }
.btn-toggle.green { background: linear-gradient(135deg, var(--success) 0%, #34d399 100%); }

/* Role pill in users table */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.pill.admin       { background: #fee2e2; color: #991b1b; }
.pill.muhasebeci  { background: #dbeafe; color: #1e40af; }
.pill.tahsilatci  { background: #d1fae5; color: #065f46; }
.pill.master      { background: #fef3c7; color: #92400e; }
.pill.sip         { background: #ede9fe; color: #5b21b6; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { padding: 7px 12px; font-size: 13px; }

/* ============ Modal ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: pop .15s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; }

/* ============ Messages ============ */
.error-msg, .info-msg {
  padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 500;
}
.error-msg { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.info-msg  { background: #ecfeff; color: #155e75; border: 1px solid #a5f3fc; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #0f172a; color: #fff;
  padding: 11px 18px; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500;
  z-index: 200;
  animation: slideUp .2s ease-out;
}
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ============ Print header (sadece print'te gorunur) ============ */
.print-header { display: none; }
.page-actions { display: flex; gap: 8px; }

/* ============ Print ============ */
@media print {
  .topbar, .tabs, .no-print, .row-actions, .page-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; max-width: none; margin: 0; }
  .page-head h2, .page-head p { display: none; }
  .card { box-shadow: none; border: 1px solid #cbd5e1; }
  .print-header {
    display: block;
    padding: 16px 16px 0;
    border-bottom: 1px solid #cbd5e1;
    margin-bottom: 8px;
  }
  .print-header h2 { margin: 0 0 4px; font-size: 18px; }
  .print-header p { margin: 0 0 12px; color: #475569; font-size: 12px; }
  .data-table th { background: #f8fafc !important; }
  .data-table th, .data-table td { padding: 8px 12px; font-size: 12px; }
}

/* ============ Mobile ============ */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; }          /* menu alt satira tam genislik */
  .content { padding: 18px 14px 48px; }
  .data-table th, .data-table td { padding: 9px 10px; font-size: 13px; }
  .page-head.between { flex-direction: column; align-items: stretch; }
  .form-card { padding: 18px; }
}

/* ====== Mobil: tablolari kart gorunumune cevir (her telefonda tam sigar) ====== */
@media (max-width: 640px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
  }
  .data-table tr:hover { background: #fff; }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 9px 14px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
    font-size: 14px;
  }
  .data-table tr td:last-child { border-bottom: 0; }
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ink-3);
    font-size: 12px;
    text-align: left;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .data-table td:empty { display: none; }
  .data-table td .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  .data-table td.empty { display: block; text-align: center; padding: 24px; }
  .data-table td.empty::before { content: none; }
}
