/* TZ (Soonami) Color Palette — Linear Design */
:root {
    --tz-navy-dark: #2B3A4E;
    --tz-navy: #2E4A62;
    --tz-navy-light: #3D5A72;
    --tz-blue-gray: #607D8B;
    --tz-gray: #90A4AE;
    --tz-light-gray: #B0BEC5;
    --tz-bg: #F5F7FA;
    --tz-white: #FFFFFF;
    --tz-border: #E1E8ED;
    --tz-success: #26A69A;
    --tz-warning: #FFA726;
    --tz-warning-dark: #E65100;
    --tz-warning-bg: rgba(255, 167, 38, 0.08);
    --tz-warning-border: rgba(255, 167, 38, 0.25);
    --tz-error: #EF5350;
    --tz-error-bg: rgba(239, 83, 80, 0.08);
    --tz-error-border: rgba(239, 83, 80, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--tz-bg);
    color: var(--tz-navy);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Header — Linear clean style */
.header {
    height: 52px;
    background: var(--tz-navy-dark);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    height: 100%;
}

.logo {
    color: var(--tz-white);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.logo-icon {
    flex-shrink: 0;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.nav-link {
    color: var(--tz-light-gray);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 0 12px;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    height: 32px;
}

.nav-link:hover {
    color: var(--tz-white);
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: var(--tz-white);
    background: var(--tz-navy);
}

/* Main content */
.main {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px;
}

/* Barcode scan form */
.scan-form {
    margin-bottom: 16px;
}

.scan-form label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--tz-blue-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.scan-form input[type="text"] {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    border: 1px solid var(--tz-border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease;
    -webkit-appearance: none;
    background: var(--tz-white);
    color: var(--tz-navy-dark);
}

.scan-form input[type="text"]:focus {
    border-color: var(--tz-navy);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 10px;
    -webkit-appearance: none;
    transition: all 0.15s ease;
}

.btn-lookup {
    background: var(--tz-navy-dark);
    color: var(--tz-white);
}

.btn-lookup:hover {
    background: var(--tz-navy);
}

.btn-save {
    background: var(--tz-success);
    color: var(--tz-white);
}

.btn-save:hover {
    background: #1E8C82;
}

/* Product card */
.product-card {
    background: var(--tz-white);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--tz-border);
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--tz-navy-dark);
    letter-spacing: -0.02em;
}

.product-details {
    margin-bottom: 12px;
}

.detail {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--tz-border);
    font-size: 13px;
}

.detail .label {
    color: var(--tz-blue-gray);
    font-weight: 500;
}

.detail .value {
    font-weight: 500;
    text-align: right;
    color: var(--tz-navy-dark);
}

/* Last count — badge style */
.last-count {
    background: var(--tz-bg);
    border: 1px solid var(--tz-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.last-count .label {
    font-size: 12px;
    color: var(--tz-blue-gray);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.last-count .value {
    font-size: 20px;
    font-weight: 600;
    color: var(--tz-navy-dark);
}

.last-count .value.no-data {
    font-size: 13px;
    color: var(--tz-gray);
    font-weight: 400;
}

.last-count .date {
    font-size: 12px;
    color: var(--tz-gray);
}

.last-count .expiry {
    font-size: 12px;
    color: var(--tz-gray);
    width: 100%;
}

/* Stock form */
.stock-form .field {
    margin-bottom: 12px;
}

.stock-form label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--tz-blue-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.stock-form .optional {
    font-weight: 400;
    color: var(--tz-gray);
    text-transform: none;
    letter-spacing: normal;
}

.stock-form input[type="number"],
.stock-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--tz-border);
    border-radius: 8px;
    outline: none;
    -webkit-appearance: none;
    background: var(--tz-white);
    transition: border-color 0.15s ease;
    color: var(--tz-navy-dark);
}

.stock-form input:focus {
    border-color: var(--tz-navy);
}

/* Alerts */
.alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid;
}

.alert-error {
    background: var(--tz-error-bg);
    color: var(--tz-error);
    border-color: var(--tz-error-border);
}

.alert-fridge {
    background: var(--tz-warning-bg);
    color: var(--tz-warning-dark);
    border-color: var(--tz-warning-border);
    margin-bottom: 12px;
}

/* Toast */
.toast {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    animation: fade-in 0.3s ease;
}

.toast-success {
    background: var(--tz-success);
    color: var(--tz-white);
}

@keyframes fade-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Browse page */
.browse-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-form input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--tz-border);
    border-radius: 6px;
    outline: none;
    -webkit-appearance: none;
    background: var(--tz-white);
    transition: border-color 0.15s ease;
    color: var(--tz-navy-dark);
}

