/* ==========================================================================
   TriOffer — uygulama stili (bağımlılıksız, tek dosya)
   ========================================================================== */

:root {
  --primary: #0f2a43;
  --primary-soft: #16395a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0891b2;
  --info-bg: #ecfeff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 1.02rem; }
p { margin: 0 0 .6em; }
p:last-child { margin-bottom: 0; }
img { max-width: 100%; }
.muted { color: var(--muted); font-weight: 400; }
.link { font-weight: 600; }
.hint { color: var(--muted); font-size: .88rem; margin: 0 0 12px; }
.pre-line { white-space: pre-line; }
.inline { display: inline-block; }
.pad-x { padding: 0 18px; }

/* ------------------------------ Yerleşim ------------------------------ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--primary);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; flex-shrink: 0;
}
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section {
  padding: 14px 10px 6px;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #64748b;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: 8px;
  color: #cbd5e1; font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-label { white-space: nowrap; overflow: hidden; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.active svg { opacity: 1; }

.sidebar-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; color: #e2e8f0; min-width: 0;
}
.user-chip:hover, .user-chip.active { background: rgba(255,255,255,.08); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); border: 1px solid rgba(255,255,255,.15);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; color: #94a3b8; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 13px 26px;
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.12rem; }
.menu-toggle { display: none; }
.content { padding: 24px 26px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ------------------------------ Kartlar ------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-narrow { max-width: 680px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 18px; }
.card-narrow > form { padding: 18px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stack > * + * { margin-top: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2 > *, .grid-4 > *, .stat-grid > *, .filter-form > * { min-width: 0; }
.align-start { align-items: start; }

/* --------------------------- İstatistik kartları ---------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-warning { border-left-color: var(--warning); }
.stat-success { border-left-color: var(--success); }
.stat-danger  { border-left-color: var(--danger); }
.stat-info    { border-left-color: var(--info); }
.stat-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-value { font-size: 1.65rem; font-weight: 750; line-height: 1.2; }
.stat-sub   { font-size: .82rem; color: var(--muted); }

/* ------------------------------ Tablolar ------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; }
thead th {
  font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-num { text-align: right; }
.col-x { width: 1%; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline-block; }
tfoot td { border-top: 1px solid var(--border); padding: 8px 14px; }
.tf-label { font-weight: 600; color: var(--muted); }
.tf-grand td { border-top: 2px solid var(--primary); font-weight: 750; font-size: 1.02rem; background: #f8fafc; }
.tf-grand .tf-label { color: var(--text); }

/* ------------------------------ Rozetler ------------------------------ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem; font-weight: 650;
  white-space: nowrap;
}
.badge-lg { font-size: .85rem; padding: 4px 13px; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: #f1f5f9;           color: var(--muted); }

/* ------------------------------ Butonlar ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .88rem; font-weight: 600;
  cursor: pointer;
  background: none;
  font-family: inherit;
  line-height: 1.3;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f8fafc; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.94); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-danger-ghost { background: var(--surface); border-color: var(--border); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: #fecaca; }
.btn-sm { padding: 4px 10px; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: none; color: inherit; cursor: pointer;
  font-size: 1.1rem; line-height: 1;
}
.btn-icon svg { width: 18px; height: 18px; }
.sidebar .btn-icon { color: #94a3b8; }
.sidebar .btn-icon:hover { background: rgba(255,255,255,.08); color: #fff; }
.content .btn-icon:hover { background: #f1f5f9; }

/* ------------------------------ Formlar ------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: .82rem; font-weight: 600; color: #334155; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .35);
  outline-offset: 0;
  border-color: var(--accent);
}
input[type="file"] { font-size: .86rem; }
.field-error { color: var(--danger); font-size: .8rem; margin: 0; }
.field-row { display: flex; gap: 8px; }
.field-row > select { flex: 1; }
.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 4px;
}
.check-list { display: flex; flex-direction: column; gap: 7px; }
.check {
  display: flex; align-items: flex-start; gap: 8px;
  font-weight: 400; font-size: .9rem; cursor: pointer;
}
.check input { width: auto; margin-top: 2px; }

.search-form { display: flex; gap: 8px; flex: 1; max-width: 520px; }
.search-form input[type="search"] { flex: 1; }
.select-auto { width: auto; }
.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.field-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --------------------------- Teklif formu ----------------------------- */
.items-table input { min-width: 0; }
.items-table .num-input { width: 110px; text-align: right; }
.items-table td { padding: 7px 8px; }
.items-table thead th { padding: 10px 8px; }

/* --------------------------- Kart bilgi notu -------------------------- */
.card-note {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.55;
}
.card-note svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }

