/* ==========================================================================
   RFID Product Display — design system
   Solid colors only. Motion is 150–250 ms and honors prefers-reduced-motion.
   ========================================================================== */

:root {
    /* Color */
    --navy: #172B3A;
    --navy-hover: #1E3A4C;
    --accent: #0D9488;
    --accent-strong: #0B7C72;
    --accent-soft: #E6F3F1;
    --bg: #F5F7F8;
    --surface: #FFFFFF;
    --text: #202B33;
    --text-2: #687782;
    --border: #DFE5E8;
    --success: #16845B;
    --success-soft: #EBF5F0;
    --success-border: #C3E0D3;
    --danger: #D64545;
    --danger-hover: #BF3A3A;
    --danger-soft: #FCEFEF;
    --danger-border: #F0CBCB;
    --code-bg: #F0F5F6;
    --row-hover: #F8FAFB;
    --overlay: rgba(23, 43, 58, .44);
    --ring: rgba(13, 148, 136, .28);
    --shadow-modal: 0 18px 44px rgba(23, 43, 58, .20);

    /* Type */
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, "SF Mono", Menlo, monospace;

    /* Shape & motion */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --ease: cubic-bezier(.2, .7, .3, 1);
    --t-fast: .15s;
    --t: .2s;

    /* Layout */
    --container: 1000px;
    --header-h: 60px;

    color-scheme: light;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
p {
    margin: 0;
}

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

svg {
    display: block;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 16px;
}

.page-main {
    padding-top: 26px;
    padding-bottom: 56px;
}

.stack {
    display: grid;
    gap: 18px;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-h);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: var(--r-md);
    background: var(--navy);
    color: #fff;
}

.brand-mark svg {
    width: 17px;
    height: 17px;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Page headings
   -------------------------------------------------------------------------- */

.page-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.015em;
    color: var(--navy);
}

.page-desc {
    margin-top: 6px;
    max-width: 62ch;
    font-size: 14.5px;
    color: var(--text-2);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font: 600 13.5px/1 var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, color var(--t-fast) ease;
}

.btn:hover {
    background: var(--bg);
}

.btn svg {
    width: 15px;
    height: 15px;
    flex: none;
}

.btn-primary {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

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

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

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

.btn-ghost:hover {
    background: var(--bg);
    border-color: var(--border);
    color: var(--navy);
}

.btn-block {
    width: 100%;
    height: 42px;
}

.btn:disabled {
    opacity: .65;
    cursor: default;
}

.spinner {
    display: none;
    width: 14px;
    height: 14px;
    flex: none;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    animation: spin .7s linear infinite;
}

.is-loading {
    pointer-events: none;
}

.is-loading .spinner {
    display: inline-block;
}

/* --------------------------------------------------------------------------
   Panels
   -------------------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-head-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.panel-title {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--navy);
}

.panel-body {
    padding: 16px;
}

.count {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Live status + update hint
   -------------------------------------------------------------------------- */

.live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 12px;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.live-dot {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: var(--text-2);
    transition: background-color var(--t) ease;
}

.live[data-state="live"] .live-dot {
    background: var(--success);
}

.live[data-state="offline"] .live-dot {
    background: var(--danger);
}

.updated {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-strong);
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity .18s ease, transform .18s ease;
}

.updated::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background: var(--accent);
}

.updated.is-visible {
    opacity: 1;
    transform: none;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

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

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 10px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-2);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.table tbody tr {
    transition: background-color var(--t-fast) ease;
}

.table tbody tr:hover {
    background: var(--row-hover);
}

.cell-name {
    font-weight: 500;
}

.code {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1;
    letter-spacing: .01em;
    color: var(--text);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 4px 7px;
    white-space: nowrap;
}

.th-actions {
    text-align: right !important;
}

.cell-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* Row change animations (driven by app.js) */
.table tbody tr.row-enter {
    opacity: 0;
    animation: rowIn .2s var(--ease) forwards;
}

.table tbody tr.row-leave {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .16s ease, transform .16s ease;
}

.table tbody tr.row-updated {
    animation: rowFlash .24s ease;
}

/* --------------------------------------------------------------------------
   Icon buttons
   -------------------------------------------------------------------------- */

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: color var(--t-fast) ease, background-color var(--t-fast) ease, border-color var(--t-fast) ease;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn:hover {
    background: var(--bg);
    border-color: var(--border);
    color: var(--navy);
}

.icon-btn.danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form {
    display: grid;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font: 14.5px/1 var(--font-sans);
    transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}

input::placeholder {
    color: #93A1AA;
}

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

/* Keep the design when the browser autofills a field. */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    -webkit-text-fill-color: var(--text);
}

input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 3px var(--ring);
}

input.mono {
    font-family: var(--font-mono);
    font-size: 13.5px;
    letter-spacing: .01em;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */

.notices {
    display: grid;
    gap: 10px;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    font-size: 13.5px;
    color: var(--text);
    animation: noticeIn var(--t) var(--ease) backwards;
}

.notice svg {
    width: 16px;
    height: 16px;
    flex: none;
    margin-top: 1.5px;
}

.notice-success {
    background: var(--success-soft);
    border-color: var(--success-border);
}

.notice-success svg {
    color: var(--success);
}

.notice-error {
    background: var(--danger-soft);
    border-color: var(--danger-border);
}

.notice-error svg {
    color: var(--danger);
}

.notice.is-leaving {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-2);
}

.empty-icon svg {
    width: 20px;
    height: 20px;
}

.empty-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--navy);
}

.empty-text {
    max-width: 36ch;
    font-size: 13.5px;
    color: var(--text-2);
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: grid;
    padding: 32px 16px;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
    margin: auto;
    display: grid;
    gap: 18px;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-panel {
    padding: 24px;
}

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

.login-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--navy);
}

.login-desc {
    margin-top: 4px;
    font-size: 13.5px;
    color: var(--text-2);
}

.login-panel .notices {
    margin-bottom: 18px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    justify-self: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    transition: color var(--t-fast) ease;
}

.back-link svg {
    width: 14px;
    height: 14px;
}

.back-link:hover {
    color: var(--navy);
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay);
    opacity: 0;
    transition: opacity .18s ease;
}

.modal-panel {
    position: relative;
    width: min(420px, 100%);
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-modal);
    opacity: 0;
    transform: scale(.97) translateY(4px);
    transition: opacity .18s ease, transform .18s var(--ease);
}

.modal.is-open .modal-overlay {
    opacity: 1;
}

.modal.is-open .modal-panel {
    opacity: 1;
    transform: none;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
}

.modal-text {
    margin-top: 8px;
    font-size: 13.5px;
    color: var(--text-2);
}

.modal-text strong {
    font-weight: 600;
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

.page-enter {
    animation: pageIn .22s var(--ease) both;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes rowIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes rowFlash {
    from {
        background-color: var(--accent-soft);
    }
    to {
        background-color: transparent;
    }
}

@keyframes noticeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (min-width: 640px) {
    .form-row {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    }
}

@media (min-width: 720px) {
    .container {
        padding: 0 28px;
    }
}

@media (max-width: 560px) {
    input[type="text"],
    input[type="password"] {
        font-size: 16px; /* prevents mobile browsers from zooming on focus */
    }

    .btn-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .btn-ghost {
        width: 38px;
        padding: 0;
    }
}


