:root {
    --bg: #f2f3f5;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.eyebrow {
    font-size: 11px;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.clockbox {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 18px;
    text-align: right;
    min-width: 170px;
}

#clock-time {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 20px;
    font-weight: 700;
}

#clock-date {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--muted);
}

.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tabs a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 2px;
    border-bottom: 2px solid transparent;
}

.tabs a.active {
    color: var(--text);
    border-bottom-color: var(--text);
}

.tabs a.logout-link {
    margin-left: auto;
    color: #b91c1c;
}

/* Kod Ver kartları */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {
    .cards-grid { grid-template-columns: 1fr; }
}

.code-card {
    text-align: left;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 4px solid #333;
    border-radius: var(--radius);
    padding: 18px 20px;
    cursor: pointer;
    font: inherit;
    transition: box-shadow .15s ease, transform .15s ease;
}

.code-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    transform: translateY(-1px);
}

.code-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.code-desc {
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 14px;
}

.code-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.pill {
    background: #eef0f3;
    color: #4b5563;
    font-size: 11.5px;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    padding: 3px 9px;
    border-radius: 999px;
}

/* Kişi Yönetimi */
.code-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 3px solid #333;
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
}

.code-section h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

.empty-box {
    background: #fafafa;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 14px;
    color: var(--muted);
    font-size: 13.5px;
    text-align: center;
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.contact-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f1f1;
}

.contact-name {
    font-weight: 600;
    margin-right: 8px;
}

.badge-auto {
    background: #dcfce7;
    color: #15803d;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 2px 7px;
    border-radius: 999px;
}

.contact-phone {
    color: var(--muted);
    font-size: 13px;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    margin-top: 2px;
}

.btn-remove {
    background: transparent;
    border: 1px solid #f3b4b4;
    color: #b91c1c;
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}

.btn-remove:hover { background: #fef2f2; }

.add-contact-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.add-contact-form input {
    flex: 1;
    min-width: 160px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13.5px;
}

.add-contact-form button {
    background: #111318;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 9px 16px;
    font-weight: 600;
    cursor: pointer;
}

.help-text {
    font-size: 12px;
    color: var(--muted);
    margin: 10px 0 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,20,25,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.modal-overlay.hidden { display: none; }

.modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.modal-title { font-size: 18px; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }

.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    margin: 12px 0 5px;
}

#modal-location, #modal-preview {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
}

#modal-preview {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 12.5px;
    background: #fafafa;
    resize: vertical;
}

.modal-warning {
    margin-top: 12px;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
}

.modal-result {
    margin-top: 12px;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
}

.modal-result.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.modal-result.fail { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.modal-warning.hidden, .modal-result.hidden { display: none; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.btn-secondary {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: #111318;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary:disabled { opacity: .6; cursor: default; }

/* Gönderim Geçmişi */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 16px;
}

.history-item summary {
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    list-style: none;
}

.history-item summary::-webkit-details-marker { display: none; }

.history-code { font-weight: 700; }
.history-location { color: var(--muted); }
.history-date { color: var(--muted); font-size: 12.5px; font-family: monospace; margin-left: auto; }
.history-stats { font-size: 12.5px; color: #065f46; }
.fail-count { color: #b91c1c; }

.badge-test {
    background: #fef9c3;
    color: #854d0e;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
}

.history-message {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    white-space: pre-wrap;
    margin: 4px 0 12px;
}

.history-detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 12.5px;
}

.history-detail-table th, .history-detail-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #f1f1f1;
}

.history-detail-table td.ok { color: #15803d; font-weight: 600; }
.history-detail-table td.fail { color: #b91c1c; font-weight: 600; }
.history-detail-table td.mono { font-family: monospace; color: var(--muted); }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #111318;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    z-index: 60;
}

.toast.hidden { display: none; }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,.06);
}

.login-title { font-size: 20px; font-weight: 700; }
.login-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }

.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.login-box button {
    width: 100%;
    background: #111318;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-weight: 600;
    cursor: pointer;
}

.login-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    margin-bottom: 12px;
}
