:root{
  --bg:#f4f6f8; --panel:#fff; --border:#e5e9ee; --text:#1c2733; --muted:#74808c;
  --accent:#3b82f6; --accent-dark:#1d4ed8;
  --green:#15803d; --green-bg:#e9f9ef;
  --blue:#1d4ed8; --blue-bg:#eff6ff;
  --orange:#b45309; --orange-bg:#fff7e6;
  --red:#b91c1c; --red-bg:#fef2f2;
  --gray:#64748b; --gray-bg:#f1f5f9;
  --sidebar-bg:#17202a; --sidebar-hover:#202b36;
}
*{box-sizing:border-box}
body{margin:0;font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Arial;background:var(--bg);color:var(--text)}
a{color:inherit}
.app{display:flex;min-height:100vh}

/* SIDEBAR */
.sidebar{width:230px;background:var(--sidebar-bg);color:#cbd5e1;display:flex;flex-direction:column;padding:18px 14px;flex-shrink:0}
.brand{display:flex;align-items:center;gap:10px;padding-bottom:20px;border-bottom:1px solid #2a3543;margin-bottom:14px}
.brand-mark{width:34px;height:34px;border-radius:9px;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:13px}
.brand strong{display:block;font-size:14px;color:#fff}
.brand span{font-size:10px;color:#7d8a99}
.nav-label{font-size:10px;text-transform:uppercase;letter-spacing:.06em;color:#5c6a7a;font-weight:700;margin:14px 6px 6px}
.nav{display:flex;flex-direction:column}
.nav a{width:100%;border:0;background:transparent;color:#aeb8c2;text-align:left;padding:10px 12px;border-radius:9px;margin:2px 0;display:flex;align-items:center;gap:10px;font-weight:600;text-decoration:none;font-size:13px;box-sizing:border-box}
.nav a:hover,.nav a.active{background:var(--sidebar-hover);color:#fff}
.ico{width:18px;text-align:center;opacity:.85}
.sidebar-bottom{margin-top:auto;font-size:10px;color:#4d5a68;line-height:1.6;padding-top:14px}

/* MAIN */
.main{flex:1;min-width:0}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:14px 26px;background:#fff;border-bottom:1px solid var(--border)}
.menu-toggle{display:none;background:none;border:0;font-size:20px;cursor:pointer}
.avatar{width:32px;height:32px;border-radius:50%;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:800;text-transform:uppercase}
.content{padding:22px 26px 60px}

/* PAGE HEAD */
.page-head{display:flex;justify-content:space-between;align-items:flex-end;flex-wrap:wrap;gap:14px;margin-bottom:20px}
.eyebrow{font-size:11px;font-weight:700;color:var(--accent);text-transform:uppercase;letter-spacing:.05em}
.page-title{font-size:22px;font-weight:800;margin:4px 0 4px}
.page-sub{font-size:13px;color:var(--muted)}
.actions{display:flex;gap:8px}

/* BUTTONS */
.btn{background:#fff;border:1px solid var(--border);padding:9px 14px;border-radius:9px;font-size:12.5px;font-weight:700;cursor:pointer;color:var(--text);text-decoration:none;display:inline-flex;align-items:center;gap:6px}
.btn:hover{background:#f8fafc}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.btn.primary:hover{background:var(--accent-dark)}
.btn.danger{background:var(--red-bg);border-color:#fecaca;color:var(--red)}
.btn.btn-sm{padding:5px 10px;font-size:11px}
.row-actions{display:flex;gap:6px;flex-wrap:wrap}

/* CARDS / STATS */
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;margin-bottom:22px}
.stat{background:var(--panel);border:1px solid var(--border);border-radius:14px;padding:16px}
.stat-top{display:flex;justify-content:space-between;align-items:center;font-size:11.5px;font-weight:700;color:var(--muted)}
.stat-icon{width:26px;height:26px;border-radius:8px;background:var(--gray-bg);display:flex;align-items:center;justify-content:center;font-size:12px}
.stat-num{font-size:22px;font-weight:800;margin:10px 0 2px}
.stat-foot{font-size:11px;color:var(--muted)}

.grid2{display:grid;grid-template-columns:1.3fr 1fr;gap:16px;margin-bottom:20px}
@media(max-width:900px){.grid2{grid-template-columns:1fr}}

/* PANEL */
.panel{background:var(--panel);border:1px solid var(--border);border-radius:14px;margin-bottom:20px;overflow:hidden}
.panel-head{display:flex;justify-content:space-between;align-items:center;padding:14px 18px;border-bottom:1px solid var(--border)}
.panel-head h3{margin:0;font-size:14px;font-weight:800}
.panel-body{padding:16px 18px}
.chart-container{height:230px;position:relative}

/* TABLE */
.table-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;font-size:12.5px}
th{text-align:left;font-size:10.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);padding:10px 16px;border-bottom:1px solid var(--border);white-space:nowrap}
td{padding:11px 16px;border-bottom:1px solid #f1f3f5;vertical-align:middle}
tr:last-child td{border-bottom:none}
.empty{text-align:center;color:var(--muted);padding:30px 10px}
.muted-sm{font-size:10.5px;color:var(--muted)}

/* BADGES */
.badge{padding:4px 10px;border-radius:999px;font-size:10.5px;font-weight:800;display:inline-block}
.b-green{background:var(--green-bg);color:var(--green)}
.b-blue{background:var(--blue-bg);color:var(--blue)}
.b-orange{background:var(--orange-bg);color:var(--orange)}
.b-red{background:var(--red-bg);color:var(--red)}
.b-gray{background:var(--gray-bg);color:var(--gray)}

/* TOOLBAR / FILTERS */
.toolbar{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:14px}
.filters{display:flex;gap:6px;flex-wrap:wrap}
.filter{background:#fff;border:1px solid var(--border);padding:7px 14px;border-radius:999px;font-size:11.5px;font-weight:700;cursor:pointer;color:var(--muted);text-decoration:none}
.filter.active{background:var(--text);color:#fff;border-color:var(--text)}
.search{position:relative;display:flex;align-items:center}
.search input{width:100%;padding:9px 12px 9px 12px;border:1px solid var(--border);border-radius:9px;font-size:12.5px}
.year-select{padding:8px 12px;border:1px solid var(--border);border-radius:9px;font-size:12.5px;font-weight:700}

/* LIST */
.list{display:flex;flex-direction:column;gap:2px}
.list-item{display:flex;justify-content:space-between;align-items:center;padding:10px 4px;border-bottom:1px solid #f4f5f7}
.list-item:last-child{border-bottom:none}
.list-main{display:flex;align-items:center;gap:10px}
.list-title{font-size:12.5px;font-weight:700}
.list-meta{font-size:10.5px;color:var(--muted)}

/* FORMS */
.field label{display:block;font-size:10px;text-transform:uppercase;letter-spacing:.05em;color:#7a8793;font-weight:800;margin-bottom:6px}
.field input,.field select,.field textarea{width:100%;border:1px solid var(--border);border-radius:8px;padding:9px 10px;font-size:12.5px;font-family:inherit;outline:none;box-sizing:border-box}
.field input:focus,.field select:focus,.field textarea:focus{border-color:#93b4ef;box-shadow:0 0 0 3px #eff6ff}
.field textarea{resize:vertical}
.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}
.form-grid.three{grid-template-columns:repeat(3,1fr)}
@media(max-width:640px){.form-grid,.form-grid.three{grid-template-columns:1fr}}

/* MODAL */
.modal{display:none;position:fixed;inset:0;background:rgba(15,23,32,.55);z-index:100;align-items:center;justify-content:center;padding:16px}
.modal.open{display:flex}
.modal-box{background:#fff;border-radius:16px;width:min(560px,100%);max-height:94vh;display:flex;flex-direction:column;overflow:hidden}
.modal-box.modal-wide{width:min(980px,96vw)}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:16px 24px;border-bottom:1px solid var(--border);flex-shrink:0}
.modal-head h2{margin:0;font-size:16px;font-weight:800}
.close{background:none;border:0;font-size:22px;cursor:pointer;color:var(--muted);line-height:1;padding:4px}
.modal-body{padding:20px 24px;overflow-y:auto;flex:1;min-height:0}
/* Modallerdeki <form>, modal-body ve modal-foot'u sarmalıyor; form'un kendisi de
   flex düzenine katılmazsa içerik kadar büyür ve modal-body'nin scroll'u işe yaramaz. */
.modal-box > form{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.modal-foot{display:flex;justify-content:flex-end;gap:8px;padding:14px 24px;border-top:1px solid var(--border);flex-shrink:0;flex-wrap:wrap}

/* RECIPE ROWS (ürün modalı) */
.recipe-row{display:grid;grid-template-columns:2fr 1fr 90px 90px 34px;gap:8px;margin-bottom:8px;align-items:end}
@media(max-width:640px){.recipe-row{grid-template-columns:1fr 1fr;grid-template-areas:"a a" "b c" "d e"}}
.remove-row{height:37px;border:1px solid #fee2e2;background:#fff5f5;color:#b91c1c;border-radius:7px;cursor:pointer}

/* QUOTE ITEMS TABLE */
.items-table-wrap{overflow-x:auto;margin-bottom:6px}
.items-table{width:100%;min-width:640px;border-collapse:separate;border-spacing:0 8px}
.items-table th{font-size:10.5px;text-transform:uppercase;letter-spacing:.03em;color:var(--muted);padding:0 8px 6px;text-align:left;white-space:nowrap}
.items-table td{padding:8px;vertical-align:top;background:#fafbfc;border-top:1px solid var(--border);border-bottom:1px solid var(--border)}
.items-table td:first-child{border-left:1px solid var(--border);border-radius:8px 0 0 8px}
.items-table td:last-child{border-right:1px solid var(--border);border-radius:0 8px 8px 0}
.items-table input,.items-table select{width:100%;padding:8px 9px;border:1px solid var(--border);border-radius:6px;font-size:12.5px;background:#fff}
.items-table .i-desc{min-width:170px;font-weight:600}
.items-table .i-qty,.items-table .i-price{min-width:85px}
.items-table .i-sub{font-weight:800;font-size:12.5px;white-space:nowrap;text-align:right;padding-top:16px}
.row-del-btn{color:#c0392b;cursor:pointer;font-size:16px;padding:6px}
.totals-box{margin-top:14px;text-align:right;font-size:13px;display:flex;flex-direction:column;gap:5px;align-items:flex-end;background:var(--gray-bg);border-radius:10px;padding:14px 18px}
.totals-box .grand{font-size:17px;font-weight:800;border-top:1px solid var(--border);padding-top:8px;margin-top:4px}

/* PRODUCT CARDS (products.php) */
.product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px}
.product-card{background:var(--panel);border:1px solid var(--border);border-radius:14px;overflow:hidden;display:flex;flex-direction:column}
.product-card-img{height:140px;background:var(--gray-bg);display:flex;align-items:center;justify-content:center;overflow:hidden}
.product-card-img img{width:100%;height:100%;object-fit:cover}
.product-card-noimg{font-size:34px;color:#c3cad1}
.product-card-body{padding:14px 16px;display:flex;flex-direction:column;gap:10px;flex:1}
.product-card-top{display:flex;justify-content:space-between;align-items:flex-start;gap:8px}
.product-card-top b{font-size:13.5px}
.product-card-meta{display:flex;justify-content:space-between;font-size:11px;color:var(--muted)}
.product-card-actions{display:flex;gap:8px;margin-top:auto}
.product-card-actions .btn{flex:1;justify-content:center}

/* RECIPE VIEW (recipe_view.php) */
.recipe-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin-bottom:20px}
.recipe-stat{background:var(--panel);border:1px solid var(--border);border-radius:12px;padding:14px 16px;display:flex;align-items:center;gap:12px}
.recipe-stat-icon{width:38px;height:38px;border-radius:10px;background:var(--blue-bg);color:var(--blue);display:flex;align-items:center;justify-content:center;font-size:16px;flex-shrink:0}
.recipe-stat-label{font-size:10.5px;color:var(--muted);font-weight:700}
.recipe-stat-val{font-size:16px;font-weight:800}
.recipe-hero{display:flex;gap:20px;align-items:flex-start;margin-bottom:20px}
.recipe-hero-img{width:150px;height:110px;border-radius:12px;background:var(--gray-bg);flex-shrink:0;display:flex;align-items:center;justify-content:center;overflow:hidden;border:1px solid var(--border)}
.recipe-hero-img img{width:100%;height:100%;object-fit:cover}
.recipe-group{background:var(--panel);border:1px solid var(--border);border-radius:14px;margin-bottom:14px;overflow:hidden}
.recipe-group-head{display:flex;justify-content:space-between;align-items:center;padding:13px 18px;cursor:pointer;user-select:none}
.recipe-group-head:hover{background:#fafbfc}
.recipe-group-title{font-size:13px;font-weight:800;display:flex;align-items:center;gap:10px}
.recipe-group-count{font-size:10.5px;color:var(--muted);font-weight:600;background:var(--gray-bg);padding:2px 9px;border-radius:999px}
.recipe-group-sub{font-size:12.5px;font-weight:800;color:var(--accent-dark)}
.recipe-group-chev{transition:.2s;color:var(--muted)}
.recipe-group.collapsed .recipe-group-chev{transform:rotate(-90deg)}
.recipe-group.collapsed .recipe-group-body{display:none}
.recipe-group-body{border-top:1px solid var(--border)}
.breadcrumb{font-size:11.5px;color:var(--muted);margin-bottom:6px}
.breadcrumb a{color:var(--accent);text-decoration:none}

/* RECIPE EDIT (recipe_edit.php) */
.recipe-edit-group{background:var(--panel);border:1px solid var(--border);border-radius:14px;padding:16px 18px;margin-bottom:14px}
.recipe-edit-group-head{display:flex;gap:10px;align-items:center;margin-bottom:12px}
.group-name-input{flex:1;font-size:13px;font-weight:800;border:1px solid var(--border);border-radius:8px;padding:8px 10px}
.recipe-edit-table input,.recipe-edit-table select{min-width:70px}
.recipe-edit-table .ri-name{min-width:150px}
.recipe-edit-table .ri-code{min-width:80px}

/* NOTE TEMPLATES (settings.php) */
.template-list{display:flex;flex-direction:column;gap:8px}
.template-item{border:1px solid var(--border);border-radius:10px;padding:10px 14px}
.template-item-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.template-item-body{font-size:12px;color:var(--muted);margin-top:6px;line-height:1.6;white-space:pre-line}

/* ALERTS */
.alert-error{background:var(--red-bg);color:var(--red);border:1px solid #fecaca;border-radius:9px;padding:10px 13px;font-size:12px;font-weight:700}
.alert-info{background:var(--blue-bg);color:var(--blue);border:1px solid #bfdbfe;border-radius:9px;padding:10px 13px;font-size:12px;font-weight:700}

/* TOAST */
.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%) translateY(20px);background:#1c2733;color:#fff;padding:10px 18px;border-radius:9px;font-size:12.5px;font-weight:600;opacity:0;pointer-events:none;transition:.25s;z-index:200}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* LOGIN */
.login-body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(160deg,#111820,#1c2733);font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Arial}
.login-box{background:#fff;border-radius:16px;padding:34px 32px;width:min(380px,90vw);box-shadow:0 25px 80px rgba(0,0,0,.35)}
.login-box .field{margin-top:0}
.login-box .field label{display:block;font-size:10px;text-transform:uppercase;letter-spacing:.05em;color:#7a8793;font-weight:800;margin-bottom:6px}
.login-box .field input{width:100%;border:1px solid #dfe5ea;border-radius:8px;padding:11px;outline:none;font-size:13px;box-sizing:border-box}

/* MOBILE */
@media(max-width:880px){
  .menu-toggle{display:block}
  .sidebar{position:fixed;left:-240px;top:0;bottom:0;z-index:150;transition:.2s;box-shadow:0 0 30px rgba(0,0,0,.3)}
  .sidebar.open{left:0}
}
