:root {
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;

    color: #17333a;
    background: #f4f8f7;

    --primary: #0f766e;
    --primary2: #115e59;
    --line: #d8e4e2;
    --soft: #f8fbfa;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f4f8f7;
}

.shell {
    max-width: 1200px;
    margin: auto;
    padding: 24px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .14em;
    color: var(--primary);
}

header h1 {
    font-size: 34px;
    margin: 3px 0;
}

header p {
    color: #668087;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 12px 35px #123b3310;
}

.auth {
    max-width: 430px;
    margin: 50px auto;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
}

input,
select {
    display: block;
    width: 100%;
    margin-top: 7px;
    border: 1px solid #cbdad7;
    border-radius: 12px;
    padding: 12px 13px;
    font-size: 15px;
    background: #fff;
    color: inherit;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #0f766e18;
}

button {
    border: 0;
    border-radius: 12px;
    padding: 12px 17px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

button:hover {
    background: var(--primary2);
}

button:disabled {
    opacity: .65;
    cursor: wait;
}

button.secondary {
    background: #e5f2f0;
    color: var(--primary2);
}

button.secondary:hover {
    background: #d7ebe8;
}

button.ghost {
    background: transparent;
    color: var(--primary2);
    border: 1px solid #cbdad7;
}

button.ghost:hover {
    background: #eaf5f3;
}

.hidden {
    display: none !important;
}


/* =========================================================
   STEP
========================================================= */

.stepbar {
    display: flex;
    align-items: center;
    margin: 4px 0 20px;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #819297;
    font-size: 12px;
    font-weight: 700;
}

.step b {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #dce8e6;
    color: #62777b;
}

.step.active {
    color: var(--primary);
}

.step.active b {
    background: var(--primary);
    color: white;
}

.line {
    height: 1px;
    background: var(--line);
    flex: 1;
    margin: 0 12px;
}


/* =========================================================
   TOOLBAR
========================================================= */

.toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}

.info {
    padding: 11px 14px;
    background: #eaf5f3;
    border: 1px solid #cfe6e2;
    border-radius: 12px;
    color: var(--primary2);
    margin-bottom: 12px;
    font-weight: 700;
}

.empty {
    text-align: center;
    color: #71858a;
}

#instrumentChooser {
    margin-bottom: 16px;
}


/* =========================================================
   INSTRUMENT
========================================================= */

.instrumentHead {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.instrumentHead h2 {
    margin: 4px 0;
}

.instrumentHead p {
    color: #71858a;
    margin: 0;
}


/* =========================================================
   VALUE GROUP
========================================================= */

#valueGroups {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.valueGroup {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
}

.groupHead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 13px;
}

.groupHead h3 {
    margin: 0;
    font-size: 16px;
    color: var(--primary2);
}

.groupHead small {
    color: #71858a;
    font-size: 12px;
}

.cellGrid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.cellField {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 11px;
}

.cellField label {
    margin: 0;
    color: var(--primary2);
    font-size: 12px;
    font-weight: 800;
}

.cellField input {
    margin-top: 6px;
}

.currentValue {
    display: block;
    color: #71858a;
    font-size: 11px;
    line-height: 1.35;
    margin-top: 7px;
}

.noMapping {
    color: #71858a;
    font-size: 13px;
    padding: 5px 0;
}


/* =========================================================
   UPDATE
========================================================= */

.update {
    width: 100%;
    margin-top: 18px;
    padding: 15px;
    font-size: 15px;
}


/* =========================================================
   MESSAGE
========================================================= */

.msg {
    margin-top: 12px;
    min-height: 20px;
    font-size: 13px;
}


/* =========================================================
   MODAL
========================================================= */

.modal {
    position: fixed;
    inset: 0;
    background: #052a2599;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow: auto;
    z-index: 1000;
}

.modalBox {
    background: #fff;
    width: min(1000px, 100%);
    min-height: 100px;
    max-height: calc(100vh - 40px);
    overflow: auto;
    border-radius: 22px;
    padding: 22px;
    position: relative;
    z-index: 1001;
    margin: 0 auto;
}

.modalHead {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.adminGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
}

.adminGrid label {
    position: relative;
}

.adminGrid span {
    display: block;
    font-weight: 400;
    color: #74878b;
    font-size: 11px;
    margin-top: 3px;
}

.adminGrid select,
.adminGrid input {
    position: relative;
    z-index: 5;
}

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

.listRow {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    padding: 10px 12px;
    border-radius: 12px;
    margin: 7px 0;
}

.listRow small {
    display: block;
    color: #71858a;
    margin-top: 3px;
}

.muted {
    color: #71858a;
}

.danger {
    background: #b42318;
}

.danger:hover {
    background: #8f1b12;
}

.pw {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
}

.pw input {
    margin: 0;
}


/* =========================================================
   HR
========================================================= */

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 900px) {

    .cellGrid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}

