/* GS Garage — UI inspirada em iOS (Safari / PWA) */
* { box-sizing: border-box; }

:root {
    --ios-bg: #f2f2f7;
    --ios-elevated: rgba(255, 255, 255, 0.82);
    --ios-card: #ffffff;
    --ios-text: #000000;
    --ios-secondary: rgba(60, 60, 67, 0.6);
    --ios-tertiary: rgba(60, 60, 67, 0.3);
    --ios-separator: rgba(60, 60, 67, 0.18);
    --ios-blue: #007aff;
    --ios-blue-press: #0062cc;
    --ios-green: #34c759;
    --ios-orange: #ff9500;
    --ios-red: #ff3b30;
    --ios-radius-lg: 22px;
    --ios-radius-md: 14px;
    --ios-radius-sm: 12px;
    --ios-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --ios-tabbar-h: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    color-scheme: light dark;
}

body.ios-shell {
    margin: 0;
    min-height: 100dvh;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Text",
        "SF Pro Display",
        "Inter",
        system-ui,
        sans-serif;
    color: var(--ios-text);
    background: var(--ios-bg);
    letter-spacing: -0.022em;
}

.ios-app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ——— Navbar (large title) ——— */
.ios-navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: calc(10px + var(--safe-top)) 16px 8px;
    background: rgba(242, 242, 247, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--ios-separator);
}

.ios-navbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 32px;
}

