:root {
    --background: #f4f2ee;
    --surface: #ffffff;
    --surface-muted: #faf9f6;
    --ink: #1f2328;
    --ink-soft: #5b6168;
    --ink-faint: #8a9097;
    --line: #e4e0d8;
    --line-strong: #d3cec4;
    --accent: #1f5f5b;
    --accent-soft: #e3efed;
    --star: #d99a1e;
    --danger: #a8402f;
    --focus: #2563eb;
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    --columns: 44px 1fr 180px 184px 140px 170px 96px 112px 112px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: var(--font);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
    margin: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline-offset: 0;
}

[hidden] {
    display: none !important;
}

.button {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

.button:hover {
    border-color: var(--ink-faint);
}

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

.button-primary:hover {
    border-color: #174a47;
    background: #174a47;
}

.button:disabled {
    opacity: .45;
    cursor: default;
}

input[type="text"], input[type="search"], input[type="password"], select, textarea {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
}

textarea {
    height: auto;
    padding: 8px 10px;
    resize: vertical;
    line-height: 1.5;
}

.authentication {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.authentication-box {
    width: 400px;
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.authentication-box h1 {
    margin-bottom: 24px;
    font-size: 22px;
}

.authentication-box h2 {
    margin-bottom: 4px;
    font-size: 17px;
}

.authentication-box form {
    display: grid;
    gap: 8px;
}

.authentication-box label {
    margin-top: 8px;
    color: var(--ink-soft);
    font-size: 13px;
}

.authentication-box .button {
    justify-content: center;
    margin-top: 16px;
}

.authentication-hint {
    color: var(--ink-soft);
}

.authentication-error {
    margin-top: 8px;
    color: var(--danger);
}

.header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--line);
    background: var(--background);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 40px 16px;
}

.title {
    margin-right: 24px;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.search {
    max-width: 480px;
}

.new-customer {
    margin-left: auto;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 40px 14px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tab, .filter button {
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}

.tab:hover, .filter button:hover {
    background: var(--surface);
    color: var(--ink);
}

.tab.active, .filter button.active {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
}

.tab.active {
    border-color: color-mix(in srgb, var(--tab-color, var(--line-strong)) 55%, var(--surface));
    background: color-mix(in srgb, var(--tab-color, var(--surface)) 18%, var(--surface));
}

.tab-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 7px;
    border: 1px solid color-mix(in srgb, var(--tab-color, var(--ink-faint)) 75%, var(--ink));
    border-radius: 50%;
    background: var(--tab-color, var(--surface));
    vertical-align: 0;
}

.count {
    margin-left: 6px;
    color: var(--ink-faint);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.filter {
    display: flex;
    align-items: center;
    gap: 2px;
}

.filter button {
    padding: 0 8px;
}

.discard-reason-filter {
    margin-bottom: 8px;
}

.filter-label {
    margin-right: 6px;
    color: var(--ink-faint);
    font-size: 13px;
}

.content {
    padding: 16px 40px 80px;
}

.list-head, .customer-row {
    display: grid;
    grid-template-columns: var(--columns);
    align-items: center;
}

.list-head, .details-heading, .section-title {
    letter-spacing: .04em;
    text-transform: uppercase;
}

.list-head, .details-heading {
    color: var(--ink-faint);
    font-size: 12px;
    font-weight: 600;
}

.list-head {
    height: 36px;
}

.list-head > * {
    padding: 0 12px;
}

.sort {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.sort:hover {
    color: var(--ink);
}

.sort.active {
    color: var(--accent);
}

.sort.active::after {
    content: "↑";
    font-size: 13px;
}

.sort.active.descending::after {
    content: "↓";
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 8px 0 8px;
    color: var(--star);
    font-size: 13px;
    font-weight: 650;
}

.favorites-hint {
    color: var(--ink-faint);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.favorites {
    margin-bottom: 24px;
}

.favorites-list, .customers-list {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
}

.favorites-list {
    border-color: #ead7ae;
}

.customers-list:empty, .favorites-list:empty {
    display: none;
}

.empty {
    padding: 48px 0;
    color: var(--ink-faint);
    text-align: center;
}

.customer + .customer {
    border-top: 1px solid var(--line);
}

.customer-row {
    min-height: 48px;
    box-shadow: inset 3px 0 0 var(--stripe-color, transparent);
    cursor: pointer;
    transition: background .15s;
}

.customer-row:hover {
    background: var(--surface-muted);
}

.customer.open > .customer-row {
    background: var(--accent-soft);
}

.customer.open .design-count {
    background: var(--surface);
}

.customer-row > * {
    min-width: 0;
    padding: 0 12px;
}

.customer-row > *, .toggle, .field-value a, .link-item > a, .link-item > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toggle {
    max-width: 100%;
    padding: 4px 0;
    border: 0;
    background: none;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.toggle.unnamed {
    color: var(--ink-faint);
    font-weight: 400;
    font-style: italic;
}

.cell-date, .cell-design {
    color: var(--ink-soft);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.pill {
    width: auto;
    max-width: 100%;
    height: 28px;
    padding: 0 12px;
    border: 1px solid color-mix(in srgb, var(--pill-color, var(--line-strong)) 55%, var(--surface));
    border-radius: 999px;
    background: color-mix(in srgb, var(--pill-color, var(--surface)) 18%, var(--surface));
    color: color-mix(in srgb, var(--pill-color, var(--ink)) 50%, var(--ink));
    font-size: 13px;
    font-weight: 600;
    appearance: none;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}

.pill:hover {
    border-color: color-mix(in srgb, var(--pill-color, var(--ink-faint)) 70%, var(--ink));
}

.pill option {
    background: var(--surface);
    color: var(--ink);
}

.customer-row > .cell-priority {
    display: grid;
    gap: 2px;
    padding-block: 4px;
    overflow: visible;
}

.priority-line {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.discard {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: none;
    color: var(--ink-faint);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}

.customer-row:hover .discard {
    color: var(--ink-soft);
}

.customer-row .discard:hover, .discard.active {
    border-color: color-mix(in srgb, var(--discard-color) 55%, var(--surface));
    background: color-mix(in srgb, var(--discard-color) 18%, var(--surface));
    color: color-mix(in srgb, var(--discard-color) 50%, var(--ink));
}

.discard:focus-visible {
    border-radius: 50%;
}

.pill[data-action="discard_reason"] {
    justify-self: start;
    height: 22px;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 500;
    field-sizing: content;
}

.pill:is([data-action="priority"], [data-action="discard_reason"])[data-value=""] {
    border-style: dashed;
    color: var(--ink-faint);
    font-weight: 400;
}

.cell-feedback .pill[data-value=""] {
    border-color: transparent;
    background: transparent;
    color: transparent;
}

.customer-row:hover .pill[data-value=""], .cell-feedback .pill[data-value=""]:focus-visible {
    border-color: var(--line-strong);
    color: var(--ink-faint);
}

.pill.pill-strong {
    border-color: var(--pill-color);
    background: var(--pill-color);
    color: #fff;
    font-weight: 700;
}

.design-count {
    display: inline-block;
    min-width: 24px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.star {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-left: 6px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--line-strong);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s;
}

.star:hover {
    color: var(--star);
}

.star.active {
    color: var(--star);
}

.customer-row > .cell-star {
    padding: 0;
    overflow: visible;
}

.customer-details {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .32s cubic-bezier(.3, .7, .2, 1);
}

.customer.open > .customer-details {
    grid-template-rows: 1fr;
}

.details-clip {
    min-height: 0;
    overflow: hidden;
}

.details-inner {
    padding: 20px 24px 20px 56px;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .25s, transform .32s cubic-bezier(.3, .7, .2, 1);
}

.customer.open .details-inner {
    opacity: 1;
    transform: none;
}

.details-columns {
    display: grid;
    grid-template-columns: repeat(3, round(down, calc((100% - 80px) / 3), 1px));
    gap: 40px;
}

.details-heading {
    margin: 0 0 8px;
}

.details-group + .details-group {
    margin-top: 20px;
}

.field {
    display: grid;
    grid-template-columns: 112px 1fr;
    align-items: start;
    min-height: 32px;
}

.field-label {
    padding-top: 6px;
    color: var(--ink-soft);
    font-size: 13px;
}

.field-value {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    min-height: 32px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: text;
    overflow-wrap: anywhere;
    white-space: pre-line;
    transition: background .15s;
}

.field-value:hover {
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line);
}

.field-value.empty-value::before {
    content: "–";
    color: var(--line-strong);
}

.contact-date {
    width: auto;
    height: 32px;
    border: 0;
    background: none;
    cursor: pointer;
}

.contact-date::-webkit-calendar-picker-indicator {
    margin-left: 4px;
    opacity: .5;
    cursor: pointer;
}

.field-editor {
    display: block;
    padding: 0;
}

.field-editor input {
    height: 32px;
}

.saved {
    animation: saved 1.2s ease;
}

@keyframes saved {
    0%, 30% {
        background: #dcefe2;
        box-shadow: inset 0 0 0 1px #9cd0ad;
    }
    100% {
        background: transparent;
    }
}

.link-list {
    display: grid;
    gap: 2px;
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
    padding: 2px 4px 2px 8px;
    border-radius: 6px;
}

.link-item:hover {
    background: var(--surface);
}

.link-item > a, .link-item > span {
    flex: 1;
    min-width: 0;
}

.link-item.editing {
    padding: 0;
}

.icon-button {
    display: grid;
    flex: none;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--ink-faint);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
}

.link-item:hover .icon-button, .field-value:hover .icon-button, .icon-button:focus-visible {
    opacity: 1;
}

.icon-button:hover {
    background: var(--line);
    color: var(--ink);
}

.icon-button[data-action="delete-link"]:hover {
    color: var(--danger);
}

.link-form {
    display: grid;
    grid-template-columns: round(down, calc((100% - 6px) / 2), 1px) 1fr;
    gap: 6px;
}

.link-form input {
    height: 32px;
    font-size: 14px;
}

.legal-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.legal-button {
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.legal-button:hover {
    border-color: var(--ink-faint);
}

.legal-button[aria-pressed="true"] {
    border-color: var(--danger);
    background: #f6e4e0;
    color: var(--danger);
    font-weight: 600;
}

.details-textarea {
    min-height: 96px;
    max-height: 300px;
    overflow-y: auto;
}

.details-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.details-dates {
    color: var(--ink-faint);
    font-size: 13px;
}

.discard-customer {
    margin-left: auto;
}

.delete-customer {
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--ink-faint);
    font-size: 13px;
    cursor: pointer;
}

.delete-customer:hover {
    color: var(--danger);
    text-decoration: underline;
}

.toast {
    position: fixed;
    right: 32px;
    bottom: 32px;
    z-index: 20;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
}

.toast.visible {
    opacity: 1;
    transform: none;
}

.toast.error {
    background: var(--danger);
}
