/* Shared app styles — Machine Logger */
* {
    box-sizing: border-box;
}

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

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 24px 16px 40px;
    background: #f4f7f9;
    color: #1a1a1a;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.container--narrow {
    max-width: 640px;
}

h1 {
    text-align: center;
    margin: 0 0 24px;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 700;
    color: #1e3a5f;
}

h2 {
    text-align: center;
    margin: 24px 0 16px;
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    font-weight: 700;
    color: #1e3a5f;
}

/* Toolbar / controls bar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #d0dae3;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.toolbar-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #5a6a7a;
    margin-right: 4px;
    white-space: nowrap;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.btn-group--actions {
    margin-left: auto;
}

.btn-group--center {
    justify-content: center;
    width: 100%;
}

/* Form controls */
select,
input[type="date"],
input[type="text"],
textarea {
    min-height: 44px;
    max-width: 100%;
    padding: 0 12px;
    font-size: 1rem; /* 16px prevents iOS zoom on focus */
    font-family: inherit;
    font-weight: 600;
    color: #1e3a5f;
    border: 1px solid #b8c5d0;
    border-radius: 8px;
    background: #fff;
}

select {
    min-width: 180px;
    cursor: pointer;
}

input[type="date"] {
    min-width: 0;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    font-weight: 400;
    resize: vertical;
    line-height: 1.45;
}

.field-full,
.panel select,
.panel input[type="date"] {
    width: 100%;
    min-width: 0;
}

select:focus,
input[type="date"]:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.panel label,
form:not(.toolbar) > label {
    display: block;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 6px;
    color: #1e3a5f;
}

.toolbar label {
    display: inline;
    margin: 0;
}

/* Buttons */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    min-height: 44px;
    height: auto;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    border: 1px solid #b8c5d0;
    border-radius: 8px;
    background: #fff;
    color: #1e3a5f;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}

button:hover,
.btn:hover {
    background: #eef3f7;
    border-color: #8fa3b5;
}

button.btn-primary,
.btn.btn-primary {
    background: #2d6a4f;
    border-color: #2d6a4f;
    color: #fff;
    min-width: 120px;
}

button.btn-primary:hover,
.btn.btn-primary:hover {
    background: #245a42;
    border-color: #245a42;
}

button.btn-active,
.btn.btn-active {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #fff;
}

button.btn-active:hover,
.btn.btn-active:hover {
    background: #162d4a;
    border-color: #162d4a;
}

/* Home nav grid */
.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 14px;
    max-width: 720px;
    margin: 0 auto;
}