.ios-back {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: 42%;
    font-size: 17px;
    font-weight: 400;
    color: var(--ios-blue);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ios-back:active { opacity: 0.55; }

.ios-back-chev {
    font-size: 22px;
    font-weight: 500;
    line-height: 1;
    margin-top: -1px;
}

.ios-navbar-brand {
    font-size: 17px;
    font-weight: 600;
    color: var(--ios-text);
    letter-spacing: -0.03em;
}

.ios-navbar-spacer {
    width: 42%;
}

.ios-kicker {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ios-large-title {
    margin: 2px 0 0;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

/* ——— Conteúdo ——— */
.container.ios-main {
    flex: 1;
    width: 100%;
    max-width: min(960px, 100%);
    margin: 0 auto;
    padding: 12px 16px calc(24px + var(--ios-tabbar-h) + var(--safe-bottom));
}

h2 {
    margin: 20px 2px 10px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ios-section {
    margin-top: 8px;
}

.ios-footnote {
    margin: 6px 4px 12px;
    font-size: 13px;
    line-height: 1.35;
    color: var(--ios-secondary);
}

.ios-pill {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ios-secondary);
    background: rgba(60, 60, 67, 0.08);
    border-radius: 999px;
    vertical-align: middle;
}

a.ios-link-os {
    color: var(--ios-blue);
    font-weight: 700;
    text-decoration: none;
}
a.ios-link-os:active {
    opacity: 0.55;
}

/* KPI cards — estilo “widgets” iOS */
.cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (min-width: 520px) {
    .cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.card {
    background: var(--ios-card);
    border-radius: var(--ios-radius-md);
    padding: 14px 14px 12px;
    box-shadow: var(--ios-shadow);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
}

.card h3 {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-secondary);
    letter-spacing: -0.01em;
}

.big {
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

/* Formulários — grouped inset */
form {
    background: var(--ios-card);
    border-radius: var(--ios-radius-lg);
    padding: 14px 14px 6px;
    margin-bottom: 14px;
    border: 0.5px solid var(--ios-separator);
    box-shadow: var(--ios-shadow);
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    margin-left: 2px;
    color: var(--ios-secondary);
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: none;
    border-radius: var(--ios-radius-sm);
    font-size: 17px;
    background: #f2f2f7;
    color: var(--ios-text);
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
    background: #e8e8ed;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Botão primário iOS */
button {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: none;
    border-radius: var(--ios-radius-sm);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #fff;
    background: var(--ios-blue);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    background: var(--ios-blue-press);
    transform: scale(0.985);
}

/* Toast / flash */
.ios-toast {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: var(--ios-radius-md);
    font-size: 15px;
    font-weight: 500;
    color: #0f5132;
    background: #d1e7dd;
    border: 0.5px solid #badbcc;
}

/* Tabelas — lista agrupada */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--ios-card);
    border-radius: var(--ios-radius-lg);
    overflow: hidden;
    border: 0.5px solid var(--ios-separator);
    box-shadow: var(--ios-shadow);
}

th,
td {
    text-align: left;
    padding: 12px 14px;
    font-size: 15px;
    border-bottom: 0.5px solid var(--ios-separator);
}

th {
    font-size: 13px;
    font-weight: 600;
    color: var(--ios-secondary);
    background: rgba(242, 242, 247, 0.9);
}

tr:last-child td,
tr:last-child th {
    border-bottom: none;
}

tr:active td {
    background: rgba(0, 0, 0, 0.03);
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 0 10px;
}

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

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

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

.status-aberta,
.status-aberto {
    color: var(--ios-orange);
    font-weight: 600;
}

.status-em_andamento {
    color: var(--ios-blue);
    font-weight: 600;
}

.status-finalizada,
.status-fechado {
    color: var(--ios-green);
    font-weight: 600;
}

.status-cotando {
    color: #5856d6;
    font-weight: 600;
}

.status-comprado {
    color: #32ade6;
    font-weight: 600;
}

.muted {
    color: var(--ios-secondary);
    font-size: 15px;
    line-height: 1.35;
    margin: 4px 2px 14px;
}

.ios-owner-intro {
    margin: 0 0 14px;
    font-size: 16px;
    line-height: 1.4;
}

/* ——— Tab bar (inferior) ——— */
.ios-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    gap: 0;
    min-height: var(--ios-tabbar-h);
    padding: 6px 4px calc(6px + var(--safe-bottom));
    background: rgba(250, 250, 250, 0.88);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 0.5px solid var(--ios-separator);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ios-tabbar::-webkit-scrollbar {
    display: none;
}

.ios-tab {
    flex: 1 0 auto;
    min-width: 56px;
    max-width: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    font-size: 10px;
    font-weight: 500;
    color: var(--ios-secondary);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ios-tab-icon {
    font-size: 22px;
    line-height: 1;
    opacity: 0.92;
}

.ios-tab-label {
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.ios-tab.is-active {
    color: var(--ios-blue);
}

.ios-tab.is-active .ios-tab-icon {
    transform: translateY(-0.5px);
}

.ios-tab:active {
    opacity: 0.55;
}

@media (min-width: 900px) {
    .ios-tabbar {
        max-width: min(960px, 100%);
        left: 50%;
        transform: translateX(-50%);
        border-radius: 18px 18px 0 0;
        border-left: 0.5px solid var(--ios-separator);
        border-right: 0.5px solid var(--ios-separator);
    }
}

/* Busca no topo */
.ios-search {
    margin: 10px 0 0;
}

.ios-search input[type="search"] {
    width: 100%;
    padding: 10px 14px 10px 36px;
    margin-bottom: 0;
    border-radius: 10px;
    border: none;
    font-size: 17px;
    background: rgba(118, 118, 128, 0.12);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%238e8e93' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px 50%;
}

.ios-search input[type="search"]::placeholder {
    color: var(--ios-secondary);
}

.ios-search input[type="search"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
}

/* Alerta estoque */
.ios-alert {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: var(--ios-radius-md);
    font-size: 15px;
    background: rgba(255, 149, 0, 0.12);
    border: 0.5px solid rgba(255, 149, 0, 0.35);
    color: #1c1c1e;
}

.ios-alert a {
    color: var(--ios-blue);
    font-weight: 600;
    margin-left: 6px;
}

/* Detalhes expansíveis (recepção) */
.ios-details {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--ios-radius-sm);
    background: rgba(118, 118, 128, 0.08);
}

.ios-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    color: var(--ios-blue);
}

.ios-quicklinks {
    margin: 0 0 16px;
    font-size: 15px;
    text-align: center;
}

.ios-quicklinks a {
    color: var(--ios-blue);
    font-weight: 600;
    text-decoration: none;
}

.ios-dot {
    color: var(--ios-secondary);
    margin: 0 6px;
}

/* Linha estoque crítico */
tr.row-low td {
    background: rgba(255, 59, 48, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg: #000000;
        --ios-card: #1c1c1e;
        --ios-text: #f2f2f7;
        --ios-secondary: rgba(235, 235, 245, 0.6);
        --ios-separator: rgba(84, 84, 88, 0.65);
    }

    body.ios-shell {
        background: var(--ios-bg);
        color: var(--ios-text);
    }

    .ios-navbar {
        background: rgba(28, 28, 30, 0.86);
        border-bottom-color: var(--ios-separator);
    }

    .ios-navbar-brand {
        color: var(--ios-text);
    }

    .ios-large-title {
        color: var(--ios-text);
    }

    .ios-kicker {
        color: var(--ios-secondary);
    }

    input,
    select,
    textarea {
        background: #2c2c2e !important;
        color: var(--ios-text) !important;
        border-color: transparent !important;
    }

    input:focus,
    select:focus,
    textarea:focus {
        background: #3a3a3c !important;
    }

    .card,
    table,
    form {
        background: var(--ios-card);
        border-color: var(--ios-separator);
    }

    th {
        background: #2c2c2e;
        color: var(--ios-secondary);
    }

    tr:active td {
        background: rgba(255, 255, 255, 0.05);
    }

    .ios-tabbar {
        background: rgba(28, 28, 30, 0.92);
        border-top-color: var(--ios-separator);
    }

    .ios-search input[type="search"] {
        background-color: rgba(118, 118, 128, 0.24);
        color: var(--ios-text);
    }

    .ios-toast {
        background: rgba(52, 199, 89, 0.2);
        border-color: rgba(52, 199, 89, 0.45);
        color: #b8f5c0;
    }

    .ios-alert {
        background: rgba(255, 159, 10, 0.18);
        border-color: rgba(255, 159, 10, 0.4);
        color: #f2f2f7;
    }

    tr.row-low td {
        background: rgba(255, 69, 58, 0.15);
    }

    .muted {
        color: var(--ios-secondary);
    }
}
