:root {
    --brand: #1f6feb;
    --brand-dark: #1858bd;
    --brand-soft: #e8f0fe;
    --ink: #111827;
    --muted: #5b6472;
    --line: #e2e6ec;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --success: #067647;
    --success-soft: #e6f6ee;
    --warn: #92590a;
    --warn-soft: #fdf3dc;
    --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.3; margin: 0; }
h2 { font-size: 16px; line-height: 1.4; margin: 0 0 12px; }
p { margin: 0 0 12px; }
code { font-size: 13px; }

/* Kabuk */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px;
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.sidebar .logo { display: block; padding: 0 8px; }
.sidebar .logo img { display: block; height: 52px; width: auto; margin: -6px 0 -6px -14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink);
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav .soon { color: var(--muted); padding: 8px 10px; }
.nav-title { font-size: 12px; color: var(--muted); padding: 10px 10px 4px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 0; font-size: 13px; }
.sidebar-foot .who { font-weight: 600; overflow-wrap: anywhere; }
.sidebar-foot .role { color: var(--muted); margin-bottom: 8px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.narrow { max-width: 720px; }

/* Bant ve bildirimler */
.banner { padding: 10px 28px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }

/* Kart ve ızgara */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.columns { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { color: var(--muted); font-size: 13px; }
.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* Tablo */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -18px -18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 22px 14px; text-align: center; }

/* Rozet */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }

/* Form */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], select, textarea {
    width: 100%;
    padding: 9px 11px;
    min-height: 40px;
    border: 1px solid #c9d0da;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}
.is-invalid { border-color: var(--danger) !important; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.check, .field label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; }
.check .hint { margin-top: 0; }
fieldset > .hint { margin: 0 0 10px; }
.check input { margin-top: 4px; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 2px 16px; }
.form-row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input { flex: 1 1 240px; width: auto; }
.filters select { flex: 0 1 170px; width: auto; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: #fff; border-color: #c9d0da; color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; border-color: #e6b8b3; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* Misafir sayfaları */
.guest { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 36px 16px; }
.guest-logo { display: block; margin-bottom: 6px; }
.guest-logo img { display: block; height: 104px; width: auto; }
.guest-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.guest-card.wide { max-width: 640px; }
.guest-card h1 { margin-bottom: 6px; }
.guest-card .lead { color: var(--muted); margin-bottom: 18px; }
.guest-links { margin-top: 14px; text-align: center; font-size: 14px; }
.legal h1 { font-size: 22px; line-height: 1.3; }
.legal h2 { font-size: 17px; margin: 24px 0 8px; }
.legal h3 { font-size: 15px; margin: 16px 0 6px; }
.legal p, .legal ul { margin-bottom: 12px; }
.legal ul { padding-left: 20px; }
.legal table { display: block; overflow-x: auto; margin-bottom: 14px; font-size: 13px; }
.legal th { white-space: normal; }
.legal td, .legal th { padding: 8px 10px; min-width: 110px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.section-title h2 { margin: 0; }
.group-block { margin-bottom: 22px; }

/* Sayfalama */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 12px 0; font-size: 14px; }
.pagination .page { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pagination .page.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .page.is-disabled { color: var(--muted); }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 10px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-title, .nav .soon { display: none; }
    .sidebar-foot { margin-top: 0; }
    .main { padding: 18px 16px 40px; }
    .banner { padding: 10px 16px; }
    .columns { grid-template-columns: minmax(0, 1fr); }
}

/* Ölçüm */
.subhead { font-size: 14px; margin: 16px 0 2px; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.metrics .stat-value { font-size: 20px; }
.total-cell { font-weight: 700; }
tfoot th { text-align: right; }
.version-list { list-style: none; margin: 0; padding: 0; }
.version-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.version-list li:last-child { border-bottom: 0; }
.version-list .hint { display: block; margin-top: 0; }
.version-list a.is-current { font-weight: 700; color: var(--ink); }

.me [hidden] { display: none !important; }
.me-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.me-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.me-shape { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.me-shape-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.me-shape-head input { flex: 1; min-width: 0; }
.me-fields { display: grid; gap: 0 10px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.me-fields .field { margin-bottom: 6px; }
.me-fields label { font-size: 13px; font-weight: 400; color: var(--muted); }
.me-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.me-add select { flex: 1 1 140px; width: auto; }
.me-entry { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.me-entry input { flex: 1 1 96px; width: auto; min-width: 0; }
.me-entry input.me-entry-name { flex: 2 1 180px; }
.me-manual { margin: -4px 0 12px 24px; max-width: 220px; }
.me-metrics { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.me-metric-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.me-pattern { padding: 8px 0; border-top: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }

.plan-svg { display: block; width: 100%; max-height: 480px; background: var(--bg); border-radius: 8px; }
.me-drawing .empty { padding: 48px 14px; }
.plan-part { fill: #dcc6a4; stroke: none; }
.plan-handle { cursor: grab; touch-action: none; }
.plan-handle:active { cursor: grabbing; }
.plan-hole { fill: #ffffff; fill-opacity: .92; stroke: var(--danger); stroke-width: 1.5px; stroke-dasharray: 4 3; }
.plan-joist { stroke: #6d7f79; stroke-width: 1px; stroke-opacity: .55; }
.plan-board { stroke: #8f7350; stroke-width: 1px; stroke-opacity: .7; }
.plan-joint { stroke: var(--danger); stroke-width: 1.5px; }
.plan-outline { stroke: var(--ink); stroke-width: 2px; stroke-linecap: square; }
.plan-layout, .plan-name, .plan-dim { pointer-events: none; }
.is-dragging .plan-layout, .is-dragging .plan-name { display: none; }
.plan-dim { fill: var(--ink); }
.plan-name { fill: var(--ink); }
.plan-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.plan-legend span::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
.legend-board::before { border-color: #8f7350; }
.legend-joist::before { border-color: #6d7f79; }
.legend-joint::before { border-color: var(--danger); }
.legend-hole::before { border-color: var(--danger); border-top-style: dashed; }
.cut-bar { display: block; width: 100%; height: 14px; background: var(--bg); border-radius: 3px; margin: 4px 0; }
.cut-piece { fill: var(--brand); }
.cut-cell { min-width: 200px; }

.print-page { background: #fff; max-width: 980px; margin: 0 auto; padding: 24px; }
.print-actions { display: flex; gap: 10px; margin-bottom: 18px; }
.print-head { margin-bottom: 14px; }
.print-page .plan-svg { max-height: 420px; background: #fff; border: 1px solid var(--line); }
.print-page h2 { margin-top: 20px; }

@media (max-width: 1180px) {
    .me-grid { grid-template-columns: minmax(0, 1fr); }
    .me-side { position: static; max-height: none; overflow: visible; order: -1; }
}

@media print {
    .print-actions { display: none; }
    .print-page { padding: 0; max-width: none; }
    .card, .table-wrap, .plan-svg, tr { break-inside: avoid; }
}
