/* ==========================================================================
   Arretados Lab — FTC Arretados Tech · BIOBUZZ
   Tema escuro, cor principal laranja #fe5c00, layout mobile-first.
   ========================================================================== */

:root {
    --primary: #fe5c00;
    --primary-dark: #d94e00;
    --primary-soft: rgba(254, 92, 0, .14);
    --primary-ring: rgba(254, 92, 0, .35);

    --bg: #0e0f12;
    --surface: #16181d;
    --surface-2: #1d2026;
    --surface-3: #24282f;
    --border: #2a2e37;
    --border-strong: #3a3f4a;

    --text: #e9ebef;
    --text-muted: #969dab;
    --text-dim: #6e7684;

    --ok: #3fbf7f;
    --ok-soft: rgba(63, 191, 127, .14);
    --danger: #ff5c5c;
    --danger-soft: rgba(255, 92, 92, .14);
    --info: #4aa3ff;
    --info-soft: rgba(74, 163, 255, .14);
    --warn: #f5b13d;
    --warn-soft: rgba(245, 177, 61, .14);
    --violet: #a97bff;
    --violet-soft: rgba(169, 123, 255, .14);

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);

    --topbar-h: 60px;
    --bottomnav-h: 62px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4 {
    margin: 0 0 .5rem;
    line-height: 1.25;
    font-weight: 650;
    letter-spacing: -.01em;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .8rem; }

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

