:root {
    --bg: #eef6f8;
    --panel: #ffffff;
    --text: #102331;
    --muted: #5f7280;
    --border: #d7e5ea;
    --primary: #0a6f8f;
    --primary-dark: #074f67;
    --teal: #15a3a6;
    --mint: #dff7f1;
    --danger: #b42318;
    --danger-bg: #fff5f5;
    --success: #08706e;
    --amber: #f6b942;
    --shadow: 0 24px 70px rgba(16, 35, 49, 0.14);
    --soft-shadow: 0 12px 34px rgba(16, 35, 49, 0.07);
    --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 8%, rgba(21, 163, 166, 0.22), transparent 28%),
        radial-gradient(circle at 90% 5%, rgba(10, 111, 143, 0.20), transparent 30%),
        linear-gradient(180deg, #f7fbfc 0%, var(--bg) 46%, #ffffff 100%);
    line-height: 1.55;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(10, 111, 143, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(10, 111, 143, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0,0,0,0.85), transparent 70%);
}

.site-header {
    width: min(1180px, calc(100% - 40px));
    margin: 24px auto 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 18px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 28px;
    box-shadow: var(--soft-shadow);
    position: sticky;
    top: 14px;
    z-index: 20;
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    width: 58px;
    height: auto;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(10, 111, 143, 0.18);
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.04;
    letter-spacing: -0.045em;
}

h1 {
    font-size: clamp(1.38rem, 2.1vw, 2rem);
    color: var(--text);
}

h2 {
    font-size: clamp(1.35rem, 2vw, 1.75rem);
    color: var(--text);
}

p { margin: 0.25rem 0 0; }

.site-header p {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.98rem;
}

.layout {
    width: min(1180px, calc(100% - 40px));
    margin: 22px auto 46px;
    display: grid;
    gap: 18px;
}

.panel {
    position: relative;
    background: rgba(255, 255, 255, 0.90);
    border: 1px solid rgba(215, 229, 234, 0.95);
    border-radius: 28px;
    padding: 24px;
    box-shadow: var(--soft-shadow);
    overflow: visible;
}

.entry-panel {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.78)),
        radial-gradient(circle at 100% 0%, rgba(21, 163, 166, 0.12), transparent 28%);
}

.entry-panel::before {
    content: "Add medicine";
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    position: absolute;
    top: 22px;
    right: 24px;
    border: 1px solid rgba(10, 111, 143, 0.16);
    background: var(--mint);
    color: var(--primary-dark);
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.entry-panel h2,
.table-panel h2,
.output-panel h2 {
    padding-right: 120px;
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(240px, 2fr) repeat(5, minmax(120px, 1fr));
    gap: 0.85rem;
}

label {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    font-weight: 750;
    color: var(--primary-dark);
    font-size: 0.88rem;
}

label span {
    color: var(--primary-dark);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.78rem 0.85rem;
    font-size: 0.96rem;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(10, 111, 143, 0.65);
    box-shadow: 0 0 0 4px rgba(10, 111, 143, 0.10);
    background: #ffffff;
}

textarea {
    resize: vertical;
    min-height: 240px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.5;
    color: #31515f;
    background: #f6fafb;
    border-style: dashed;
}

.button-row {
    display: flex;
    gap: 0.7rem;
    margin-top: 1.15rem;
    align-items: center;
}

.button-row.wrap { flex-wrap: wrap; }
.button-row.right { justify-content: flex-end; }

.button {
    appearance: none;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    padding: 0.78rem 1.08rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 850;
    letter-spacing: -0.015em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.48rem;
    box-shadow: 0 16px 34px rgba(10, 111, 143, 0.22);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(10, 111, 143, 0.28);
}

.button:active {
    transform: translateY(0);
    box-shadow: 0 10px 22px rgba(10, 111, 143, 0.20);
}

.button.secondary {
    background: #ffffff;
    color: var(--primary-dark);
    border-color: var(--border);
    box-shadow: none;
}

.button.secondary:hover {
    background: #f6fafb;
    border-color: rgba(10, 111, 143, 0.32);
    color: var(--primary-dark);
    box-shadow: 0 12px 24px rgba(16, 35, 49, 0.08);
}

.button.ghost {
    background: rgba(255, 255, 255, 0.62);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.button.ghost:hover {
    background: #ffffff;
    border-color: rgba(10, 111, 143, 0.30);
}

.header-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hint {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 0.95rem;
    padding: 0.74rem 0.9rem;
    border: 1px solid rgba(10, 111, 143, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.62);
}

.hint::before {
    content: "i";
    width: 21px;
    height: 21px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--mint);
    color: var(--primary-dark);
    font-weight: 900;
    font-family: Georgia, serif;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 12px;
}

.status-line {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.4rem 0.75rem;
    border: 1px solid rgba(10, 111, 143, 0.15);
    border-radius: 999px;
    background: var(--mint);
    color: var(--primary-dark);
    font-size: 0.86rem;
    font-weight: 850;
    white-space: nowrap;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: #ffffff;
}

.med-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.med-table th,
.med-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.72rem;
    text-align: left;
    vertical-align: top;
}

