:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --border: #e1e6ec;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --ok: #16a34a;
    --warn: #d97706;
    --err: #dc2626;
    --info: #0891b2;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

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

.topbar {
    background: #111827;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
}
.brand {
    font-weight: 700;
    color: #fff;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.usermenu { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.usermenu-name { color: #cbd5e1; font-size: 13.5px; }
.usermenu form { display: inline; }
.usermenu .btn-ghost { color: #cbd5e1; }
.usermenu .btn-ghost:hover { color: #fff; background: #1f2937; }
.mainnav a {
    color: #cbd5e1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
}
.mainnav a:hover { background: #1f2937; text-decoration: none; color: #fff; }
.mainnav a.active { background: var(--primary); color: #fff; }

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { margin: 0 6px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.metric {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.metric-label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.metric-value { display: block; font-size: 24px; font-weight: 700; }
.metric-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.metric-accent {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: #fff;
}
.metric-accent .metric-label,
.metric-accent .metric-sub { color: rgba(255, 255, 255, 0.82); }
.metric-value-xl { font-size: 32px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; }
tr:hover td { background: #fafbfc; }

.form label { display: block; margin-bottom: 14px; font-size: 13.5px; font-weight: 600; color: #374151; }
.form input, .form select, .form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-ghost { background: transparent; color: var(--muted); border: none; padding: 6px 10px; }
.btn-danger { background: #fff; color: var(--err); border-color: #fca5a5; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-off { background: #e5e7eb; color: #4b5563; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; }
.flash-ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.alert { padding: 14px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 0 40px; }

.pagination { display: flex; gap: 8px; margin-top: 14px; }

.chart-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

code.pill { background: #f3f4f6; border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.search-box { display: flex; gap: 10px; }
.search-box input { flex: 1; }

/* ── Sistem Sağlığı (index.php) ─────────────────────────────────────── */
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.health-stat {
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    background: #f9fafb;
}
.health-stat-value { display: block; font-size: 26px; font-weight: 800; line-height: 1.15; color: var(--text); }
.health-stat-label { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.health-stat-ok { border-left-color: var(--ok); }
.health-stat-ok .health-stat-value { color: var(--ok); }
.health-stat-err { border-left-color: var(--err); }
.health-stat-err .health-stat-value { color: var(--err); }
.health-stat-warn { border-left-color: var(--warn); }
.health-stat-warn .health-stat-value { color: var(--warn); }
.health-stat-info { border-left-color: var(--info); }
.health-stat-info .health-stat-value { color: var(--info); }
.health-stat-off { border-left-color: var(--muted); }

/* ── Cihaz Kartları (devices.php) ───────────────────────────────────── */
.device-card { display: flex; flex-direction: column; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.device-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); }
.device-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.device-card-head h2 { font-size: 15px; margin: 0; }
.device-card-sub { margin: -4px 0 6px; font-size: 12.5px; }
.device-card-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.device-card-metrics .metric-label { font-size: 11px; margin-bottom: 3px; }
.device-card-metrics .metric-value { font-size: 18px; }
.device-card .btn { margin-top: 8px; margin-right: 6px; }

/* ── Anlık Güç Paneli / Gauge (realtime.php) ────────────────────────── */
.realtime-summary { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.realtime-summary-meta { color: var(--muted); font-size: 13px; }
.gauge-card { text-align: center; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.gauge-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); }
.gauge-card-title { font-size: 14px; margin: 0 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gauge {
    --pct: 0;
    width: 124px;
    height: 124px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) calc(var(--pct) * 3.6deg), var(--border) 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.6s ease;
}
.gauge::before {
    content: '';
    position: absolute;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--border);
}
.gauge-center { position: relative; z-index: 1; padding: 0 8px; }
.gauge-value { font-size: 14px; font-weight: 700; line-height: 1.3; }
.gauge-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; gap: 6px; }

/* ── Giriş / İlk Kurulum Sayfası (login.php) ────────────────────────── */
.auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #2563eb 100%);
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.auth-wrap { width: 100%; padding: 20px; box-sizing: border-box; }
.auth-card {
    max-width: 400px;
    margin: 0 auto;
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.auth-brand {
    font-weight: 800;
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    color: #111827;
}
.auth-card h1 { font-size: 19px; }
.auth-card .subtitle { margin-bottom: 22px; }

@media (max-width: 720px) {
    .topbar-inner { flex-direction: column; height: auto; padding: 10px 16px; gap: 8px; }
    .mainnav { justify-content: center; }
    .usermenu { justify-content: center; }
    .kv { grid-template-columns: 1fr; }
    .device-card-metrics { grid-template-columns: 1fr; }
}
