:root {
    --teal: #0f766e;
    --dark: #0f172a;
    --light: #f1f5f9;
    --red: #dc2626;
    --orange: #d97706;
    --green: #16a34a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--light);
    color: var(--dark);
}

.topbar {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--teal);
    color: white;
}

.topbar h1 { margin: 0; font-size: 20px; }

main { max-width: 720px; margin: auto; padding: 16px; }

.card, .medicine, .friend, .request {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

label { display: block; margin-bottom: 10px; font-size: 14px; }

input, select, textarea {
    width: 100%;
    padding: 11px;
    margin-top: 5px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 16px;
}

button {
    padding: 11px 15px;
    border: 0;
    border-radius: 10px;
    background: #e2e8f0;
    font-size: 15px;
    cursor: pointer;
}

button.primary { background: var(--teal); color: white; }
button.danger { background: var(--red); color: white; }
button.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.tab { background: white; }

.tab.active {
    background: var(--teal);
    color: white;
}

.toolbar {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.medicine h3, .friend h3, .request h3 { margin: 0 0 4px; }
.medicine p, .friend p, .request p { margin: 3px 0; color: #475569; }

.badge {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    background: #e2e8f0;
}

.badge.ok { background: #dcfce7; color: var(--green); }
.badge.soon { background: #fef3c7; color: var(--orange); }
.badge.expired { background: #fee2e2; color: var(--red); }
.badge.gray { background: #e2e8f0; color: #475569; }

.actions { display: flex; gap: 8px; margin-top: 10px; }

#reader { width: 100%; margin-bottom: 12px; }

.scan-result {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #ecfeff;
    word-break: break-all;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 12px 18px;
    border-radius: 999px;
    z-index: 10;
}

.toast.error { background: var(--red); }

.hidden { display: none !important; }

@media (max-width: 480px) {
    .tabs { grid-template-columns: repeat(2, 1fr); }
    .toolbar { grid-template-columns: 1fr; }
}