:root {
  --bg: #0b1020;
  --bg2: #0f1630;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-h: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf7;
  --muted: #9aa4c0;
  --accent: #6ea8fe;
  --accent2: #8b7bff;
  --green: #46d19e;
  --amber: #ffcb6b;
  --red: #ff6b7d;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(110, 168, 254, 0.14), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(139, 123, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  font-size: 26px; width: 46px; height: 46px; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(110,168,254,.25), rgba(139,123,255,.25));
  border: 1px solid var(--border); border-radius: 13px;
}
.brand-title { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.search-wrap { flex: 1; display: flex; justify-content: center; }
#search {
  width: min(520px, 100%); padding: 11px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  font-size: 15px; outline: none; transition: border .15s, background .15s;
}
#search:focus { border-color: var(--accent); background: var(--panel-h); }
#search::placeholder { color: var(--muted); }

.session { display: flex; align-items: center; gap: 10px; min-width: 46px; justify-content: flex-end; }
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 15px; border-radius: 11px; font-size: 14px; cursor: pointer;
  transition: background .15s, border .15s, transform .05s; text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--panel-h); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(145deg, var(--accent), var(--accent2)); border: none; color: #0b1020; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--panel-h); }

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 6px 6px 6px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(145deg, var(--accent), var(--accent2)); color: #0b1020;
}
.user-chip .uname { font-size: 13px; line-height: 1.1; }
.user-chip .urole { font-size: 11px; color: var(--muted); }

/* ── Status bar (admin) ── */
.statusbar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px;
  padding: 16px 22px 0;
}
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px;
}
.stat .k { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; border-radius: 6px; background: rgba(255,255,255,.08); margin-top: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--green), var(--accent)); }
.bar.warn > i { background: linear-gradient(90deg, var(--amber), var(--red)); }

/* ── Grid ── */
.grid-wrap { padding: 18px 22px 60px; max-width: 1400px; margin: 0 auto; }
.cat { margin-top: 26px; }
.cat h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted);
  margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
.cat h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }

.card {
  position: relative; display: flex; align-items: center; gap: 13px;
  padding: 15px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  transition: transform .12s ease, background .15s, border .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); background: var(--panel-h); border-color: rgba(110,168,254,.5); box-shadow: var(--shadow); }