.search-form input[type="text"]::placeholder {
    color: var(--tz-gray);
}

.search-form input[type="text"]:focus {
    border-color: var(--tz-navy);
}

.search-form .btn {
    width: auto;
    margin-top: 0;
    padding: 8px 16px;
}

.result-count {
    font-size: 12px;
    color: var(--tz-gray);
    margin-bottom: 8px;
}

/* Table — Linear minimal */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--tz-white);
    border-radius: 8px;
    border: 1px solid var(--tz-border);
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.inv-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.inv-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--tz-blue-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--tz-border);
    white-space: nowrap;
}

.inv-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--tz-border);
    vertical-align: top;
    color: var(--tz-blue-gray);
}

.inv-table tr:last-child td {
    border-bottom: none;
}

.inv-table tbody tr:hover td {
    background: var(--tz-bg);
}

.inv-table .col-count {
    min-width: 140px;
}

.cell-product {
    font-weight: 500;
    color: var(--tz-navy-dark);
    font-size: 13px;
    line-height: 1.3;
}

.cell-brand {
    font-size: 11px;
    color: var(--tz-gray);
    margin-top: 2px;
}

.cell-mono {
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 12px;
}

.count-qty {
    font-size: 16px;
    font-weight: 600;
    color: var(--tz-navy-dark);
}

.count-date {
    font-size: 11px;
    color: var(--tz-gray);
    margin-top: 2px;
}

.count-expiry {
    font-size: 11px;
    color: var(--tz-gray);
}

.count-location {
    font-size: 11px;
    color: var(--tz-navy);
    font-weight: 500;
    margin-top: 2px;
}

.no-data {
    color: var(--tz-border);
}

.fridge-row {
    background: var(--tz-warning-bg);
}

/* Browse: grouped location rows */
.group-header td {
    font-weight: 600;
    border-bottom: none;
    padding-bottom: 4px;
}

.group-detail td {
    padding-top: 2px;
    padding-bottom: 2px;
    border-bottom: none;
    font-size: 12px;
    color: var(--tz-gray);
}

.group-detail:last-child td,
.group-detail + .group-header td {
    border-top: 1px solid var(--tz-border);
}

/* Ensure the last detail row before a new header has a bottom border */
.group-detail + .group-header td {
    padding-top: 10px;
}

.cell-location-total {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tz-gray);
}

.cell-location {
    font-size: 12px;
    font-weight: 500;
    color: var(--tz-navy);
    padding-left: 12px;
}

/* Scan: location counts */
.location-counts {
    margin: 12px 0 20px 0;
}

.location-counts-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--tz-navy-dark);
    margin: 0 0 8px 0;
}

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--tz-gray);
    font-size: 13px;
}

/* Location badge */
.location-badge {
    display: flex;
    align-items: stretch;
    background: var(--tz-navy-dark);
    color: var(--tz-white);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    overflow: hidden;
}

.location-badge .location-info {
    flex: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
}

.location-badge .location-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tz-light-gray);
}

.location-badge .location-value {
    font-weight: 600;
    font-size: 15px;
}

.location-badge .location-clear {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tz-white);
    text-decoration: none;
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    background: rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.location-badge .location-clear:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Location items section */
.location-items {
    margin-top: 24px;
}

.location-items-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tz-navy-dark);
    margin-bottom: 8px;
}

.location-items-count {
    font-weight: 400;
    color: var(--tz-gray);
    font-size: 13px;
}

/* Responsive — small screens */
@media (max-width: 480px) {
    .header {
        padding: 0 12px;
    }

    .main {
        padding: 16px 12px;
    }

    .browse-main {
        padding: 16px 12px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form .btn {
        width: 100%;
    }

    .scan-form input[type="text"] {
        font-size: 16px;
        padding: 10px;
    }

    .inv-table th,
    .inv-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .inv-table .col-count {
        min-width: 110px;
    }

    .count-qty {
        font-size: 14px;
    }

    .product-name {
        font-size: 15px;
    }

    .detail {
        font-size: 12px;
    }

    .last-count .value {
        font-size: 18px;
    }
}
