:root {
    --ink: #26211a;
    --ink-soft: #5b5449;
    --paper: #f8f5ee;
    --paper-2: #ffffff;
    --line: #e2dbcc;
    --green: #3f5a22;
    --green-dark: #2f431a;
    --gold: #a07d2a;
    --danger: #a3372c;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(38, 33, 26, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--green);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 0.35em;
}

.title {
    font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.15rem);
    margin-bottom: 0.25em;
}

.section-title {
    font-size: 1.12rem;
    margin-bottom: 0.6em;
}

.muted {
    color: var(--ink-soft);
    margin-top: 0;
}

.small {
    font-size: 0.85rem;
}

/* Top bar */
.topbar {
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    font-weight: 600;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--green);
    color: #fff;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
}

.brand-large {
    margin-bottom: 1rem;
}

.brand-large .brand-mark {
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-right: auto;
}

.nav a {
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.nav a:hover {
    background: #f1ece1;
    text-decoration: none;
}

.nav a.active {
    background: #eae4d6;
    color: var(--green-dark);
    font-weight: 600;
}

.nav-search input {
    width: 170px;
    padding: 0.35rem 0.6rem;
    font-size: 0.86rem;
    border-radius: 999px;
    background: #fbf8f0;
}

.nav-search {
    display: flex;
}

.logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.who {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/* Layout */
.page {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    flex: 1;
}

.page.narrow {
    max-width: 640px;
}

.footer {
    border-top: 1px solid var(--line);
    background: var(--paper-2);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--ink-soft);
    font-size: 0.82rem;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.25rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: 0;
}

.stat-value {
    font-family: Georgia, serif;
    font-size: 1.9rem;
    color: var(--green-dark);
}

.stat-label {
    color: var(--ink-soft);
    font-size: 0.88rem;
}

.modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.module {
    margin: 0;
}

.module h3 {
    font-size: 1.05rem;
}

.module p {
    color: var(--ink-soft);
    font-size: 0.92rem;
    margin: 0 0 0.75rem;
}

.badge,
.pill {
    display: inline-block;
    padding: 0.16rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: #efe8d6;
    color: #7a6320;
}

.pill-ok {
    background: #e3eedd;
    color: var(--green-dark);
}

.pill-off {
    background: #f0e3e0;
    color: var(--danger);
}

.pill-warn {
    background: #f6ead0;
    color: #8a5b12;
}

/* Forms */
.stack {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-top: 0.5rem;
}

input,
select {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fffdf8;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
}

input:focus,
select:focus,
button:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}

input[type="file"] {
    padding: 0.45rem;
    background: #fbf8f0;
}

.wide {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.82rem;
}

.row-form {
    display: flex;
    gap: 0.9rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.field {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
}

.inline {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
}

.inline select,
.reset input {
    width: auto;
    font-size: 0.85rem;
    padding: 0.35rem 0.45rem;
}

/* Buttons */
.button {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.6rem 1.1rem;
    border: 0;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: var(--green-dark);
    text-decoration: none;
}

.button.secondary {
    background: #eef2e8;
    color: var(--green-dark);
    border: 1px solid #d6dfc9;
}

.button.secondary:hover {
    background: #e3ead9;
}

.button.danger {
    background: var(--danger);
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--green);
    font: inherit;
    font-size: 0.87rem;
    cursor: pointer;
    text-decoration: underline;
}

.link-button.danger {
    color: var(--danger);
}

/* Flash messages */
.flash-holder {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
}

.flash.success {
    background: #e6f0df;
    border: 1px solid #cfe0c1;
    color: var(--green-dark);
}

.flash.error {
    background: #fbeae7;
    border: 1px solid #f0cdc6;
    color: var(--danger);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    text-align: left;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.5rem;
    white-space: nowrap;
}

.table td {
    border-bottom: 1px solid #f0ebe0;
    padding: 0.6rem 0.5rem;
    vertical-align: top;
}

.table tr:last-child td {
    border-bottom: 0;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.right {
    text-align: right;
}

.facts {
    display: grid;
    grid-template-columns: minmax(150px, 220px) 1fr;
    gap: 0.4rem 1rem;
    margin: 0 0 1rem;
}

.facts dt {
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.facts dd {
    margin: 0;
}

/* Auth pages */
.auth-body {
    background:
        radial-gradient(1200px 500px at 15% -10%, #e9e3d2 0%, transparent 60%),
        radial-gradient(900px 400px at 100% 0%, #dfe6d3 0%, transparent 55%),
        var(--paper);
}

.auth-wrap {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 2.5rem 1.25rem;
}

.auth-card {
    width: 100%;
    max-width: 430px;
}

.auth-card .button {
    width: 100%;
}

/* Security page */
.qr {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0;
}

.qr img {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.secret {
    display: block;
    padding: 0.6rem 0.75rem;
    background: #f3efe4;
    border-radius: 9px;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    word-break: break-all;
    margin-bottom: 0.5rem;
}

.quick {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.quick .button {
    margin-top: 0;
}

/* Contacts and companies */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.crumbs {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.tag {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    margin: 0 0.25rem 0.25rem 0;
    border-radius: 999px;
    background: #eef2e8;
    color: var(--green-dark);
    font-size: 0.74rem;
    font-weight: 600;
}

.badge-live {
    background: #e3eedd;
    color: var(--green-dark);
}

.timeline {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline li {
    border-left: 3px solid var(--line);
    padding-left: 0.9rem;
}

.timeline-meta {
    display: flex;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.prewrap {
    white-space: pre-wrap;
    margin: 0.25rem 0 0.5rem;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    margin-top: 0.9rem;
}

.checkline input {
    width: auto;
    margin: 0;
}

.tabs {
    display: flex;
    gap: 0.35rem;
    margin: 0 0 1.25rem;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    padding: 0.45rem 0.85rem;
    font-size: 0.92rem;
    color: var(--ink-soft);
    border-bottom: 2px solid transparent;
    border-radius: 8px 8px 0 0;
}

.tabs a:hover {
    background: #f1ece1;
    text-decoration: none;
}

.tabs a.active {
    color: var(--green-dark);
    border-bottom-color: var(--green);
    font-weight: 600;
    background: #f6f3ea;
}

.item-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}

.item-detail {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.item-photo img {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    object-fit: cover;
}

.methods {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    margin: 0.9rem 0 0;
}

.methods legend {
    padding: 0 0.35rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.methods .checkline {
    margin-top: 0.4rem;
}

@media (max-width: 760px) {
    .item-detail {
        grid-template-columns: 1fr;
    }
}

textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fffdf8;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

textarea:focus {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}


@media (max-width: 640px) {
    .topbar-inner {
        gap: 0.75rem;
    }

    .nav {
        order: 3;
        width: 100%;
        margin-right: 0;
    }

    .logout {
        margin-left: auto;
    }

    .facts {
        grid-template-columns: 1fr;
    }

    .facts dt {
        margin-top: 0.5rem;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
