:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #e3e3e8;
  --accent: #0071e3;
  --accent-text: #ffffff;
  --new: #1f9d55;
  --new-bg: #e3f6ea;
  --warn: #b25000;
  --warn-bg: #fff1e0;
  --danger: #d70015;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989d;
    --border: #38383a;
    --accent: #0a84ff;
    --new: #30d158;
    --new-bg: rgba(48, 209, 88, 0.15);
    --warn: #ff9f0a;
    --warn-bg: rgba(255, 159, 10, 0.15);
    --danger: #ff453a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}
header.top h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
header.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}

form.add { display: flex; gap: 8px; padding: 12px; margin-bottom: 16px; }
form.add input { flex: 1; min-width: 0; }

input[type="text"], input[type="url"], input[type="search"], input[type="password"] {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 12px;
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1; min-width: 180px; }
.toolbar label { color: var(--muted); font-size: 14px; display: flex; gap: 6px; align-items: center; cursor: pointer; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.msg.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.msg.ok { background: var(--new-bg); color: var(--new); }

/* Tablo */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { font-size: 10px; margin-left: 4px; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.app-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.app-cell .name { font-weight: 600; }
.app-cell .dev { color: var(--muted); font-size: 13px; }
.icon { width: 40px; height: 40px; border-radius: 22%; background: var(--surface-2); flex: none; object-fit: cover; }
.icon.lg { width: 64px; height: 64px; }
.mono { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.badge.new { background: var(--new-bg); color: var(--new); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* Liste */
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.item { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.item .head { display: flex; gap: 14px; align-items: center; }
.item .name { font-weight: 600; font-size: 16px; }
.item .dev { color: var(--muted); font-size: 13px; }
.item .facts { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.item .facts strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; }
.item .foot { display: flex; justify-content: space-between; align-items: center; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Geçmiş penceresi */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dlg-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dlg-head .name { font-weight: 600; font-size: 17px; }
.dlg-head .dev { color: var(--muted); font-size: 13px; }
.dlg-head .btn { margin-left: auto; }
.dlg-body { padding: 8px 20px 20px; overflow-y: auto; max-height: calc(100vh - 180px); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 14px 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 19px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline .ver { font-weight: 600; }
.timeline .when { color: var(--muted); font-size: 13px; }
.timeline .notes { white-space: pre-wrap; font-size: 14px; margin-top: 6px; color: var(--text); opacity: 0.85; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

/* Giriş sayfası */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }

@media (max-width: 640px) {
  header.top h1 { font-size: 22px; }
  form.add { flex-direction: column; }
  .toolbar input[type="search"] { flex-basis: 100%; }
  .hide-sm { display: none; }
}