.nav-grid button,
.nav-grid .btn {
    width: 100%;
    min-height: 64px;
    height: auto;
    padding: 16px 20px;
    font-size: 1.1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.nav-grid button.btn-primary,
.nav-grid .btn.btn-primary {
    background: #1e3a5f;
    border-color: #1e3a5f;
}

.nav-grid button.btn-primary:hover,
.nav-grid .btn.btn-primary:hover {
    background: #162d4a;
    border-color: #162d4a;
}

/* Secondary tools section (Analysis, Maintenance) */
.nav-tools {
    max-width: 720px;
    margin: 36px auto 0;
    padding-top: 28px;
    border-top: 1px solid #c5d0da;
}

.nav-tools__title {
    margin: 0 0 14px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7c8d;
    text-align: center;
}

.nav-tools__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.nav-tools .btn-tool {
    width: 100%;
    min-height: 52px;
    height: auto;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    background: transparent;
    border: 2px dashed #8fa3b5;
    color: #2d6a4f;
    box-shadow: none;
}

.nav-tools .btn-tool:hover {
    background: #e8f5ee;
    border-color: #2d6a4f;
    border-style: solid;
    color: #245a42;
}

/* Cards / panels */
.panel {
    background: #fff;
    border: 1px solid #d0dae3;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.table-wrap {
    background: #fff;
    border: 1px solid #d0dae3;
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Tables */
table {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
    font-family: "Courier New", Courier, monospace;
    font-size: clamp(0.85rem, 2vw, 1.05rem);
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e2e8ee;
    vertical-align: top;
    word-break: break-word;
}

th {
    background: #1e3a5f;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

tr:nth-child(even) td {
    background: #eef6f8;
}

tr:hover td {
    background: #e0edf2;
}

td.col-date {
    white-space: nowrap;
    font-weight: 600;
    color: #2c5282;
}

td.col-machine {
    font-weight: 600;
}

td.col-num,
th.col-num {
    text-align: center;
    white-space: nowrap;
}

td.col-desc {
    line-height: 1.5;
    color: #333;
}

.usage-inline {
    color: #2d6a4f;
    font-weight: 600;
    white-space: nowrap;
}

/* Summary / callout */
.summary {
    margin-top: 20px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #d0dae3;
    border-left: 4px solid #1e3a5f;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 1rem;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.usage-since {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 16px;
    margin: -8px 0 20px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #d0dae3;
    border-left: 4px solid #2d6a4f;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 1rem;
}

.usage-since__label {
    font-weight: 600;
    color: #1e3a5f;
}

.usage-since__value {
    font-family: "Courier New", Courier, monospace;
    font-size: 1.35rem;
    font-weight: 700;
    color: #2d6a4f;
}

.usage-since__meta {
    color: #6b7c8d;
    font-size: 0.9rem;
}

.total-bar {
    margin: 20px 0;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #d0dae3;
    border-left: 4px solid #2d6a4f;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e3a5f;
    overflow-wrap: anywhere;
}

.empty-msg {
    text-align: center;
    padding: 48px 20px;
    color: #6b7c8d;
    font-size: 1.05rem;
}

.success {
    color: #2d6a4f;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.error {
    color: #b00020;
    font-weight: 700;
    margin: 12px 0 16px;
    text-align: center;
    overflow-wrap: anywhere;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
}

.page-footer {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

/* —— Mobile —— */
@media (max-width: 640px) {
    body {
        padding: 16px 12px 32px;
    }

    h1 {
        margin-bottom: 18px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        gap: 12px;
    }

    .toolbar .btn-group {
        width: 100%;
        justify-content: flex-start;
    }

    .btn-group--actions {
        margin-left: 0;
    }

    .btn-group--actions button,
    .btn-group--actions .btn {
        flex: 1 1 auto;
    }

    .toolbar input[type="date"],
    .toolbar select {
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    /* Stack date filters: label above field */
    .toolbar .btn-group:not(.btn-group--actions) {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .toolbar .toolbar-label,
    .toolbar label.toolbar-label {
        display: block;
        margin: 8px 0 0;
        white-space: normal;
    }

    .toolbar .btn-group:not(.btn-group--actions) > .toolbar-label:first-child,
    .toolbar .btn-group:not(.btn-group--actions) > label.toolbar-label:first-child {
        margin-top: 0;
    }

    /* Row count buttons stay in a wrapping row */
    .toolbar .btn-group:has(button):not(.btn-group--actions) {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .toolbar .btn-group:has(button):not(.btn-group--actions) > .toolbar-label {
        display: inline;
        margin: 0 4px 0 0;
        width: auto;
    }

    select {
        min-width: 0;
        width: 100%;
    }

    .panel {
        padding: 14px;
    }

    th, td {
        padding: 8px 10px;
    }

    th {
        font-size: 0.75rem;
        letter-spacing: 0.02em;
    }

    td.col-date,
    td.col-machine {
        white-space: normal;
    }

    .usage-inline {
        display: inline-block;
        white-space: normal;
        margin-top: 4px;
    }

    .usage-since__value {
        font-size: 1.2rem;
    }

    .total-bar {
        font-size: 1rem;
        padding: 12px 14px;
    }

    .summary {
        font-size: 0.95rem;
        padding: 14px;
        line-height: 1.65;
    }

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

    .form-actions button,
    .form-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .nav-grid {
        gap: 10px;
    }

    .nav-grid button,
    .nav-grid .btn {
        min-height: 56px;
        font-size: 1rem;
        padding: 14px 16px;
    }

    .nav-tools {
        margin-top: 28px;
        padding-top: 22px;
    }

    .nav-tools__grid {
        grid-template-columns: 1fr;
    }

    .empty-msg {
        padding: 32px 16px;
    }

    .empty-msg button {
        width: 100%;
        max-width: 280px;
    }
}

@media (max-width: 380px) {
    body {
        padding: 12px 8px 28px;
    }

    table {
        min-width: 420px;
        font-size: 0.8rem;
    }

    .btn-group button {
        min-width: 52px;
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}