code, pre, .mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.small { font-size: .82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------- topbar -- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(14, 15, 18, .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: var(--topbar-h);
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 .9rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 11px;
    background: linear-gradient(145deg, var(--primary), #ff8a3d);
    color: #1a0d00;
    font-weight: 800;
    font-size: .85rem;
    letter-spacing: -.02em;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.brand-text strong {
    font-size: .95rem;
    white-space: nowrap;
}

.brand-text small {
    color: var(--text-dim);
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.user-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    max-width: 42vw;
}

.user-name {
    font-size: .82rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-area {
    font-size: .68rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ------------------------------------------------------------- navegação -- */

.mainnav {
    display: none;
}

.mainnav a {
    display: block;
    padding: .55rem .1rem;
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 550;
    border-bottom: 2px solid transparent;
    text-decoration: none;
}

.mainnav a.is-active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.mainnav .nav-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: .3rem;
    border-radius: 9px;
    background: var(--primary);
    color: #1a0d00;
    font-size: .68rem;
    font-weight: 700;
    text-align: center;
    vertical-align: 1px;
}

.bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    background: rgba(18, 20, 24, .96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: var(--bottomnav-h);
    color: var(--text-dim);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-decoration: none;
    position: relative;
}

.bottomnav a.is-active { color: var(--primary); }

.bottomnav a.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 2px;
    border-radius: 0 0 3px 3px;
    background: var(--primary);
}

.bottomnav .nav-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.bottomnav .nav-count {
    position: absolute;
    top: 6px;
    left: 50%;
    margin-left: 6px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--primary);
    color: #1a0d00;
    font-size: .62rem;
    font-weight: 800;
    text-align: center;
}

/* -------------------------------------------------------------- layout --- */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem .9rem calc(var(--bottomnav-h) + 1.5rem);
}

.page-head {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-bottom: 1rem;
}

.page-head .eyebrow {
    color: var(--primary);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.page-head h1 { margin: 0; }

.page-head .lede {
    color: var(--text-muted);
    margin: 0;
    font-size: .9rem;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }

/* --------------------------------------------------------------- cards --- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.card + .card { margin-top: 1rem; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.card-head h2,
.card-head h3 { margin: 0; }

.card-sub {
    color: var(--text-dim);
    font-size: .8rem;
    margin: .1rem 0 0;
}

.card-soft {
    background: var(--surface-2);
    border-color: transparent;
}

/* lista de itens */

.item-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.item {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem .9rem;
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}

.item:hover {
    border-color: var(--primary);
    background: var(--surface-2);
    text-decoration: none;
}

.item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
}

.item-title {
    font-weight: 620;
    font-size: .98rem;
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.item-meta {
    color: var(--text-dim);
    font-size: .76rem;
    margin-top: .3rem;
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .6rem;
}

.item-desc {
    color: var(--text-muted);
    font-size: .86rem;
    margin-top: .4rem;
}

/* --------------------------------------------------------------- botões -- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .62rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-size: .87rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #1a0d00;
}

.btn-primary:hover { background: #ff6f1f; }

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); }

.btn-ok {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: rgba(63, 191, 127, .35);
}

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(255, 92, 92, .35);
}

.btn-sm { padding: .42rem .7rem; font-size: .79rem; }
.btn-block { width: 100%; }

.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- pills -- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-idealizacao { background: var(--surface-3); color: var(--text-muted); border-color: var(--border-strong); }
.badge-producao    { background: var(--info-soft); color: var(--info); border-color: rgba(74, 163, 255, .3); }
.badge-teste       { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 177, 61, .3); }
.badge-revisao     { background: var(--violet-soft); color: var(--violet); border-color: rgba(169, 123, 255, .3); }
.badge-aprovado    { background: var(--ok-soft); color: var(--ok); border-color: rgba(63, 191, 127, .3); }
.badge-reprovado   { background: var(--danger-soft); color: var(--danger); border-color: rgba(255, 92, 92, .3); }
.badge-outro       { background: var(--surface-3); color: var(--text-muted); border-color: var(--border-strong); }

.version-pill {
    display: inline-flex;
    align-items: center;
    padding: .18rem .5rem;
    border-radius: 7px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-ring);
    font-size: .72rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.version-pill.is-old {
    background: var(--surface-3);
    color: var(--text-dim);
    border-color: var(--border-strong);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
}

/* --------------------------------------------------------------- forms --- */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: .9rem;
}

.field label {
    display: block;
    font-size: .82rem;
    font-weight: 650;
    margin-bottom: .3rem;
}

.field .hint {
    display: block;
    color: var(--text-dim);
    font-size: .76rem;
    font-weight: 400;
    margin-top: .25rem;
    line-height: 1.4;
}

.field .required {
    color: var(--primary);
    margin-left: .15rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: .68rem .75rem;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

textarea.code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    min-height: 200px;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.2rem;
}

input[type="file"] {
    width: 100%;
    padding: .6rem .7rem;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font: inherit;
    font-size: .85rem;
}

input[type="file"]::file-selector-button {
    margin-right: .7rem;
    padding: .4rem .7rem;
    border: 0;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}

/* escolha de área no cadastro */

.choice-row {
    display: grid;
    gap: .5rem;
}

.choice {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem .8rem;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.choice input {
    margin: .22rem 0 0;
    accent-color: var(--primary);
}

.choice-body strong {
    display: block;
    font-size: .9rem;
}

.choice-body span {
    display: block;
    color: var(--text-dim);
    font-size: .78rem;
    margin-top: .1rem;
}

.choice:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* -------------------------------------------------------------- alerts --- */

.alert {
    padding: .75rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-size: .87rem;
    margin-bottom: .8rem;
}

.alert-error { background: var(--danger-soft); border-color: rgba(255, 92, 92, .35); color: #ffb3b3; }
.alert-success { background: var(--ok-soft); border-color: rgba(63, 191, 127, .35); color: #9fe8c3; }
.alert-info { background: var(--info-soft); border-color: rgba(74, 163, 255, .35); color: #b3d8ff; }
.alert-warn { background: var(--warn-soft); border-color: rgba(245, 177, 61, .35); color: #ffdca3; }

.alert ul { margin: .3rem 0 0; padding-left: 1.1rem; }

/* --------------------------------------------------------------- tabela -- */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    min-width: 520px;
}

th, td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }

.row-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------- diff/CAD -- */

.diff-row {
    display: grid;
    gap: .4rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}

.diff-row:last-child { border-bottom: 0; }

.diff-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.diff-side {
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: .84rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.diff-before {
    background: var(--danger-soft);
    border-color: rgba(255, 92, 92, .25);
    color: #ffc4c4;
}

.diff-after {
    background: var(--ok-soft);
    border-color: rgba(63, 191, 127, .25);
    color: #b6ebd1;
}

.diff-arrow {
    color: var(--text-dim);
    font-size: .8rem;
    text-align: center;
}

/* código */

.code-block {
    margin: 0;
    padding: .8rem .85rem;
    background: #0b0c0f;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: .8rem;
    line-height: 1.55;
    tab-size: 4;
}

.code-diff {
    margin: 0;
    padding: .4rem 0;
    background: #0b0c0f;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: .78rem;
    line-height: 1.5;
}

.code-diff .line {
    display: block;
    padding: 0 .75rem 0 2.6rem;
    position: relative;
    white-space: pre;
}

.code-diff .line::before {
    content: attr(data-sign);
    position: absolute;
    left: .7rem;
    color: var(--text-dim);
}

.code-diff .line-add { background: rgba(63, 191, 127, .12); color: #b6ebd1; }
.code-diff .line-del { background: rgba(255, 92, 92, .12); color: #ffc4c4; }
.code-diff .line-same { color: var(--text-muted); }

.code-diff .line-gap {
    color: var(--text-dim);
    background: var(--surface-2);
    font-style: italic;
    padding-left: .75rem;
}

.code-diff .line-gap::before { content: ""; }

/* visualizador de CAD */

.cad-viewer {
    position: relative;
    height: 60vh;
    min-height: 320px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: #08090b;
    touch-action: none;
}

.cad-viewer canvas { display: block; }

.cad-status {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: .5rem;
    text-align: center;
    padding: 1.2rem;
    color: var(--text-muted);
    font-size: .87rem;
    background: rgba(8, 9, 11, .88);
}

.cad-status.is-hidden { display: none; }

.cad-toolbar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .6rem;
}

.cad-hint {
    color: var(--text-dim);
    font-size: .76rem;
    margin-top: .5rem;
}

/* --------------------------------------------------------------- misc ---- */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state h1,
.empty-state h2 { color: var(--text); }

.empty-state .btn { margin-top: .6rem; }

.auth-shell {
    max-width: 420px;
    margin: 0 auto;
    padding: 1.6rem .9rem calc(var(--bottomnav-h) + 1.5rem);
}

.auth-shell .brand {
    justify-content: center;
    margin-bottom: 1.2rem;
}

.auth-shell .brand-text { align-items: flex-start; }

.auth-foot {
    text-align: center;
    color: var(--text-dim);
    font-size: .84rem;
    margin-top: 1rem;
}

.meta-grid {
    display: grid;
    gap: .55rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-grid .meta-item {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: .55rem .7rem;
    min-width: 0;
}

.meta-grid .meta-key {
    display: block;
    color: var(--text-dim);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.meta-grid .meta-value {
    display: block;
    font-size: .87rem;
    margin-top: .1rem;
    overflow-wrap: anywhere;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.timeline li {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .6rem .7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.timeline li.is-current {
    border-color: var(--primary-ring);
    background: var(--primary-soft);
}

.timeline .timeline-body {
    flex: 1;
    min-width: 0;
}

.timeline .timeline-meta {
    color: var(--text-dim);
    font-size: .74rem;
}

/* ------------------------------------------------------------ desktop --- */

@media (min-width: 720px) {
    body { font-size: 15.5px; }

    .container { padding: 1.4rem 1.2rem 2.5rem; }

    .page-head {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }

    .page-head .lede { max-width: 62ch; }

    .form-grid { gap: 1rem; }

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

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

    .diff-row { grid-template-columns: 1fr auto 1fr; align-items: center; }

    .diff-label { grid-column: 1 / -1; }

    .cad-viewer { height: 66vh; }
}

@media (min-width: 900px) {
    .bottomnav { display: none; }

    .container { padding-bottom: 2.5rem; }

    .topbar-inner { padding: 0 1.2rem; }

    .mainnav {
        display: flex;
        gap: 1.4rem;
        max-width: 1100px;
        margin: 0 auto;
        padding: 0 1.2rem;
    }

    .mainnav a { padding: .6rem 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
