:root {
  /* Mountain Air paleti — ANA TEMA: yeşil */
  --green-900: #212e1a; /* çok koyu yeşil (sidebar) */
  --green-800: #35472a; /* koyu yeşil */
  --green-700: #4c6039; /* orta koyu yeşil (metin) */
  --green-600: #778c58; /* zeytin (ana yeşil) */
  --green-500: #7f9a83; /* adaçayı */
  --lime: #7f9a83;      /* yeşil vurgu */
  --lime-soft: #e4ebd9; /* yumuşak yeşil */
  --cream: #f6f8f3;
  --sand: #eaf0e2;
  --ink: #1f2b18;
  --muted: #647159;
  --border: #dfe6d6;
  --white: #fff;
  /* DETAY/AKSAN: mavi-teal */
  --accent: #254b5a;
  --accent-2: #33627a;
  --accent-dark: #082434;
  --accent-light: #99bad7;
  --accent-soft: #d4e1e7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 16px 40px -20px rgba(33, 46, 26, 0.30);
  --shadow-soft: 0 8px 24px -14px rgba(76, 96, 57, 0.24);
  --red: #d9534f;
  --amber: #e6a817;
  --blue: #2f80ed;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brandy { font-family: 'Space Grotesk', sans-serif; }
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; border: 1.5px solid transparent; cursor: pointer; transition: all .2s; }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn--primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn--ghost { background: #fff; color: var(--accent); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); }
.btn--danger { background: #fff; color: var(--red); border-color: #f2c7c5; }
.btn--danger:hover { background: var(--red); color: #fff; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(60% 60% at 80% 10%, rgba(127,154,131,.42), transparent 70%), radial-gradient(50% 50% at 10% 30%, rgba(153,186,215,.28), transparent 70%), linear-gradient(180deg, var(--sand), var(--cream)); }
.login__card { background: #fff; padding: 40px; border-radius: 22px; box-shadow: var(--shadow); width: 100%; max-width: 400px; }
.login__brand { font-family: 'Space Grotesk'; font-weight: 700; font-size: 24px; color: var(--green-800); margin-bottom: 24px; }
.login__card h1 { font-size: 24px; color: var(--green-900); }
.login__sub { color: var(--muted); margin-bottom: 24px; font-size: 15px; }
.login__err { color: var(--red); font-size: 14px; margin-top: 12px; text-align: center; min-height: 18px; }
.login__hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ---------- Fields ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--green-800); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14.5px; background: var(--cream); transition: border-color .2s, background .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green-500); background: #fff; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

.sidebar { background: var(--green-900); color: rgba(255,255,255,.85); display: flex; flex-direction: column; padding: 24px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { font-family: 'Space Grotesk'; font-weight: 700; font-size: 22px; color: #fff; padding: 0 10px 26px; }
.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.menu__item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: none; color: rgba(255,255,255,.8); border-radius: var(--radius-sm); cursor: pointer; font-size: 15px; font-weight: 500; text-align: left; transition: all .2s; }
.menu__item span { font-size: 17px; }
.menu__item:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu__item.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.sidebar__foot { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar__site { font-size: 14px; padding: 10px 14px; border-radius: var(--radius-sm); transition: background .2s; }
.sidebar__site:hover { background: rgba(255,255,255,.08); }
.sidebar__logout { background: rgba(255,255,255,.08); border: none; color: #fff; padding: 11px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 14px; transition: background .2s; }
.sidebar__logout:hover { background: var(--red); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 30px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h2 { font-size: 20px; color: var(--green-900); flex: 1; }
.topbar__menu { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--green-800); }
.topbar__user { font-size: 14px; color: var(--muted); font-weight: 500; }

.content { padding: 30px; flex: 1; }

/* ---------- Cards / stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 28px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.stat__ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 20px; background: var(--lime-soft); margin-bottom: 14px; }
.stat__num { font-family: 'Space Grotesk'; font-size: 28px; font-weight: 700; color: var(--green-900); }
.stat__lbl { color: var(--muted); font-size: 14px; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel__head h3 { font-size: 18px; color: var(--green-900); }
.panel__body { padding: 22px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 18px; font-size: 14.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--cream); }
tr:last-child td { border-bottom: none; }
td .thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: contain; object-position: center; background: var(--sand); }
.cell-actions { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; font-size: 15px; transition: all .2s; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.del:hover { border-color: var(--red); background: var(--red); }

/* ---------- Badges/status ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.tag--yeni { background: #e3efff; color: var(--blue); }
.tag--hazirlaniyor { background: #fff3d6; color: var(--amber); }
.tag--kargoda { background: #ece5ff; color: #6b3fd4; }
.tag--teslim { background: rgba(119,140,88,.18); color: #4c6039; }
.tag--iptal { background: #fde2e1; color: var(--red); }
.tag--taslak { background: #eef1f0; color: var(--muted); }
.tag--gonderildi { background: #e3efff; color: var(--blue); }
.tag--kabul { background: rgba(119,140,88,.18); color: #4c6039; }
.tag--red { background: #fde2e1; color: var(--red); }
.tag--pasif { background: #eef1f0; color: var(--muted); }
.tag--aktif { background: rgba(119,140,88,.18); color: #4c6039; }
.tag--incelendi { background: #fff3d6; color: var(--amber); }
.tag--teklif_verildi { background: #ece5ff; color: #6b3fd4; }
.tag--kapandi { background: rgba(119,140,88,.18); color: #4c6039; }

.stat--accent { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* Teklif isteği detay */
.req-detail__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.req-detail__grid > div { display: flex; flex-direction: column; gap: 2px; }
.req-detail__grid span { font-size: 12px; color: var(--muted); }
.req-detail__grid strong { font-size: 14.5px; color: var(--ink); }
.req-detail__note { margin-top: 14px; font-size: 13.5px; color: var(--muted); background: var(--cream); padding: 12px 14px; border-radius: 10px; }
.req-detail__total { text-align: right; margin-top: 12px; font-size: 15px; color: var(--ink); }
.req-detail__total strong { font-size: 18px; color: var(--green-700); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty span { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(12,50,38,.5); backdrop-filter: blur(3px); }
.modal__box { position: relative; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal__head h3 { font-size: 19px; color: var(--green-900); }
.modal__close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal__body { padding: 24px; }
.modal__foot { display: flex; gap: 12px; justify-content: flex-end; padding: 18px 24px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: #fff; }

/* ---------- Image picker ---------- */
.imgpick { display: flex; gap: 14px; align-items: center; position: relative; }
.imgpick__preview { width: 84px; height: 84px; border-radius: 12px; object-fit: contain; object-position: center; background: var(--sand); border: 1.5px dashed var(--border); }
.imgpick__video-badge {
  position: absolute; left: 8px; top: 8px; z-index: 1;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 7px; border-radius: 6px; pointer-events: none;
}
.imgpick__actions { display: flex; flex-direction: column; gap: 8px; flex: 1; }

/* ---------- Rich text editor ---------- */
.rte { border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.rte__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px; background: var(--cream); border-bottom: 1px solid var(--border); }
.rte__bar button { min-width: 32px; height: 30px; padding: 0 9px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; transition: all .15s; }
.rte__bar button:hover { border-color: var(--accent); color: var(--accent); }
.rte__bar button sup { font-size: 9px; }
.rte__sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }
.rte__color { position: relative; min-width: 32px; height: 30px; padding: 0 6px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink); overflow: hidden; }
.rte__color:hover { border-color: var(--accent); color: var(--accent); }
.rte__color span { position: relative; z-index: 1; pointer-events: none; border-bottom: 3px solid currentColor; line-height: 1.1; }
.rte__color--bg span { border-bottom: none; }
.rte__color input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0; }
.rte__editor { min-height: 150px; max-height: 340px; overflow-y: auto; padding: 14px 16px; font-size: 14.5px; line-height: 1.7; outline: none; color: var(--ink); }
.rte__editor--sm { min-height: 72px; max-height: 200px; }
.rte__editor:focus { background: #fff; }
.rte__editor p { margin-bottom: 10px; }
.rte__editor h2 { font-size: 22px; margin: 4px 0 8px; color: var(--green-900); font-family: inherit; }
.rte__editor h3 { font-size: 18px; margin: 4px 0 8px; color: var(--green-900); font-family: inherit; }
.rte__editor ul, .rte__editor ol { margin: 0 0 10px 22px; }
.rte__editor a { color: var(--accent); text-decoration: underline; }
.rte--compact .rte__editor { min-height: 72px; max-height: 200px; }
.rte__select-wrap {
  display: inline-flex; align-items: center; height: 30px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 0 4px;
}
.rte__select-wrap select {
  border: none; background: transparent; font-size: 12.5px; color: var(--ink);
  height: 28px; padding: 0 4px; cursor: pointer; outline: none; max-width: 92px;
  min-width: 72px;
}
.rte__select-wrap--font select {
  max-width: 148px;
  min-width: 110px;
}
.repeat-simple-rich { margin-bottom: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: #fff; }

/* ---------- Gallery editor ---------- */
.gallery-edit { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.gallery-thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1.5px solid var(--border); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.gallery-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(217,83,79,.92); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.gallery-del:hover { background: var(--red); }

/* ---------- Line items (quotes) ---------- */
.lineitems { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.lineitems th, .lineitems td { padding: 8px; border: none; background: none; }
.lineitems input { padding: 8px 10px; }
.li-remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: 18px; }
.quote-totals { margin-top: 16px; margin-left: auto; width: 280px; }
.quote-totals .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14.5px; }
.quote-totals .row.total { font-weight: 700; font-size: 18px; color: var(--green-700); border-top: 2px solid var(--border); margin-top: 6px; padding-top: 12px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--green-800); color: #fff; padding: 14px 22px; border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 200; font-weight: 500; font-size: 14.5px; animation: toastIn .3s ease; }
.toast.err { background: var(--red); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Content editor ---------- */
.editor-hint { background: var(--lime-soft); border: 1px solid #b6cbd9; color: var(--green-800); padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14.5px; display: flex; align-items: center; gap: 10px; }
.edit-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.edit-block > h3 { font-size: 16px; color: var(--green-700); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.edit-save-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.95); backdrop-filter: blur(6px); border-top: 1px solid var(--border); padding: 16px 0; margin-top: 10px; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; z-index: 10; }
.repeat-item { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px; position: relative; background: var(--cream); }
.repeat-item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.repeat-item__head strong { font-size: 13px; color: var(--muted); }
.repeat-item__actions { display: flex; align-items: center; gap: 6px; }
.repeat-item__actions .li-remove { position: static; font-size: 20px; line-height: 1; padding: 0 4px; }
.repeat-simple-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.repeat-simple-row input { flex: 1; }
.add-item { background: var(--sand); border: 1.5px dashed var(--accent); color: var(--accent); padding: 10px; border-radius: var(--radius-sm); cursor: pointer; width: 100%; font-weight: 600; }
.rte--compact .rte__editor { min-height: 96px; max-height: 220px; }
.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-picker__btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px;
  border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
  cursor: pointer; font-size: 12.5px; color: var(--ink); transition: all .15s;
}
.icon-picker__btn:hover { border-color: var(--accent); }
.icon-picker__btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.icon-picker__btn .ico { width: 16px; height: 16px; }
.content-studio {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr); gap: 20px; align-items: start;
}
.content-studio__preview {
  position: sticky; top: 76px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-soft);
}
.content-studio__preview-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--cream);
}
.content-studio__preview-bar strong { font-size: 14px; color: var(--green-800); }
.content-studio__preview-bar span { font-size: 12px; color: var(--muted); }
.content-studio__frame { width: 100%; height: calc(100vh - 160px); min-height: 520px; border: 0; background: #fff; display: block; }
@media (max-width: 1200px) {
  .content-studio { grid-template-columns: 1fr; }
  .content-studio__preview { position: relative; top: 0; }
  .content-studio__frame { height: 480px; min-height: 360px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 250px; transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: none; }
  .topbar__menu { display: block; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}

/* ---------- Teklif yazdırma ----------
   Görsel stiller JS'te quoteCss() ile şablona göre (.quote-doc) üretilir. */
#printArea { display: none; }

@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  @page { margin: 16mm; }
}

/* ---------- Teklif şablonu editörü ---------- */
.tpl-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-chip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1.5px solid var(--border); background: #fff; border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--ink); transition: all .15s; }
.tpl-chip:hover { border-color: var(--accent); }
.tpl-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.tpl-badge { font-size: 11px; font-weight: 600; color: var(--green-800); background: var(--lime-soft); padding: 2px 7px; border-radius: 20px; }

.tpl-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 1000px) { .tpl-editor { grid-template-columns: 1fr; } }

.tpl-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); margin: 4px 0 14px; cursor: pointer; }
.tpl-check input { width: 16px; height: 16px; }
.tpl-color { height: 42px; padding: 4px; cursor: pointer; }
.field-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row3 { grid-template-columns: 1fr; } }
.tpl-defaults { border: 1px dashed var(--border); border-radius: 10px; padding: 14px 16px; margin: 6px 0 16px; background: var(--cream); }
.tpl-defaults__title { font-size: 13px; font-weight: 600; color: var(--green-800); margin-bottom: 10px; }
.tpl-actions { display: flex; gap: 10px; margin-top: 8px; }
.tpl-preview { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
#tplForm .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
