:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #647084;
    --line: #d9e0e8;
    --primary: #0f6bff;
    --primary-dark: #074dbb;
    --teal: #0f8f8c;
    --danger: #cf2e2e;
    --warning: #b7791f;
    --success: #157347;
    --nav-dark: #101827;
    --nav-darker: #0b1220;
    --nav-line: rgba(255, 255, 255, 0.12);
    --nav-muted: #aab6c8;
    --shadow: 0 12px 34px rgba(31, 42, 68, 0.08);
    --content-max: 1360px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    display: none;
}

.main {
    min-height: 100vh;
    padding: 18px 14px 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 auto 18px;
    max-width: var(--content-max);
}

.page-title {
    max-width: var(--content-max);
    margin: 0 auto 18px;
    min-width: 0;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    white-space: nowrap;
}

.mobile-brand .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 26px;
}

.mobile-brand strong {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
}

.page-title h1,
.login-brand h1,
.section-head h2,
.detail-panel h2,
.form-card h2 {
    margin: 0;
    letter-spacing: 0;
    color: var(--ink);
}

.page-title h1 {
    font-size: 24px;
    font-weight: 750;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--teal);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.new-order-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    padding: 0 14px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, #0f6bff 0%, #074dbb 100%);
    box-shadow: 0 10px 22px rgba(15, 107, 255, 0.22);
    font-size: 14px;
    font-weight: 750;
    white-space: nowrap;
}

.new-order-button:hover {
    background: linear-gradient(135deg, #075bd8 0%, #063f99 100%);
}

.action-icon {
    position: relative;
    display: inline-block;
    width: 17px;
    height: 20px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 4px;
}

.action-icon::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 3px;
    width: 7px;
    height: 4px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    background: transparent;
}

.action-icon::after {
    content: "";
    position: absolute;
    top: 6px;
    left: 4px;
    width: 7px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 5px 0 rgba(255, 255, 255, 0.9);
}

.top-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.menu {
    position: relative;
}

.menu summary {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--nav-line);
    border-radius: 8px;
    background: var(--nav-dark);
    color: #fff;
    font-size: 24px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu-panel {
    position: absolute;
    top: 52px;
    right: 0;
    z-index: 20;
    display: grid;
    width: min(88vw, 360px);
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--nav-line);
    border-radius: 8px;
    background: var(--nav-dark);
    box-shadow: 0 22px 60px rgba(9, 17, 32, 0.28);
    color: #fff;
}

.menu-panel strong {
    color: #fff;
}

.menu-panel span {
    margin-bottom: 10px;
    color: var(--nav-muted);
    font-size: 13px;
}

.menu-panel a {
    padding: 12px;
    border-radius: 8px;
    color: #fff;
    font-weight: 650;
}

.menu-panel a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: #2563eb;
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
}

.brand small,
.order-card span,
td span,
.metric span,
.section-head p,
.upload-box small,
.timeline span {
    color: var(--muted);
}

.alert {
    max-width: var(--content-max);
    margin: 0 auto 16px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eefaf4;
    color: #0f5132;
}

.alert-danger {
    background: #fff0f0;
    color: #9b1c1c;
}

