:root {
    --border: #dcdcdc;
    --text: #111;
    --muted: #666;
    --bg: #fff;
    --panel: #f7f7f7;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    border-bottom: 1px solid var(--border);
    background: white;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}

.brand a {
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}

.nav a {
    margin-left: 14px;
    text-decoration: none;
    color: var(--text);
}

.nav a:hover {
    text-decoration: underline;
}

main.container {
    padding: 24px 0;
}

.footer {
    border-top: 1px solid var(--border);
    margin-top: 32px;
    padding: 16px 0;
    color: var(--muted);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.table th, .table td {
    border: 1px solid var(--border);
    padding: 10px;
    vertical-align: top;
}

.table th {
    background: var(--panel);
    text-align: left;
}

.tabs {
    display: flex;
    gap: 8px;
    margin: 14px 0;
    flex-wrap: wrap;
}

.tab {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    background: white;
}

.tab.active {
    background: var(--panel);
    font-weight: 600;
}

.panel {
    border: 1px solid var(--border);
    background: var(--panel);
    padding: 14px;
    border-radius: 10px;
}

.button {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    background: white;
    color: var(--text);
    cursor: pointer;
}

.button:hover {
    background: var(--panel);
}

.button.secondary {
    background: var(--panel);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    max-width: 520px;
}

.form-row input, .form-row select, .form-row textarea {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.error {
    color: #b00020;
    font-size: 0.9rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    text-decoration: none;
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--panel);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.note-cell {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.note-text {
    flex: 1;
    min-width: 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.note-empty {
    color: var(--muted);
    font-style: italic;
}

.icon-btn.danger {
    border-color: #e0b4b4;
}

.icon-btn.danger:hover {
    background: #ffecec;
}

.icon-btn.danger svg {
    fill: currentColor;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
}

/* =========================================================
   CUSTOMERS (KEEPING ALL WORK WE DID)
   - Row coloring: green active, yellow returned
   - Floating pill anchored in Tablet UUID column
   ========================================================= */

.customers-table tbody tr.active-row td {
    background: #e9f7ee; /* light green */
}

.customers-table tbody tr.returned-row td {
    background: #fff7df; /* light yellow */
}

.customers-table tbody tr:hover td {
    filter: brightness(0.985);
}

/* Tablet UUID cell anchors the floating actions capsule */
.customers-lastcol {
    position: relative;
    overflow: visible;
    padding-right: 70px; /* reserve space so text doesn't sit under circle */
    vertical-align: middle;
}

.customers-lastcol-text {
    display: inline-block;
}

/* =========================================================
   STORAGE (NEW) – device row coloring
   Green: ready-to-go
   Yellow: just confirmed back
   Red: damaged
   ========================================================= */

.storage-table tbody tr.device-ready td {
    background: #e9f7ee; /* light green */
}

.storage-table tbody tr.device-recent td {
    background: #fff7df; /* light yellow */
}

.storage-table tbody tr.device-damaged td {
    background: #ffe3e3; /* light red */
}

.storage-table tbody tr:hover td {
    filter: brightness(0.985);
}

/* =========================================================
   EXPANDABLE CAPSULE (reused in Customers + Storage)
   - Equal padding all around inside the pill
   - Toggle pinned on right end, expands left
   - Floating version hangs half off right edge
   ========================================================= */

.actions-shell {
    --actions-count: 2;

    --btn-size: 34px;
    --btn-gap: 10px;

    /* equal padding all around */
    --capsule-pad: 8px;

    /* capsule height = button + padding*2 */
    --toggle-size: calc(var(--btn-size) + (var(--capsule-pad) * 2));

    --actions-width: calc(
            (var(--actions-count) * var(--btn-size)) +
            ((var(--actions-count) - 1) * var(--btn-gap))
    );

    --open-width: calc(
            var(--toggle-size) +
            (var(--capsule-pad) * 2) +
            var(--actions-width)
    );

    display: inline-flex;
    align-items: center;

    /* reverse so toggle stays on RIGHT end */
    flex-direction: row-reverse;

    height: var(--toggle-size);
    width: var(--toggle-size);
    border: 1px solid #222;
    border-radius: 999px;
    background: #fff;
    overflow: hidden;

    transition: width .16s ease;
}

.actions-shell.open {
    width: var(--open-width);
}

/* Floating placement: half off the right edge of the anchor cell */
.actions-shell--floating {
    position: absolute;
    right: calc(var(--toggle-size) / -2);
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

.actions-toggle {
    width: var(--toggle-size);
    height: var(--toggle-size);
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    flex: 0 0 auto;
}

.actions-items {
    display: inline-flex;
    align-items: center;
    gap: var(--btn-gap);

    /* equal spacing from pill edges */
    padding: var(--capsule-pad);

    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
}

.actions-shell.open .actions-items {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.pill-btn {
    width: var(--btn-size);
    height: var(--btn-size);
    border-radius: 999px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    background: #eee;
    color: #111;
}

.pill-btn.lock { background: #f2c94c; }
.pill-btn.plus { background: #27ae60; color: #fff; }
.pill-btn.danger { background: #eb5757; color: #fff; }