.med-table th {
    color: var(--primary-dark);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.065em;
    background: #f6fafb;
    white-space: nowrap;
}

.med-table tbody tr:nth-child(even) {
    background: rgba(246, 250, 251, 0.72);
}

.med-table tbody tr:hover {
    background: rgba(223, 247, 241, 0.36);
}

.med-table tr:last-child td { border-bottom: 0; }
.med-table td input,
.med-table td select {
    padding: 0.52rem 0.58rem;
    border-radius: 12px;
    background: #ffffff;
}

.button.small {
    padding: 0.5rem 0.74rem;
    border-radius: 999px;
    font-size: 0.82rem;
    line-height: 1;
}

.button.danger {
    border-color: #f3b6b6;
    background: var(--danger-bg);
    color: var(--danger);
    box-shadow: none;
}

.button.danger:hover {
    border-color: var(--danger);
    background: #fee2e2;
    color: #991b1b;
    box-shadow: 0 12px 24px rgba(180, 35, 24, 0.12);
}

.row-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.remove-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.32rem;
    min-height: 2.1rem;
}

.remove-button .material-icons {
    font-size: 1rem;
    line-height: 1;
}

.suggestions {
    position: absolute;
    margin-top: 4.85rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    width: min(520px, calc(100vw - 2rem));
}

.suggestion-item {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    width: 100%;
    text-align: left;
    background: #fff;
    color: var(--text);
    border: 0;
    border-bottom: 1px solid #edf2f7;
    border-radius: 0;
    padding: 0.66rem 0.82rem 0.58rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.96rem;
    font-weight: 500;
    line-height: 1.25;
}

.suggestion-main {
    display: block;
    color: var(--text);
    font-size: 0.96rem;
    font-weight: 650;
    line-height: 1.25;
}

.suggestion-meta {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background: var(--mint);
    outline: none;
}

.suggestion-item:hover .suggestion-meta,
.suggestion-item:focus .suggestion-meta {
    color: var(--primary-dark);
}

.interaction-output {
    margin-top: 1rem;
    border: 1px solid #f4c7c3;
    background: #fff4f2;
    border-radius: 18px;
    padding: 1rem;
}

.interaction-output ul {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    background: #102331;
    color: #fff;
    padding: 0.86rem 1rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 100;
    max-width: min(420px, calc(100vw - 2rem));
}

.dialog {
    width: min(460px, calc(100vw - 2rem));
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.1rem;
    box-shadow: var(--shadow);
}

.dialog::backdrop {
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(5px);
}

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

@media (max-width: 760px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        width: min(100% - 24px, 1180px);
        margin-top: 12px;
        top: 8px;
    }

    .layout {
        width: min(100% - 24px, 1180px);
        margin-top: 14px;
    }

    .panel {
        padding: 18px;
        border-radius: 22px;
    }

    .form-grid { grid-template-columns: 1fr; }

    .button-row,
    .header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .button { width: 100%; }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .status-line { align-self: flex-start; }

    .entry-panel::before { display: none; }
    .entry-panel h2,
    .table-panel h2,
    .output-panel h2 { padding-right: 0; }
}

@media (max-width: 520px) {
    .med-table th,
    .med-table td {
        padding: 0.58rem;
    }

    .suggestions {
        width: calc(100vw - 40px);
    }
}

.legacy-copy-buffer {
    position: fixed;
    left: -10000px;
    top: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.legacy-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.38);
    padding: 1rem;
}

.legacy-modal-backdrop[hidden] {
    display: none;
}

.modal-confirm {
    color: var(--text);
    width: min(440px, calc(100vw - 2rem));
}

.modal-confirm .modal-content {
    padding: 20px;
    border-radius: 24px;
    border: none;
    text-align: center;
    font-size: 14px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2);
}

.modal-confirm .modal-header {
    border-bottom: none;
    position: relative;
    display: block;
    padding: 0;
}

.modal-confirm h4 {
    text-align: center;
    font-size: 26px;
    margin: 30px 0 10px;
    color: var(--text);
}

.modal-confirm .close {
    position: absolute;
    top: -5px;
    right: -2px;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.modal-confirm .modal-body {
    color: var(--muted);
    line-height: 1.5;
    padding: 0 0 8px;
}

.modal-confirm .icon-box {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    border-radius: 50%;
    z-index: 9;
    text-align: center;
    border: var(--teal) solid 3px;
}

.modal-confirm .icon-box i {
    color: var(--teal);
    font-size: 46px;
    display: inline-block;
    margin-top: 13px;
}

.legacy-copy-table .pharmacy-cells {
    background-color: #DEFFD4;
    width: 20px;
    font-size: 10px;
    text-align: center;
}