/* ------------------------------ Flash --------------------------------- */
.flashes { margin-bottom: 18px; }
.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid;
  margin-bottom: 8px;
  font-weight: 500;
  transition: opacity .4s, transform .4s;
}
.flash-hide { opacity: 0; transform: translateY(-4px); }
.flash-success { background: var(--success-bg); border-color: #bbf7d0; color: #166534; }
.flash-error   { background: var(--danger-bg);  border-color: #fecaca; color: #991b1b; }
.flash-close {
  border: 0; background: none; cursor: pointer;
  font-size: 1.2rem; line-height: 1; color: inherit; opacity: .6; padding: 0 2px;
}
.flash-close:hover { opacity: 1; }

/* ------------------------- Detay / çeşitli ---------------------------- */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px 18px; }
.detail-title { display: flex; align-items: center; gap: 12px; }
.detail-title h2 { font-size: 1.25rem; }
.status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 11px 18px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 7px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.logo-preview img, .signature-preview img {
  max-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

/* ------------------------------ Giriş --------------------------------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(150deg, var(--primary) 0%, #1e3a5f 55%, #274b79 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(2, 8, 20, .45);
  padding: 34px 32px 26px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { width: 46px; height: 46px; font-size: 1.4rem; border-radius: 12px; margin-bottom: 10px; }
.login-brand h1 { font-size: 1.3rem; }
.login-foot { text-align: center; margin-top: 22px; font-size: .8rem; }

/* --------------------------- Rapor grafikleri ------------------------- */
.chart { width: 100%; height: auto; display: block; }
.cbar  { fill: var(--accent); }
.cbar:hover { fill: var(--accent-hover); }
.caxis { stroke: var(--border); stroke-width: 1; }
.camt  { font-size: 11px; font-weight: 700; fill: #334155; text-anchor: middle; }
.clab  { font-size: 10px; fill: var(--muted); text-anchor: middle; }
.ccnt  { font-size: 9px;  fill: #94a3b8; text-anchor: middle; }
.bar-cell { width: 120px; }
.minibar { display: block; }
.minibar-bg { fill: #eef2f7; }
.minibar-fg { fill: var(--accent); }
.color-input { padding: 3px; height: 38px; cursor: pointer; }

/* ----------------------- Masaüstü daraltılmış menü -------------------- */
.sidebar { transition: width .18s ease; }
@media (min-width: 861px) {
  body.sidebar-collapsed .sidebar { width: 70px; overflow: hidden; }
  body.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-section,
  body.sidebar-collapsed .user-meta { display: none; }
  body.sidebar-collapsed .nav-link { justify-content: center; padding: 11px 0; gap: 0; }
  body.sidebar-collapsed .nav-link svg { width: 20px; height: 20px; }
  body.sidebar-collapsed .sidebar-foot { flex-direction: column; gap: 8px; padding: 10px 6px; }
  body.sidebar-collapsed .user-chip { justify-content: center; padding: 6px; }
}

/* ----------------------------- Duyarlılık ----------------------------- */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .content { padding: 18px 16px 40px; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(2, 8, 20, .4);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 120px 1fr; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  th, td { padding: 8px 10px; }
}