.card .cico {
  font-size: 26px; width: 50px; height: 50px; flex: none; display: grid; place-items: center;
  border-radius: 13px; background: rgba(255,255,255,.05); border: 1px solid var(--border);
}
.card .cbody { min-width: 0; }
.card .ctitle { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cdesc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .badge {
  position: absolute; top: 9px; right: 10px; font-size: 10px; padding: 2px 7px; border-radius: 20px;
  background: rgba(139,123,255,.18); color: #cbb8ff; border: 1px solid rgba(139,123,255,.3);
}
.card .badge.off { background: rgba(255,107,125,.15); color: #ffb3bd; border-color: rgba(255,107,125,.3); }

/* kart üstü admin aksiyonları (düzenle/sil) — fareyle üzerine gelince görünür */
.cardactions { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transform: translateY(-3px); transition: opacity .14s, transform .14s; z-index: 3; pointer-events: none; }
.card:hover .cardactions, .card:focus-within .cardactions { opacity: 1; transform: translateY(0); pointer-events: auto; }
.ca {
  width: 30px; height: 30px; border-radius: 8px; padding: 0; cursor: pointer;
  display: grid; place-items: center; border: 1px solid var(--border); background: rgba(13,20,40,.95); color: var(--text);
  transition: background .12s, border .12s, color .12s;
}
.ca:hover { background: var(--panel-h); }
.ca.edit:hover { border-color: var(--accent); color: var(--accent); }
.ca.del:hover { border-color: var(--red); color: var(--red); }
.card.custom .cico { background: rgba(110,168,254,.1); border-color: rgba(110,168,254,.3); }

/* üst bar "Kart Ekle" butonu */
.addbtn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.addbtn svg { display: block; }

/* büyük "Kart Ekle" kutusu (grid en üstünde) */
.cards.topadd { margin-bottom: 4px; }
.addtile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 82px; padding: 15px; border-radius: var(--radius); cursor: pointer;
  border: 2px dashed rgba(110,168,254,.5); background: rgba(110,168,254,.06); color: var(--accent);
  transition: background .15s, border .15s, transform .12s;
}
.addtile:hover { background: rgba(110,168,254,.13); border-color: var(--accent); transform: translateY(-2px); }
.addtile .plus { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: rgba(110,168,254,.18); }
.addtile .addtxt { font-weight: 650; font-size: 14px; }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

/* ── Drawer (admin panel) ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(440px, 94vw); z-index: 50;
  background: linear-gradient(180deg, #121a34, #0d1428); border-left: 1px solid var(--border);
  box-shadow: -20px 0 50px rgba(0,0,0,.45); overflow-y: auto; padding-bottom: 40px;
  transform: translateX(0); transition: transform .2s ease;
}
.drawer.hidden { transform: translateX(105%); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #101833; z-index: 2; }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-sec { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-sec h3 { margin: 0 0 12px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form .row { display: flex; gap: 10px; }
.form input, .form select {
  width: 100%; padding: 10px 12px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--border); color: var(--text); font-size: 14px; outline: none;
}
.form input:focus, .form select:focus { border-color: var(--accent); }
.form .ic { width: 74px; flex: none; text-align: center; }
/* açılır menü yazıları koyu temada okunur olsun (beyaz-üstü-beyaz sorunu) */
.form select { color-scheme: dark; }
.form select option { background: #101833; color: #e8ecf7; }
.fieldlabel { font-size: 12px; color: var(--muted); margin: 2px 0 -4px; }
.fieldnote { font-size: 11px; color: var(--muted); margin: -4px 2px 0; }
.form input.readonly { opacity: .6; cursor: not-allowed; }
.iconrow { display: flex; align-items: center; gap: 10px; }
.iconprev {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center; font-size: 24px;
  border-radius: 11px; background: rgba(255,255,255,.05); border: 1px solid var(--border); overflow: hidden;
}
.iconprev .cimg { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.pico {
  width: 34px; height: 34px; font-size: 18px; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); border-radius: 9px; padding: 0;
  transition: background .12s, transform .05s;
}
.pico:hover { background: var(--panel-h); transform: translateY(-1px); }
.pico:active { transform: translateY(0); }

/* kartlarda resim ikon */
.card .cico .cimg { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; }
.mitem .mico .cimg { width: 20px; height: 20px; object-fit: contain; border-radius: 5px; }
.mitem .edit { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.mitem .edit:hover { color: var(--accent); }

.manage-list { display: flex; flex-direction: column; gap: 8px; }
.mitem {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--border);
}
.mitem .mico { font-size: 18px; width: 30px; text-align: center; flex: none; }
.mitem .mtxt { flex: 1; min-width: 0; }
.mitem .mtitle { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mitem .mdom { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mitem select { padding: 6px 8px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--border); color: var(--text); font-size: 12px; }
.mitem .del { border: none; background: transparent; color: var(--red); cursor: pointer; font-size: 15px; }
.tag { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 1px 6px; }
.tag.own { color: #cbb8ff; border-color: rgba(139,123,255,.4); }
.mgroup { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 14px 2px 4px; }
.mgroup:first-child { margin-top: 0; }
.icon-btn.logout { display: grid; place-items: center; color: var(--muted); }
.icon-btn.logout:hover { color: var(--red); }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #182142; border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; font-size: 14px; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }

/* ── Modal (popup) ── */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.modal-card {
  width: min(460px, 96vw); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #121a34, #0d1428); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #101833; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal .form { padding: 16px 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.btn.danger { background: linear-gradient(145deg, #ff6b7d, #e0455a); border: none; color: #fff; font-weight: 700; }
.btn.danger:hover { filter: brightness(1.07); }

/* onay (sil/gizle) popup'ı */
.confirm-card { width: min(400px, 94vw); }
.confirm-body { padding: 26px 24px 8px; text-align: center; }
.confirm-icon {
  width: 62px; height: 62px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 30px;
  border-radius: 50%; background: rgba(255,107,125,.14); border: 1px solid rgba(255,107,125,.3);
}
.confirm-body h3 { margin: 0 0 8px; font-size: 18px; }
.confirm-body p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; white-space: pre-line; }
.confirm-actions { padding: 18px 24px 22px; }
.confirm-actions .btn { flex: 1; justify-content: center; padding: 11px; }

.hidden { display: none !important; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .search-wrap { order: 3; flex-basis: 100%; }
  .brand-sub { display: none; }
}