@media (max-width: 520px) {
    .new-order-button {
        width: 44px;
        min-width: 44px;
        padding: 0;
        justify-content: center;
    }

    .new-order-button span:last-child {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

.metric-grid,
.single-kpi,
.dashboard-kpis,
.detail-grid,
.form-card,
.filter-bar,
.table-wrap,
.section-head,
.order-list,
.entry-list,
.pagination {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
}

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

.single-kpi {
    display: grid;
    max-width: 560px;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.metric,
.detail-panel,
.form-card,
.order-card,
.empty-state,
.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.metric {
    padding: 16px;
}

.dashboard-kpis .metric {
    position: relative;
    overflow: hidden;
    border: 0;
    color: #fff;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}

.dashboard-kpis .metric:nth-child(2) {
    background: linear-gradient(135deg, #164e63 0%, #0f766e 100%);
}

.dashboard-kpis .metric span,
.dashboard-kpis .metric small {
    color: rgba(255, 255, 255, 0.82);
}

.dashboard-kpis .metric strong {
    color: #fff;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 0;
}

.metric small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-weight: 750;
}

.metric.danger strong {
    color: var(--danger);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    margin-bottom: 12px;
}

.section-head p {
    margin: 4px 0 0;
}

.order-list {
    display: grid;
    gap: 10px;
}

.entry-list {
    display: grid;
    gap: 10px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.pagination span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.pagination-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-weight: 750;
    box-shadow: 0 8px 20px rgba(31, 42, 68, 0.05);
}

.pagination-button:not(.disabled):hover {
    border-color: rgba(15, 107, 255, 0.45);
    color: var(--primary-dark);
}

.pagination-button.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.admin-user-list,
.admin-create-panel {
    display: grid;
    max-width: var(--content-max);
    gap: 10px;
    margin: 0 auto;
}

.admin-create-panel {
    gap: 14px;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.admin-create-panel h2 {
    margin: 0;
    font-size: 18px;
}

.create-user-form {
    display: grid;
    gap: 12px;
}

.user-row {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.user-identity {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.user-identity strong,
.user-identity span {
    display: block;
}

.user-identity strong {
    font-weight: 650;
}

.user-identity span {
    margin-top: 4px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 13px;
}

.entry-row {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.entry-row:hover {
    border-color: #b8c7da;
    background: #fbfdff;
}

.entry-row strong {
    display: block;
    margin-bottom: 5px;
    font-weight: 650;
}

.entry-row span,
.entry-row p,
.entry-meta span {
    color: var(--muted);
}

.entry-row p {
    display: -webkit-box;
    margin: 8px 0 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.entry-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.order-card {
    display: grid;
    gap: 7px;
    padding: 14px;
}

.order-no {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    background: #eef2f7;
    color: #3b4658;
}

.severity-critical {
    background: #ffe8e8;
    color: #a51616;
}

.severity-high {
    background: #fff1dc;
    color: #8a4a00;
}

.severity-medium {
    background: #e8f1ff;
    color: #0d55bd;
}

.severity-low {
    background: #e7f7ef;
    color: #11623a;
}

.form-card {
    display: grid;
    gap: 16px;
    padding: 16px;
}

.simple-work-order {
    max-width: 720px;
}

.mandatory-note {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.mandatory-note span {
    color: var(--danger);
}

.form-grid {
    display: grid;
    gap: 14px;
}

label,
fieldset {
    display: grid;
    gap: 7px;
    margin: 0;
    color: #253047;
    font-weight: 600;
}

label span,
legend span {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    background: #fff;
    font-weight: 450;
}

textarea {
    resize: vertical;
}

input[readonly] {
    background: #f0f4f8;
    color: var(--muted);
}

.prefix-input {
    display: grid;
    grid-template-columns: auto minmax(90px, 1fr);
    min-height: 48px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.prefix-input span {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-right: 1px solid var(--line);
    background: #f0f4f8;
    color: #273248;
    white-space: nowrap;
}

.prefix-input input {
    min-height: 46px;
    border: 0;
    border-radius: 0;
}

.severity-field {
    border: 0;
    padding: 0;
}

.severity-field legend {
    margin-bottom: 7px;
    font-weight: 650;
}

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

.severity-field legend {
    grid-column: 1 / -1;
}

.severity-field label {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.severity-field input {
    width: 18px;
    min-height: auto;
    margin-right: 8px;
}

.upload-box {
    padding: 14px;
    border: 1px dashed #aeb8c6;
    border-radius: 8px;
    background: #fbfcfe;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-top: 10px;
    background: linear-gradient(to top, var(--panel) 75%, rgba(255,255,255,0));
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
}

.primary-button {
    color: #fff;
    background: var(--primary);
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: #fff;
}

.danger-button {
    border: 1px solid #f0b8b8;
    color: #a51616;
    background: #fff5f5;
}

.danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.filter-bar {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
}

td span {
    display: block;
    margin-top: 5px;
    font-size: 13px;
}

tbody tr {
    cursor: pointer;
}

tbody tr:hover {
    background: #f8fafc;
}

.detail-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.detail-actions {
    display: flex;
    max-width: var(--content-max);
    margin: 0 auto;
}

.detail-panel {
    padding: 16px;
}

.work-order-detail {
    padding: 0;
    overflow: hidden;
}

.detail-title {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-hero {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(135deg, rgba(15, 107, 255, 0.08), rgba(15, 143, 140, 0.08)),
        #fff;
}

.detail-heading {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.detail-heading h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 780;
    color: var(--ink);
}

.detail-heading span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.definition-grid {
    display: grid;
    gap: 12px;
    margin: 0;
}

.detail-facts {
    padding: 16px;
}

.detail-facts > div {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.definition-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
}

.definition-grid dd {
    margin: 3px 0 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.detail-note {
    padding: 0 16px 16px;
}

.detail-note h3 {
    margin: 0 0 8px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 750;
}

.note-box {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f9fc;
    color: #273248;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 10px;
}

.photo-grid a {
    display: grid;
    gap: 6px;
}

.photo-grid img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline div {
    padding-left: 12px;
    border-left: 3px solid var(--primary);
}

.timeline p {
    margin: 5px 0 0;
}

.empty-state {
    padding: 18px;
    color: var(--muted);
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
    background: linear-gradient(180deg, #f5f9ff 0%, #eef7f5 100%);
}

.login-panel {
    width: min(100%, 440px);
}

.login-brand {
    margin-bottom: 18px;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 700;
}

.auth-links a {
    color: var(--primary-dark);
}

.auth-links a:hover {
    color: var(--primary);
}

@media (min-width: 720px) {
    .main {
        padding: 28px 26px 40px;
    }

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

    .entry-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .create-user-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: end;
    }

    .user-row {
        grid-template-columns: minmax(260px, 1.3fr) 190px 190px 150px minmax(160px, 0.8fr) auto auto;
        align-items: end;
    }

    .entry-meta {
        display: grid;
        justify-items: end;
    }

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

    .detail-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
    }

    .detail-badges {
        justify-content: flex-end;
    }

    .filter-bar {
        grid-template-columns: 1fr 180px 180px auto;
        align-items: center;
    }

    .detail-title {
        grid-template-columns: 1fr auto;
        align-items: start;
    }
}

@media (min-width: 1024px) {
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-shell {
        display: grid;
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .sidebar {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
        padding: 22px;
        background: var(--nav-dark);
        color: #fff;
    }

    .sidebar-brand {
        color: #fff;
    }

    .sidebar-brand small {
        color: var(--nav-muted);
    }

    .nav {
        display: grid;
        gap: 8px;
        margin-top: 30px;
    }

    .nav a {
        padding: 13px 12px;
        border-radius: 8px;
        color: var(--nav-muted);
        font-weight: 650;
    }

    .nav a.active,
    .nav a:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.11);
    }

    .profile-card {
        display: grid;
        gap: 5px;
        margin-top: auto;
        padding: 14px;
        border: 1px solid var(--nav-line);
        border-radius: 8px;
        background: var(--nav-darker);
    }

    .profile-card strong {
        color: #fff;
    }

    .profile-card span {
        color: var(--nav-muted);
    }

    .profile-card a {
        margin-top: 8px;
        color: #fff;
        font-weight: 650;
    }

    .top-actions .menu {
        display: none;
    }

    .mobile-brand {
        display: none;
    }

    .sticky-actions {
        bottom: 0;
    }
}