@media (max-width: 760px) {

    .shell {
        padding: 14px;
    }

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

    .adminGrid,
    .pw {
        grid-template-columns: 1fr;
    }

    .adminActions {
        flex-direction: column;
    }

    .instrumentHead {
        flex-direction: column;
    }

    .modal {
        padding: 10px;
    }

    .modalBox {
        padding: 16px;
        max-height: calc(100vh - 20px);
    }

    .step span {
        display: none;
    }

    .line {
        margin: 0 7px;
    }

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

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

    .listRow button {
        width: 100%;
    }

}
/* =========================================================
   MASTER PWA / ANDROID-LIKE UI ENHANCEMENT
========================================================= */

html {
    min-height: 100%;
    background: #f4f8f7;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 0% 0%, rgba(15,118,110,.10), transparent 28%),
        radial-gradient(circle at 100% 10%, rgba(20,184,166,.08), transparent 25%),
        linear-gradient(180deg, #f7fbfa 0%, #eef6f4 100%);
    padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

button {
    min-height: 44px;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:not(:disabled):active {
    transform: translateY(1px) scale(.99);
}

.shell {
    width: min(1200px, 100%);
    padding: 18px 18px 12px;
}

header {
    position: sticky;
    top: 10px;
    z-index: 20;
    padding: 15px 17px;
    margin-bottom: 18px;
    border: 1px solid rgba(255,255,255,.82);
    border-radius: 22px;
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 12px 35px rgba(18,59,51,.08);
}

header h1 {
    font-size: clamp(27px, 4vw, 36px);
    letter-spacing: -.035em;
}

header p {
    margin-bottom: 0;
    font-size: 13px;
}

.headerActions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.installBtn {
    white-space: nowrap;
}

.card {
    border-color: rgba(216,228,226,.90);
    box-shadow: 0 14px 38px rgba(18,59,51,.075);
}

.auth {
    position: relative;
    overflow: hidden;
    margin-top: 35px;
    padding: 28px;
}

.auth::before {
    content: "M";
    position: absolute;
    right: -18px;
    top: -42px;
    width: 150px;
    height: 150px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(15,118,110,.13), rgba(20,184,166,.03));
    color: rgba(15,118,110,.18);
    font-size: 88px;
    font-weight: 900;
}

.auth h2 {
    position: relative;
    z-index: 1;
    margin-bottom: 20px;
}

input,
select {
    min-height: 46px;
    border-color: #cbdad7;
    box-shadow: 0 2px 8px rgba(18,59,51,.025);
}

input:focus,
select:focus {
    transform: translateY(-1px);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.stepbar {
    padding: 8px 4px;
}

.step b {
    width: 31px;
    height: 31px;
    box-shadow: 0 4px 12px rgba(18,59,51,.07);
}

.toolbar,
.info,
.instrumentChooser,
.instrumentHead,
.valueGroup {
    box-shadow: 0 7px 22px rgba(18,59,51,.035);
}

.toolbar > label,
.instrumentChooser label {
    margin-bottom: 0;
}

.valueGroup {
    border-color: #d8e8e4;
    background: linear-gradient(180deg, #fbfdfd 0%, #f5faf8 100%);
}

.valueGroupTitle {
    letter-spacing: -.01em;
}

.cellInput {
    background: #fff !important;
}

.update {
    min-height: 52px;
    border-radius: 15px;
    font-size: 15px;
    background: linear-gradient(135deg, #0f766e, #0b655f);
}

.update:hover {
    background: linear-gradient(135deg, #0b655f, #095850);
}

.appFooter {
    margin: 24px 0 8px;
    padding: 20px 12px calc(10px + env(safe-area-inset-bottom));
    text-align: center;
    color: #71858a;
    font-size: 11px;
    line-height: 1.7;
}

.footerBrand {
    margin-bottom: 5px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .16em;
}

/* Install prompt / safe mobile spacing */
@media (max-width: 700px) {
    .shell {
        padding: 10px 10px 4px;
    }

    header {
        top: 6px;
        padding: 13px 14px;
        border-radius: 18px;
    }

    header p {
        font-size: 12px;
    }

    .headerActions {
        gap: 5px;
    }

    .headerActions button {
        padding: 9px 11px;
        min-height: 40px;
        font-size: 12px;
    }

    .auth {
        margin-top: 18px;
        padding: 21px;
        border-radius: 18px;
    }

    .card {
        border-radius: 18px;
        padding: 17px;
    }

    .stepbar {
        margin-bottom: 12px;
    }

    .step span {
        display: none;
    }

    .step b {
        width: 29px;
        height: 29px;
    }

    .line {
        margin: 0 6px;
    }

    .toolbar {
        gap: 9px;
    }

    .instrumentHead {
        padding-bottom: 14px;
        margin-bottom: 14px;
    }

    .appFooter {
        padding-left: 8px;
        padding-right: 8px;
        font-size: 10px;
    }
}

@media (display-mode: standalone) {
    body {
        padding-top: max(0px, env(safe-area-inset-top));
    }

    header {
        top: max(6px, env(safe-area-inset-top));
    }
}

@media (min-width: 1000px) {
    .shell {
        padding-top: 26px;
    }

    .appFooter {
        padding-top: 28px;
    }
}
